How to do gdi pixel search with this color Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
TheLegend27

How to do gdi pixel search with this color  Topic is solved

23 Mar 2018, 23:23

I was reading some old posts in the forum and I saw that people are using something called GDI+ library functions for better performance.

But I don't understand a thing lol this is all chinese and japanese to me. I tried searching for so long for some kind of tutorial and I only found this post https://autohotkey.com/board/topic/7172 ... xelsearch/ and even that is not very helpful and that is pixelgetcolor I want pixelsearch.


How do I use that better performance function in this? I don't have the function there's such a long list of chinese I don't know what to do with all of those.

^p::
PixelSearch, X, Y, 0, 0, 500, 500, 0x644E37, 0, Fast RGB
If (ErrorLevel = 2) {
Msgbox ERROR
ExitApp
}
else If (ErrorLevel = 1)
Msgbox NOT FOUND!
Else if (ErrorLevel = 0)
MouseMove, %X%, %Y%,
Else
Msgbox error
return



Can you please write all of the script I need? Do I need to download dlls or something? I will be thankful if you can give me links to the functions and the dlls.


Also what am I supposed to do with the function?
Am I supposed to copy and paste that thing in front of my script and not worry about it?
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: How to do gdi pixel search with this color

24 Mar 2018, 03:08

If you are not familiar with using libraries like gdip i would stay with the ahk pixelsearch which is fast and easy to use.Only looking for a lot of pixels in one go or hidden window/offscreen would give an advantage to gdip.

Yesterday by coincidence ? the topic got discussed if you are still interested to spend some time learning how to use gdip you can take a look and try the example:

https://autohotkey.com/boards/viewtopic.php?f=5&t=46002


You need to download the libraries attached to MaxAstro's post and have them in the same directory as the code.But for simple pixelsearch is not an improvement over ahk standard pixelsearch function.
TheLegend27

Re: How to do gdi pixel search with this color

24 Mar 2018, 06:08

noname wrote:If you are not familiar with using libraries like gdip i would stay with the ahk pixelsearch which is fast and easy to use.Only looking for a lot of pixels in one go or hidden window/offscreen would give an advantage to gdip.

Yesterday by coincidence ? the topic got discussed if you are still interested to spend some time learning how to use gdip you can take a look and try the example:

https://autohotkey.com/boards/viewtopic.php?f=5&t=46002


You need to download the libraries attached to MaxAstro's post and have them in the same directory as the code.But for simple pixelsearch is not an improvement over ahk standard pixelsearch function.
Also do you know how to pixelsearch when the monitor is off? For something it doesn't work for me when monitor is off..
Guest

Re: How to do gdi pixel search with this color

24 Mar 2018, 06:28

noname wrote:If you are not familiar with using libraries like gdip i would stay with the ahk pixelsearch which is fast and easy to use.Only looking for a lot of pixels in one go or hidden window/offscreen would give an advantage to gdip.

Yesterday by coincidence ? the topic got discussed if you are still interested to spend some time learning how to use gdip you can take a look and try the example:

https://autohotkey.com/boards/viewtopic.php?f=5&t=46002


You need to download the libraries attached to MaxAstro's post and have them in the same directory as the code.But for simple pixelsearch is not an improvement over ahk standard pixelsearch function.
Also can ahk have virus?
TheLegend27

Re: How to do gdi pixel search with this color

24 Mar 2018, 07:41

noname wrote:If you are not familiar with using libraries like gdip i would stay with the ahk pixelsearch which is fast and easy to use.Only looking for a lot of pixels in one go or hidden window/offscreen would give an advantage to gdip.

Yesterday by coincidence ? the topic got discussed if you are still interested to spend some time learning how to use gdip you can take a look and try the example:

https://autohotkey.com/boards/viewtopic.php?f=5&t=46002


You need to download the libraries attached to MaxAstro's post and have them in the same directory as the code.But for simple pixelsearch is not an improvement over ahk standard pixelsearch function.
Ok I downloaded the two files and put it in the same folder as my own script.

Now what do I need to write in the script and how do I write it and what are the parameters can you help thanks.
User avatar
noname
Posts: 515
Joined: 19 Nov 2013, 09:15

Re: How to do gdi pixel search with this color

25 Mar 2018, 13:31

Because the bitmap is from the screen ,the coordinates are referenced to the screen.

Only for ahk 32bit version !

demo example:

Code: Select all

#include *i gdip_all.ahk

SetWorkingDir, %A_ScriptDir%
SetBatchLines, -1


If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}

;------------  demo window with colored point ---------------
    Gui,font,s28
    gui,add,text,c644E37,.
    gui,show, x50 y50 w100 h100 , demo
;------------  demo window  ---------------------------------

^p::
Coordmode, pixel
CoordMode, mouse

pBitmap:=Gdip_BitmapFromScreen("0|0|500|500")
Gdip_GetImageDimensions(pBitmap, w,h)

error:=Gdip_PixelSearch(pBitmap,0xff644E37,px,py)

If (Error < 0) {
Msgbox ERROR if %error%=-1 pixel not found
Gdip_DisposeImage(pBitmap)
return
}

MouseMove, %px%, %py%,

Gdip_DisposeImage(pBitmap)
return



guiclose:
esc::
Gdip_Shutdown(pToken)
ExitApp


Gdip_PixelSearch(pBitmap, ARGB, ByRef x, ByRef y)
{
	static _PixelSearch
	if !_PixelSearch
	{
		MCode_PixelSearch := "8B44241099535583E2035603C233F6C1F80239742418577E388B7C24148B6C24248B5424188D1C85000000008D64240033C085"
		. "D27E108BCF3929743183C00183C1043BC27CF283C60103FB3B74241C7CDF8B4424288B4C242C5F5EC700FFFFFFFF5DC701FFFFFFFF83C8FF5BC38B4C2"
		. "4288B54242C5F890189325E5D33C05BC3"

		VarSetCapacity(_PixelSearch, StrLen(MCode_PixelSearch)//2)
		Loop % StrLen(MCode_PixelSearch)//2      ;%
			NumPut("0x" SubStr(MCode_PixelSearch, (2*A_Index)-1, 2), _PixelSearch, A_Index-1, "char")
	}
	Gdip_GetImageDimensions(pBitmap, Width, Height)
	if !(Width && Height)
		return -1

	if (E1 := Gdip_LockBits(pBitmap, 0, 0, Width, Height, Stride1, Scan01, BitmapData1))
		return -2

	x := y := 0
	E := DllCall(&_PixelSearch, "uint", Scan01, "int", Width, "int", Height, "int", Stride1, "uint", ARGB, "int*", x, "int*", y)
	Gdip_UnlockBits(pBitmap, BitmapData1)
	return (E = "") ? -3 : E
}








Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333 and 177 guests