Run PixelGetColor only in specific window Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nikaz
Posts: 9
Joined: 21 Jan 2017, 12:30

Run PixelGetColor only in specific window

14 Dec 2017, 09:02

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?
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Run PixelGetColor only in specific window  Topic is solved

14 Dec 2017, 09:10

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.
Nikaz
Posts: 9
Joined: 21 Jan 2017, 12:30

Re: Run PixelGetColor only in specific window

14 Dec 2017, 09:19

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!
User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: Run PixelGetColor only in specific window

14 Dec 2017, 09:26

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.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Spawnova and 268 guests