I am working on a script that will run on a variety of computers with different sized monitors. When making scripts I try to avoid using mouse clicks like the plague and do keyboard shortcuts instead, unfortunately, this button has no keyboard shortcut. Is there a best practice for clicking buttons?
- Using "MouseClick, left, 1010, 320" works fine on my computer assuming the window is maximized but as soon as it runs on someone else's computer with a different resolution, the mouse click misses the button.
-I've looked into the "PixelSearch, Px, Py, 650, 300, 880, 335, 0099FF, 0, Fast" command, to find the color of the button and click it. Is this the best solution and just try to set the search area to be large enough to find the button on different sized monitors?
-Are there functions to detect the size of the active window? If so, it seems like you could use Mouse Click 20% Max X Pixels, 10% Max Y Pixel. Would this relative positioning work? Is this what people are doing?
-Should I just set a variable at the top of the script and when I put the script on other computers just specify the location of the button? Seems very manual and not cool, but might be the most stable?
Thanks for any advice,
Thanks,
Andrew V. Romero
Clicking Buttons Topic is solved
Re: Clicking Buttons
Hi,
Can you maybe reach that button by pressing the Tab key (several times)?
That would be the first thing I would try to do.
Can you maybe reach that button by pressing the Tab key (several times)?
That would be the first thing I would try to do.
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Re: Clicking Buttons
Could this help?
Code: Select all
Gui,Add, Button, x33 y45 vBut1 gBut,I will be clicked in a second
Gui,Show, h100 w400, Prova
Gui_ID := WinExist("A")
gosub FindButton
return
FindButton:
ControlGetPos, x,y,w,h, Button1, ahk_id %Gui_ID%
sleep,1000
MouseClick, Left, x+w/2 , y+h/2
return
But:
MsgBox Clicked !!!!
return
____________________________________________________________________________
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Windows 10 Pro 64 bit - Autohotkey v1.1.30.01 64-bit Unicode
Re: Clicking Buttons
Scr1pter- I have tried all sort of variations of tab, alt-tab, alt buttons, function buttons, etc. Nothing seems to grant focus to the button in this application.
Odlanir- I didn't know you could use this type of logic with non-AHK functions. ControlGetPos is something I will have to investigate more although in running the documentation example for ControlGetPos, it isn't identifying any coordinates or buttons. Could this be because the application is a Citrix application?
-Andrew
Odlanir- I didn't know you could use this type of logic with non-AHK functions. ControlGetPos is something I will have to investigate more although in running the documentation example for ControlGetPos, it isn't identifying any coordinates or buttons. Could this be because the application is a Citrix application?
Code: Select all
Loop
{
Sleep, 100
MouseGetPos, , , WhichWindow, WhichControl
ControlGetPos, x, y, w, h, %WhichControl%, ahk_id %WhichWindow%
ToolTip, %WhichControl%`nX%X%`tY%Y%`nW%W%`t%H%
}
Re: Clicking Buttons Topic is solved
With Citrix you'll have no luck with Odlanir's solution. You can either try PixelSearch or ImageSearch
Re: Clicking Buttons
Thanks, I was suspecting Citrix might be causing the issue. I do look forward to trying ControlGetPos on other scripts.
Who is online
Users browsing this forum: Bing [Bot], Descolada and 176 guests