The inbuilt methods, while easy to use, have limitations.
The limitations which I'm motivated to work around are:
- Both PixelSearch and PixelGetColor fail to return valid results for any Fullscreen OpenGL or D3D process in Windows 7.
They worked fine in XP but are broken now, I'm unsure exactly why or if its fixable with some OS setting. It isn't Aero related afaik.
- Pixelsearch only searches one direction in fast mode, leaving 3/4ths of any searched-for object invisible to the script.
Say I wanted to get the bottom or right limit of an object by scanning pixels, I couldn't without some slow iterative loop.
- Prior attempts to work around these have either been FAR too slow (say, ten million times slower than PixelSearch, Fast was in WinXP) or too resource-intensive.
With these in mind, my goal is to create a replacement function which is comparable in speed and resource use to the optimized default fastmode,
while removing the directional constraint and the fullscreen broken-ness.
My plan is to first identify which single-pixel read method is most efficient, provided it works for fullscreen apps.
After that, I'd write some search functions using it, either by capturing a chunk of the screen at once and parisng it, or by iterating one pixel at a time.
My guess is that the parse method is the better idea, but I'm not at that stage yet.
Finally, I'd replicate the search function in a language which can be compiled to MCode (duno if ahk can) and use the result of that in my scripts.
I'll likely need some help with each stage, but for now I'll just ask:
What is the most efficient (read: fast and not resource-hungry) way of getting pixel color data from a fullscreen OpenGL or D3D application in Windows 7?
I've included an attempt using GDI+ bitmap from screen, which is hugely resource hungry and eats up an entire processor core while causing the target applications smooth operation to suffer. Clearly, this is not the method I should be using.
;// TRYING to build a method of reading pixels quickly from a fullscreen D3D or OpenGL window without causing lag
;// the default "pixelsearch, fast" mode is quick enough, unfortunately it is directionally limited and incapable of seeing pixels in any fullscreen application due to some windows 7 malarkey.
;// this method is the start of my attempt to rectify these weaknesses.
;// it is really inefficient and causes a huge performance hit :(
#Persistent
#KeyHistory, 0
#NoEnv
#HotKeyInterval 1
#MaxHotkeysPerInterval 127
#SingleInstance, Force
SetKeyDelay,-1, 8
SetControlDelay, -1
SetMouseDelay, -1
SetWinDelay,-1
SendMode, Event
SetBatchLines,-1
ListLines, Off
CoordMode, Pixel, Relative, RGB
CoordMode, Mouse, Relative
PID := DllCall("GetCurrentProcessId")
Process, Priority, %PID%, Low
#Include Gdip.ahk
pToken := GDIP_StartUp()
Loop, {
pBitMap := GDIP_BitmapFromScreen()
MouseGetPos, x_in, y_in
PixelGetColor, PRGB, %x_in%, %y_in%, RGB
ARGB := GDIP_GetPixel( pbitmap, x_in, y_in )
GDIP_DisposeImage( pBitMap )
MRGB := ARGB2RGB( ARGB )
ToolTip, %x_in% | %y_in% | %ARGB% | %MRGB%
GoSub, SleepF
}
pixelsearchup() {
;to be done once i have a useable pixel reading method that doesnt lag me
}
pixelsearchdown() {
;to be done once i have a useable pixel reading method that doesnt lag me
}
pixelsearchleft() {
;to be done once i have a useable pixel reading method that doesnt lag me
}
pixelsearchright() {
;to be done once i have a useable pixel reading method that doesnt lag me
}
argb2rgb(argb){
argb := argb & 0x00ffffff
return "0x" . argb
}
SleepF:
SleepDuration = 1
TimePeriod = 1
DllCall("Winmm\timeBeginPeriod", uint, TimePeriod)
Iterations = 1
StartTime := A_TickCount
Loop, %Iterations% {
DllCall("Sleep", UInt, TimePeriod)
}
DllCall("Winmm\timeEndPeriod", UInt, TimePeriod)
Return




