Waits for a region of a window to change or stop changing by using GDI bitmap functions and MD5 hashes. Requires Windows Vista or Windows XP. Earlier versions of Windows can be supported by using PhiLho and Laszlo's binary encoding libraries, although they're much slower. Details included in the scripts.
Download
RegionWaitChange: wait for region to change or stop changing
Started by
polyethene
, Aug 15 2007 04:56 PM
13 replies to this topic
Really nice function. Amazingly compact.
Since I know some people have asked for this, I'm surprised no one replied. I suspect it's definitely getting used though!
Since I know some people have asked for this, I'm surprised no one replied. I suspect it's definitely getting used though!
#2
-
Posted 02 September 2007 - 12:50 AM
I was already aware of this script, but now I actually read it. Excellent stuffs!
I have a suggestion. Use DeleteDC, not ReleaseDC, for hcdc.
I have a suggestion. Use DeleteDC, not ReleaseDC, for hcdc.
#3
-
Posted 02 September 2007 - 01:20 AM
Thanks Titan.
The script certainly look interesting, but I cannot get it to work. I am sure it is just my incompetence. Specifically, I cannot see what the following line does
An example script just measuring change in the active windows would be very good.
Regards,
David
The script certainly look interesting, but I cannot get it to work. I am sure it is just my incompetence. Specifically, I cannot see what the following line does
hwnd := WinExist(t)WinExist does not seem to be a function in the documentation, and hwnd is always 0x0.
An example script just measuring change in the active windows would be very good.
Regards,
David
#5
-
Posted 05 September 2007 - 12:18 PM
WinExist() is a built-in function, maybe you need to update your version of AutoHotkey. Here is a working example:
#Include RegionWaitChange.ahk Run, notepad ; open notepad WinWait, Untitled - Notepad ; wait for window to exist ControlSetText, Edit1 ; delete any current text MsgBox, Notepad is empty`, press F12 to fill it with random text. ; monitor the region of 100px width and height from coordinate (10, 10): RegionWaitChange(10, 10, 100, 100, "Untitled - Notepad") ; once the region changed the script will continue here: MsgBox, Notepad has changed! (RegionWaitChange completed) WinClose ExitApp F12:: VarSetCapacity(dots, 5000, Asc(".")) ; fill a variable with something ControlSetText, Edit1, %dots%, Untitled - Notepad ; change the text on notepad artificially dots = ; free variable ReturnIf you still can't get your script to work please post it.
#6
-
Posted 05 September 2007 - 01:22 PM
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
Thanks a lot Titan! It works like a charm! One use of this script would be when you start an operation that takes several minutes to finish. It would then be good to be able to push a single hotkey which would monitor the entire screen (maybe even double screens ) and make a sound when the screen changes.
#7
-
Posted 05 September 2007 - 07:16 PM
Thanks, I appreciate that. I originally wrote this for my game macros but then realized it could be used for other purposes such as event handling in the cases you mentioned. I believe it was a long requested feature as well.
#8
-
Posted 05 September 2007 - 11:21 PM
autohotkey.com/net Site Manager
Contact me by email (polyethene at autohotkey.net) or message tidbit
Ive just combined this with Rolands Gui from his wincut script to make it even easier for newcomers.
#Include RegionWaitChange.ahk +#LButton:: CoordMode, Mouse MouseGetPos, sx, sy, win WinGettitle,title, ahk_id%win% Gui, +lastfound +alwaysOnTop +toolwindow -caption Gui, Color, 00FFFF WinSet, Transparent, 50 Gui, Show, noActivate Loop { if !getKeyState("LButton", "p") break MouseGetPos, x, y Gui, Show, % "x" sx "y" sy "w" x-sx "h" y-sy } WinGetPos, gx, gy, w, h Gui, destroy msgbox %title% RegionWaitstatic(gx, gy, w, h, title) msgbox exitapp return
#9
-
Posted 06 September 2007 - 01:44 AM
I'm if correct that script waits until a region has changed or stops changing, meaning it pauses the script? How do I make it so that the script continues until the region changes? Thanks!
#10
-
Posted 26 May 2009 - 03:27 AM
I'm if correct that script waits until a region has changed or stops changing, meaning it pauses the script? How do I make it so that the script continues until the region changes? Thanks!
SetTimer, SomethingToDo, 5000 RegionWaitWhatever(arg, arrg, arrrg) SetTimer, SomethingToDo, off return SomethingToDo: msgbox, 0, Working...,...yeah, right., 3 return:lol:
#11
-
Posted 26 May 2009 - 04:13 AM
in the zip, the files have GPL licenses, but on your scripts webpage, it says BSD license
which is the correct license for this function?
which is the correct license for this function?
#12
-
Posted 27 September 2010 - 01:49 AM
Ive been playing with the WaitRegionStatic function because I'd like to write a hotkey which navigates a series of pages on a website and is not dependent on predetermined sleep delays (due to the variability of internet speed this is not feasible). However, I have found that the script always seems to continue before the region actually stops changing. For example, to test this function, I was watching a youtube video of a strobe light and designated a certain pixel to be monitored. Although the entire region was changing colour quite rapidly, the script continued after a few seconds, indicating that the region was static when in fact it was not. I am using windows vista as is required by this function. Any suggestions?
#13
-
Posted 19 May 2011 - 02:40 AM
Thanks for this script, it's been very useful to me for scripting some automated test suites for development.
It actually hasn't worked for me on some computers however, I chased it down to GetHashCode() always returning null.
Turns out DllCall("advapi32\CryptAcquireContext doesn't always work immediately, I was getting NTE_BAD_KEYSET error. I used
<!-- m -->http://msdn.microsof...ry ... 85).aspx<!-- m -->
as a guide to fix it:
Cheers,
Andrew
It actually hasn't worked for me on some computers however, I chased it down to GetHashCode() always returning null.
Turns out DllCall("advapi32\CryptAcquireContext doesn't always work immediately, I was getting NTE_BAD_KEYSET error. I used
<!-- m -->http://msdn.microsof...ry ... 85).aspx<!-- m -->
as a guide to fix it:
GetHashCode(ByRef data, len = -1, alg_id = 0x8003) { err := DllCall("advapi32\CryptAcquireContext", "UIntP", hProv, "UInt", 0, "UInt", 0, "UInt", 1, "UInt", 0) ; PROV_RSA_FULL = 1 if err = 0 { err := DllCall("GetLastError") if (err & 0xFFFFFFFF) = 0x80090016 ;NTE_BAD_KEYSET { ;No default container was found. Attempt to create it. err := DllCall("advapi32\CryptAcquireContext", "UIntP", hProv, "UInt", 0, "UInt", 0, "UInt", 1, "UInt", 8) ; PROV_RSA_FULL = 1, CRYPT_NEWKEYSET = 0x00000008 if err = 0 { msgbox, Problem with the WinCypt subsystem exit } } } DllCall("advapi32\CryptCreateHash", "UInt", hProv, "UInt", alg_id, "UInt", 0, "UInt", 0, "UIntP", hHash) DllCall("advapi32\CryptHashData", "UInt", hHash, "UInt", &data, "UInt", len < 0 ? VarSetCapacity(data) : len, "UInt", 0) ssz := VarSetCapacity(sz, 4, 0) DllCall("advapi32\CryptGetHashParam", "UInt", hHash, "UInt", 4, "UIntP", sz, "UIntP", ssz, "UInt", 0) VarSetCapacity(HashVal, sz, 0) DllCall("advapi32\CryptGetHashParam", "UInt", hHash, "UInt", 2, "UInt", &HashVal, "UIntP", sz, "UInt", 0) BinaryToString(str, HashVal, false, sz) DllCall("advapi32\CryptDestroyHash", "UInt", hHash) DllCall("advapi32\CryptReleaseContext", "UInt", hProv, "UInt", 0) Return, str }
Cheers,
Andrew
#14
-
Posted 28 June 2012 - 12:50 AM