01304 827609 info@use-ip.co.uk Find us

My AutoHotKey script to automatically launch the web interface

downhiller

Member
Messages
10
Points
1
Very often I'm on my laptop when I hear a vehicle, and want to know if it's someone coming up our drive. We have a very friendly labrador and it's good to know to be wary of him potentially getting run over...

I used to launch IE, and have to sign in manually, like a pleb. This took, I dunno, maybe 10 seconds. Feels slow and tedious though.

I've now installed AutoHotKey and learnt how to do the following. I just hit Win+Z and up it pops. Some of you might find it useful.

It dosn't just log in, but changes the live view display to 3x3, and adds my IP camera into screen position 6, and makes the whole thing full screen. I feel the web interface should remember the layout you had last time you launched it, but it certainly doesn't seem to for me?

Anyway, here's the script:

(Disclaimer: this is for my aging DS-7216HGHI-SH box - I don't know how the web interface of newer boxes might vary, but this might give you some pointers as to how to write your own script for your needs)

Code:
#z::
    wb := ComObjCreate("InternetExplorer.Application")

    wb.Visible := True

    wb.Navigate("http://192.168.1.6/doc/page/login.asp")

    While wb.readyState != 4 || wb.document.readyState != "complete" || wb.busy ; wait for the page to load
        Sleep, 10

    Sleep, 10

    un := wb.document.getElementById("username")

    un.focus()
    SendInput, myusername{tab}
    SendInput, mypassword{enter}

    Sleep, 500

    wb.document.querySelector(".btn[title=""Full Screen""]").click()

    ; switches to 3x3 layout
    wb.document.querySelector("#pop_menu_1 button:nth-child(3)").click()

    Sleep, 150

    ; clicks into camera position 6 (on my 1920 x 1080 display)
    Click, 1800, 600

    ; adds my IP camera into the above position
    wb.document.querySelector(".channel-list .ch:nth-child(17) .ch-btns .ch-btn").click()

Return

Obviously you need to substitute your username and password. Don't put quotes around them, just enter them raw. And your box's IP address - and you'll want to assign a static IP to your box in your router's DHCP settings (or on the box itself, but the former is better practice) if you haven't already.

The various Sleep commands (the numbers are milliseconds and make the script pause) appear to be necessary to make it reliable - depending on your network/computer you might be able to shorten them or may have to entend them.


I hope someone else finds this useful!
 
Last edited:
Back
Top