Jump to content

Moving button to click


Eikoo
 Share

Recommended Posts

Hello I'm not really a programer I'm just trying to make life easier for my small company employees.

 

I have everything working except where this dialog box gets resized and the button moves. This box is just an error that has no meaning and I want the mouse to move to the close button and then click it.

I'm trying to create a script where it will universally click the correct spot.  The only constants I see are 250 pixels from the left side and 105 from the bottom. 

 

This is what i have when the box in its smallest size but it pops up often sometimes the user is doing something and resizes it.

Local $aPos = WinGetPos("[ACTIVE]")
Opt("MouseCoordMode",0)
MouseMove(194, 497, 1)
MouseClick("left")
Link to comment
Share on other sites

  • Moderators

Is this a dialog box you are creating in a GUI, InputBox, etc., or is it a pop up in a 3rd party app? Either way, the conventional method would be to use the AutoIt Window Info tool, in the same directory where you installed AutoIt, and get the Control name or ID of the button. Then look at ControlClick in the help file. That way, no matter where the box is you can click on it. MouseMoves and MouseClicks you will quickly find are unreliable.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

AdlibRegister("getPos")
HotKeySet("{END}", "clickMe")

Local $aPos

getPos()

While 1
WEnd

Func getPos()
    $aPos = WinGetPos("[ACTIVE]")
EndFunc   ;==>getPos

Func clickMe()
    MouseClick("left", $aPos[0] + 194, $aPos[1] + 497, 1)
EndFunc

EDIT: hitting the end key above the arrow keys will initiate the mouseclick on your control. I'm not sure I got the coordinates correct, but the

$aPos[0] ; is the x value

and the

$aPos[1] ; is the y value

hopefully that will help you on your course to a solution. Also the

AdLibRegister("getPos") ; runs this every 250 ms -- essentially getting the active window coordinates every 250 ms
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

Can you activate the window of the dialog box with WinActivate? If so, even ControlSending an Enter would be more reliable than a MouseClick.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@Eikoo JLogan's solution might be the best for your situation.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

You stated there was a button you need to click to close the dialog box. It is somewhat difficult to troubleshoot when we're left in the dark as to what you are seeing. How about posting a screenshot of the dialog box, so we can see what is required to get rid of it?

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@Eikoo yes, that is correct. So to make sure you have the correct x and y coordinates.

just add to the x value from the left to the right *------^-----

$aPos[0] + ; the value to move the x value

 

just add to the y value from up to down *

                                                              |

                                                              |

                                                              |

                                                              *

                                                              |

                                                              |

$aPos[1] + ; the value to move the y value

 

essentially like you are plotting a point on a graph.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

ok I was looking at it again and the from the top value x can vary(cause of window resizes) but it I was measuring it from the bottom then it would be 44 pixels(all the time)

From the left the y value It would be 250 pixels all the time. 

 

I guess I want to know if I can specify how far from the bottom the button is. 

Link to comment
Share on other sites

I'm not sure you have the x and y right. x on a graph the the bottom line; essentially the top line of the window. the y is the up and down line on a graph; essentially where you want it to click from the top to bottom.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

So this then? Sorry I don't really program the most experience I have doing something like this is excel tables... And poking around the help files and using google. I don't understand most of what I read. 

AdlibRegister("getPos")
HotKeySet("{END}", "clickMe")
Local $aPos
Func getPos()
    $aPos = WinGetPos("[ACTIVE]")
EndFunc   ;==>getPos
Func clickMe()
    MouseClick("left", $aPos[0] + 250, $aPos[3] + , 44)
EndFunc
Sleep( 8000 )
Edited by Eikoo
Link to comment
Share on other sites

Hmm maybe this will help you help me.  : /   I got these values from paint...

 

250

-----------(Acknowledge)

                   |44

 

@MikahS Tried that code from above and still didn't seem to move the mouse and click the right spot. 

I can't use the value from the top cause it will vary when the user resizes the window. 

Edited by Eikoo
Link to comment
Share on other sites

This will take the x coordinate and move 250 to the right; then get the height (our y) and go up 44 <-- that was wrong :( . Then click 1 time.

AdlibRegister("getPos")
HotKeySet("{END}", "clickMe")

Local $aPos

getPos()

While 1
WEnd

Func getPos()
    $aPos = WinGetPos("[ACTIVE]")
EndFunc   ;==>getPos

Func clickMe()
    MouseClick("left", $aPos[0] + 250, $aPos[3] - 44, 1)
EndFunc   ;==>clickMe
Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Use a dynamic x and y then. Get the value of the x and y from the window, then figure out everytime they resize the window how much of a difference is needed; so everytime you get the window x and y check if they are the same; if they are not, put them in a variable that will not be changing, such as $xOLD and then find the actual x value of the button by subtracting the new x by the old x or if it is the opposite add the old x value. This can be done in the getPos function using conditionals.

Edited by MikahS

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Also, this could be alleviated with telling us what kind of window you are using, whether it is an IE window, Firefox window, or one that you have created. It could make it much simpler.

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

  • Moderators

Also, this could be alleviated with telling us what kind of window you are using, whether it is an IE window, Firefox window, or one that you have created. It could make it much simpler.

 

Hmmm....sounds familiar ;)

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hmmm....sounds familiar ;)

At this point JLogan is correct in saying multiple times that without knowing what the window is, we are completely in the dark, and as a result could not be giving you the correct answers. :(

Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...