Just trying to use the code in the example
Code:
#z::
#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
Return
When I try to run the example above I get an error message "In RegionWaitChange.AKH : A label must not point to a function
016 : Return
--> 034: {
but the values returned in error message do not seem to relate to the file at all
Code:
/*
Function: RegionWaitChange
Waits for a region of a window to change.
Parameters:
x, y - coordinates relative to window
w, h - size of the region to monitor (default: 1 and 1 respectively)
t - window title (default: Last Found Window <http://www.autohotkey.com/docs/LastFoundWindow.htm>)
f - check frequency in milliseconds (default: 500)
s - maximum image buffer size (default: 64 MiB)
inv - *reserved*
Function: RegionWaitStatic
Identical to the previous function except waits until the specified region stops changing.
Function: DCCBitmapHash
Returns an MD5 hash of a window region.
Parameters:
hwnd - window handle
x, y - coordinates relative to window
w, h - size of region
s - maximum image buffer size (default: 64 MiB)
About: License
- Version 1.01 by Titan <http://www.autohotkey.net/~Titan/#regionwaitchange>
- GNU General Public License 3.0 or higher <http://www.gnu.org/licenses/gpl-3.0.txt>
*/
RegionWaitChange(x, y, w = 1, h = 1, t = "", f = 500, s = 67108864, inv = false) {
hwnd := WinExist(t)
Loop {
hc := DCCBitmapHash(hwnd, x, y, w, h, s)
If ((inv ? hc = lhc : hc != lhc) and lhc != "")
Return, true
lhc := hc
Sleep, f
}
}
RegionWaitStatic(x, y, w = 1, h = 1, t = "", f = 1000, s = 67108864) {
RegionWaitChange(x, y, w, h, t, f, s, true)
}
DCCBitmapHash(hwnd, x, y, w = 1, h = 1, s = 67108864) {
hdc := DllCall("GetDC", "UInt", hwnd)
hcdc := DllCall("CreateCompatibleDC", "UInt", hdc)
hbmp := DllCall("CreateCompatibleBitmap", "UInt", hdc, "UInt", w, "UInt", h)
DllCall("SelectObject", "UInt", hcdc, "UInt", hbmp)
DllCall("BitBlt", "UInt", hcdc, "Int", 0, "Int", 0, "Int", w, "Int", h
, "UInt", hdc, "Int", x, "Int", y, "UInt", 0x00CC0020) ; SRCCOPY
sz := VarSetCapacity(bits, s, 0)
sz := DllCall("GetBitmapBits", "UInt", hbmp, "UInt", sz, "UInt", &bits)
DllCall("DeleteObject", "UInt", hbmp)
DllCall("DeleteDC", "UInt", hcdc)
DllCall("ReleaseDC", "UInt", hwnd, "UInt", hdc)
Return, GetHashCode(bits, sz)
}
#Include Hash.ahk
Has anyone any thoughts - sorry to be a newbie pest
Code: