Page 1 of 1

Run PixelGetColor only in specific window

Posted: 14 Dec 2017, 09:02
by Nikaz
Hello,

Im trying to setup the script that gets color and works only in specific window. What I want to do, is script running all the time, without hotkey, searching for pixelchange in certain window but I cant seem to get it right.
I came up with something like this:

Code: Select all

s::
If WinActive, Chrome {
PixelGetColor, color, 104, 926
	if (color="0x2D1AB1") {
    Send {F}
	} 
	else {
    Send {D}
	}
}
Else
Send {I}


Return
Esc::ExitApp
Even when the window active is Chrome it sends "I" instead of F or D. What is wrong with this script? can someone help me out?

Re: Run PixelGetColor only in specific window  Topic is solved

Posted: 14 Dec 2017, 09:10
by boiler
If WinActive, Chrome is not a command or a function call. You need either IfWinActive, Chrome (no space), or if WinActive("Chrome") (if with a function call).

You also need a loop to have it continue to check. You should also make sure you are using the proper CoordMode for your coordinates.

Btw, no need for braces around F, D, and I.

Re: Run PixelGetColor only in specific window

Posted: 14 Dec 2017, 09:19
by Nikaz
boiler wrote:If WinActive, Chrome is not a command or a function call. You need either IfWinActive, Chrome (no space), or if WinActive("Chrome") (if with a function call).

You also need a loop to have it continue to check. You should also make sure you are using the proper CoordMode for your coordinates.

Btw, no need for braces around F, D, and I.

Yeah yeah I know I need loop, keybind is only to test things out. I did this:

Code: Select all

s::
if WinActive("asd")
    Send {F}
	 
Else
    Send {D}
	

Return
Esc::ExitApp
asd - is the name of the folder. For example when I have opened chrome and press S it would type D, if I have the folder activated and press S while the searchbar is active it sends F. So all good. The problem comes when I try to change "asd" to game name, it sends D no matter if I have it active or not. Im running script as administrator and the game doesnt block it.


@Edit: Nevermind, figured it out, thanks man!

Re: Run PixelGetColor only in specific window

Posted: 14 Dec 2017, 09:26
by boiler
Edit: Ignore below since you got it working.

Are you sure you're getting the WinTitle for your game correct? Try having it display a MsgBox after the if statement instead of the Send just to verify you have the WinTitle correct. Use the WinSpy program to get the correct title.