Jump to content

Help with mouse click command


Recommended Posts

ok i am rather new to Autoit, i have looked over the help section but i cant put my finger on why my script isnt working the way i need it to. A little help to set me in the right direction would be much appreciated.

What I am trying to do is tell my mouse to move to position 860, 615 and left click. but only if a mouse cursor exist. If the mouse cursor does not exist then hit the alt key until the cursor appears.

This is what I have come up with by reading the guides, but it isn't working as intended.

Global $Cursor = MouseGetCursor ()

While 1
Do
Sleep ( 1000 )
Until MouseGetCursor ( ) = 2
WEnd

If $Cursor = 2 Then
send("{ALTDOWN}")
sleep(100)
MouseClick("left",860,615,1,0)
sleep(100)
send("{ALTUP}")
sleep(1000)

This is for a utility program i am trying to test. I hope autoit will make it easier for me to click through it.

Edited by JeffCline
Link to comment
Share on other sites

Ok i am trying another attempt, but now i get the error that there is no While with my Wend...

So confused...

#RequireAdmin
; Press Esc to terminate script, Pause/Break to "pause"

Global $Cursor = MouseGetCursor ()
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

;;;;;

sleep(15000)
While 1
If $Cursor = 0 Then
    send("{ALT}")

Do
    Sleep ( 1000 )
Until MouseGetCursor ( ) = 2

If $Cursor = 2 Then
    MouseClick("left",860,615,1,0)
Wend

;;;;;;;;

Func TogglePause()
$Paused = NOT $Paused
while $Paused
sleep(100)
ToolTip('script is "Paused"',0,0)
Wend
TootTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc
Link to comment
Share on other sites

This code:

If $Cursor = 2 Then
    MouseClick("left",860,615,1,0)
Wend

Is missing an EndIf.

If you are using the full version of the Scite4Autoit3 download then you can press CTRL-F5 to check your code and it will tell you where the error is.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

ok i corrected the missing EndIf and some other errors now, thanks for the advice. I am still not getting the proper results

here is my current revised script

#RequireAdmin
; Press Esc to terminate script, Pause/Break to "pause"

Global $Cursor = MouseGetCursor ()
Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")

;;;;;

sleep(10000)
While 1
Do
Sleep ( 1000 )
Until MouseGetCursor () = 2

If MouseGetCursor () = 0 Then
send("{ALT}")
EndIf

If MouseGetCursor () = 2 Then
MouseClick("left",860,615,1,0)
EndIf
Wend

;;;;;;;;

Func TogglePause()
$Paused = NOT $Paused
while $Paused
sleep(100)
ToolTip('script is "Paused"',0,0)
Wend
TootTip("")
EndFunc

Func Terminate()
Exit 0
EndFunc

It works on windows desktop but not on my utility program's pop up window. Any ideas?

Link to comment
Share on other sites

  • Moderators

Hi, JeffCline, welcome to the forum. What is the utility you're trying to manipulate? MouseClicks are inherently buggy; there may be are undoubtedly much easier ways of interacting with the windows of your program.

"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

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...