Seven0528 wrote: ↑16 Apr 2024, 13:48
@redrum
Finally! I'm glad I could help you
Thank you so much for the help!
In the following code you provided, is there a good (or even possible) place to either (1) subdivide the original window or image, or (2) specify search area?
Code: Select all
winGetPos(&winX, &winY, &winW, &winH, hWnd)
;------------------
hbm:=CreateDIBSection(winW, winH), hdc:=CreateCompatibleDC(), obm:=SelectObject(hdc, hbm)
PrintWindow(hwnd, hdc)
pHaystack:=Gdip_CreateBitmapFromHBITMAP(hbm)
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
bufHaystack:=ImagePutBuffer(pHaystack)
;------------------
state:=-1 ; Unknown
variation:=5 ; I thought a little variation wouldn't be necessary, but it is needed. I'm not sure why.
loop 1 {
if (xys:=bufHaystack.ImageSearchAll(bufNeedleOff,variation)) {
if (xys.length) {
state:=0 ; Off
break
}
}
if (xys:=bufHaystack.ImageSearchAll(bufNeedleOn,variation)) {
if (xys.length) {
state:=1 ; On
break
}
}
}
I have two trading charts stacked together (these are 1 window as far as Windows is concerned, so both charts are part of `hWnd` and the subsequent `bufHaystack`. So your code is essentially searching to see if the toggle button for the upper chart is on/off. I'd like to be able to check the lower chart as well.
I use one hotkey to make the upper chart active, and a separate hotkey to make the lower chart active (either hotkey makes the entire window active as far as Windows is concerned, but the charts are activated separately as far as Quantower is concerned, meaning if I use 1st hotkey to active upper chart, QT built-in trading hotkeys will impact only upper chart. So what I'd like to do is create a script that activates upper chart, then checks if toggle button for upper chart is enabled (if so, do nothing) or disabled (if so, enable). So I only need to search upper half of image generated downstream of `hWnd`. When I activate lower chart, I want to search lower half of image.
That's why I'm wondering if somewhere downstream of `hWnd`, the image can be subdivided.