Registry changes not being recognised

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bapiman
Posts: 9
Joined: 20 Jan 2017, 08:10

Registry changes not being recognised

22 May 2018, 09:05

Hi there
Hope you can help. I am trying to create a script that will tell me if a registry entry changes (ie the proxy server on the PC) changes. Everything I need the script to do is working fine...but the problem is if the registry entry is completed deleted (or if some characters are removed from the proxy server to make it incorrect)...the script does not recognize the change.

The proxy server entry in registry is: http://tws-testproxy-shantodomain.org:8000
If for instance the port number chances to: http://tws-testproxy-shantodomain.org:8999

The popup comes up fine signifying the change. However if some characters are removed: http://tws-testproxy-shantodomain.org:80
The script does register that the registry entry as changed. Completely removing this reg key also does not register anything. Would anyone have any ideas? Here is the script below - many thanks for any assistance you can provide...


Code: Select all


start:
sleep, 1000
;This reads the DATA value (proxy URL) in the registry under Name "AutoConfigUrl" and stores it in variable REG1
RegRead, reg1, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows\CurrentVersion\internet settings, AutoConfigURL     


;This is saying that variable PROXY refers to string: http://tws-testproxy-shantodomain.org:8000
proxy=http://tws-testproxy-shantodomain.org:8000


IfInString, proxy, %reg1%   ;so if the PROXY variable contains same text as REG1 variable (if proxy reg key equals http://tws-testproxy-shantodomain.org:8000) then continue the script that checks the registry by going back to label START:

goto, start


; If suddenly the registry proxy server changes and thus REG1 key is different to PROXY...then msgbox should come up saying "Its Changed" and the change is recorded in txt file regrecord.txt

Else

;FormatTime = built command to get the DateTime - store it into variable %TimeString%
FormatTime, TimeString

FileAppend, `n
( 
At %TimeString%, the registry key %proxy% was changed to %reg1%
), c:\temp\regrecord.txt


MsgBox, 3, , Yes to continue checking. No to open Notepad. Cancel to close script

IfMsgBox, Yes
   goto, start           
   
IfMsgBox, No
   goto, notepad

IfMsgBox, Cancel
exit



notepad:
run, c:\temp\regrecord.txt

goto, start

bapiman
Posts: 9
Joined: 20 Jan 2017, 08:10

Re: Registry changes not being recognised

22 May 2018, 09:06

Sorry...I meant to say:
However if some characters are removed: http://tws-testproxy-shantodomain.org:80
The script does "NOT" register that the registry entry as changed. Completely removing this reg key also does not register anything.
kadhri
Posts: 49
Joined: 12 Nov 2015, 06:52

Re: Registry changes not being recognised

22 May 2018, 09:28

Hi bapiman,
Instead of ifinstring use if
If proxy = reg1

Regards,
Sdk
RickC
Posts: 299
Joined: 27 Oct 2013, 08:32

Re: Registry changes not being recognised

22 May 2018, 12:08

After your first RegRead I would add, temporarily, a MsgBox %reg1% to check you have some data.

If the MsgBox doesn't show any data then have a look at the use of SetRegView (for using 32-bit AHK in a 64-bit environment and vice versa).

Hope this helps...
bapiman
Posts: 9
Joined: 20 Jan 2017, 08:10

Re: Registry changes not being recognised

23 May 2018, 07:15

Hi all
Thanks very much for all your help. Just changing it to IF made all the difference, all makes sense now why "ifinstring" did not work.

The Message box idea to check the data was good aswell - infact I added a gui to this so the theres a button which opens the msgbox to check there is any data captured.
Thanks

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Anput, Google [Bot], Nerafius, RandomBoy and 137 guests