My main script was intended to check if a page was loaded and if so to start the script. Instead of doing things manually or putting a Sleep timer that could be inaccurate or too time-consuming.
I am using pixelgetcolor to check if a specific pixel on the screen has changed color.
For example, if my script needed the Google page to be loaded before inputting a script I would run something like this.
Code: Select all
!z::
;Is Google Page Loaded
loop
{
sleep, 500
PixelGetColor, pColor, 852,366, RGB
If (pColor = "0x4285F4")
{
msgbox, I found it %pcolor%
break
}
}
;The following is an example of what the next script could be ;)
send, Los Parkinson Aromas del ayer{enter}
return
Everybody's application will be different. so you'll have to source the pixel location and the color.
The first is fairly easy, you need window Spy (Right-click on your active AHK script in the desktop bar)
Click on the window you are looking at (so it's active)
Go to the pixel you want to select by putting your mouse over
Write down the window value.
Next, we should run a script that tests the color in that pixel. Even better here's one that tests both location and color
Code: Select all
!q::
;Testing page
msgbox, start
mousemove, 852, 366
PixelGetColor, pColor, 852,366, RGB
Msgbox, Pixel color %pcolor%
return
Couple things to keep in mind:
1. Some buttons when the mouse is floating over them, will in fact change color. so you may not want' to use mouse move, or you may want to add extra mouse move away from the button
2. Remember that I am using RGB values, not sure why it wouldn't be but I was not able to run the script without the RGB value
3. It is possible to add a timer (tickount command), or so that if the page doesn't load, it exists, or closes the window, etc..
4. An easier way to calculate a timer would be to add a sleep into the loop, let's say 1000 (1 second) and chose the number of loops. ie Loop, 30. Which would mean the script would be looking for the page for 30 seconds then break automatically.
5. If the script is running it will always bee looking for that pixel, and it won't stop until it does, because it's on an infinite loop.
Hope that helps someobody. Shoot me questions if you have them.