My script works in IE, but not Edge Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
glassofwater
Posts: 6
Joined: 19 May 2021, 07:32

My script works in IE, but not Edge

06 Dec 2021, 05:57

Hey there!

So basically I have a kinda-working script where
if coordinate on screen equals #CC0000
then trigger sendkey F8
if not then trigger sendkey F9

This is to start and stop recording in OBS once an area of the screen changes color.
Here's the script:

Code: Select all

loop										          ;keeps checking till it gets triggered the first time
	{
		PixelGetColor, Color, 407, 483, RGB			  ;gets the color at X, Y

		if (Color == 0xCC0000)					      
			{
			SetKeyDelay, 0, 10					      
			Send, {F8}
			}

		else if (Color == 0xFFFFFF)
			{
			SetKeyDelay, 0, 10					      
			Send, {F9}
			}

		else									      
			{
			sleep, 500						          ;sleeps for 0.5 second
			continue							      ;starts the loop again
			}
	}
										              
										              
return
Thing is, the script works fine with Edge, but not IE (this is work related, so a few old machines are running IE instead of Edge still). I've checked with a colorpicker software and the coordinates are correct, and the font color is the same (CC0000).

Any suggestions as to why this works with Edge but not IE?
User avatar
mikeyww
Posts: 27115
Joined: 09 Sep 2014, 18:38

Re: My script works in IE, but not Edge

06 Dec 2021, 07:23

Here is a way to debug your script.

Code: Select all

F3::
x := 407, y := 483
MouseMove, x, y
PixelGetColor, Color, x, y, RGB
MsgBox, 64, Color at (%x%`,%y%), %color%
WinGetActiveTitle, aTitle
MsgBox, 64, Active window, %aTitle%
Return
Send will send to the active window, whichever window it is.
glassofwater
Posts: 6
Joined: 19 May 2021, 07:32

Re: My script works in IE, but not Edge  Topic is solved

06 Dec 2021, 07:48

mikeyww wrote:
06 Dec 2021, 07:23
Here is a way to debug your script.

Code: Select all

F3::
x := 407, y := 483
MouseMove, x, y
PixelGetColor, Color, x, y, RGB
MsgBox, 64, Color at (%x%`,%y%), %color%
WinGetActiveTitle, aTitle
MsgBox, 64, Active window, %aTitle%
Return
Send will send to the active window, whichever window it is.
Thanks! Great idea to use a script to debug with.

Turns out when the mouse was supposed to jump to x=407, y=483, it actually jumped to x=399. Changing the x-coordinate in my script to be slightly more to the right (x=410) fixed it. :)
User avatar
mikeyww
Posts: 27115
Joined: 09 Sep 2014, 18:38

Re: My script works in IE, but not Edge

06 Dec 2021, 08:25

OK. The mouse jumped to the coordinates shown in the script, but those coordinates are relative to the entire active window. You might be seeing client coordinates with your utility.

Code: Select all

F3::
CoordMode, Mouse, Client ; Changes the point of reference
x := 407, y := 483
MouseMove, x, y
PixelGetColor, Color, x, y, RGB
MsgBox, 64, Color at CLIENT coordinates (%x%`,%y%), %color%
WinGetActiveTitle, aTitle
MsgBox, 64, Active window, %aTitle%
Return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 128 guests