Xzin,
What you are attempting will be possible as long as the keystroke target app does not require DirectInput (most don't).
AHK comes with Windows Spy. You will use this to attain various properties of the window you are trying to manipulate.
Start Windows Spy.
Load the application with the button you wish to press.
Mouse over the button on the area you wish to click. Refer to Windows Spy and take note of the "In Active Window" co-ordinates. Also take note of the Windows Title (you don't need the class). Activate the button and pay attention to Windows Spy to take note of the colour you wish to AVOID clicking on.
Windows Title will be referred to as [Windows Title]
Button Co-ordinates will be referred to as [co-ords] and will be in this format: X, Y
Colour to AVOID on button will be referred to as [AVOID]
Your script:
q::
{
curWin := WinExist("A")
WinActivate [Windows Title]
MouseMove, [co-ords], 0,
PixelGetColor, pixColour, [co-ords]
If (pixColour != [AVOID]) {
Click
}
WinActivate ahk_id %curWin%
}
Return
As usual, I don't have the capabilities to test this while at work. In summary, pressing q (you can change this q to whatever hotkey you like) will get your current window's ID and save it to curWin, then activate the window of which you supplied to title for (to manipulate), move the mouse to the desired co-ords, get the pixel colour beneath the mouse cursor, determine if this cursor colour is different from the one you want to avoid, and then click on that spot if it is NOT the avoid colour. It then reactivates the window you had active before you pressed the Hotkey.
Good Luck, if this is not what you are looking for, do elaborate.
Connect With Us