Page 1 of 1

My script works in IE, but not Edge

Posted: 06 Dec 2021, 05:57
by glassofwater
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?

Re: My script works in IE, but not Edge

Posted: 06 Dec 2021, 07:23
by mikeyww
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.

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

Posted: 06 Dec 2021, 07:48
by glassofwater
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. :)

Re: My script works in IE, but not Edge

Posted: 06 Dec 2021, 08:25
by mikeyww
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