Jump to content

Autoit MouseClick Problems


Recommended Posts

Hello, this is my first time using a forum so if I do something wrong or if my formatting is off then please forgive me. With that, I'm trying to make a script that automatically makes CCleaner "Run Cleaner." My script is basic I guess (Only have made a few scripts- I've just started using Autoit.) Because CCleaner can't be navigated through the TAB key, I am trying to use the mouse functions to move my mouse to x,y and then click. Every time I try a new way I get some form of error. Main one being: "

Line 26  (File "C:\Users\kille\Desktop\AutoIT Scripts\CCleaner Analyze and Run Cleaner .au3"):

MouseMove ( 1462, 761 [, speed = 10] )
MouseMove ( 1462, 761 ^ ERROR

Error: Subscript used on non-accessible variable."

How can I get my script to run CCleaner (Which I am able to do and that's about it) and then move the mouse to the Run Cleaner button and left click? Is there a way to select the button and say "go here, click here"?

 

Here's my script:

Send ("#r")

WinWaitActive ("Run")

Send ("CCleaner")

Send ("{ENTER}")

WinActive ("Piriform CCleaner")

Sleep (10000)

MouseMove ( 1462, 761 [, speed = 10] )

Sleep (1000)

MouseClick("left")

Sleep (10000)

WinClose ("Piriform CCleaner")

 

The Bold is where I believe my error to be. If it does click, it's like it does not wait and/or move.

I can't find an answer on any other forum/topic. Any help will be greatly appreciated!

Link to comment
Share on other sites

Your error: MouseMove ( 1462, 761 [, speed = 10] )  is that 3rd parameter: [, speed = 10]

Parameters expect a constant number, constant string, variable name, or nothing (you could put nothing there).

Numbers: 1, 1.1, -1  (no commas plz)

Strings are specified with any text encapsulated in quotes: "abc", ""

Strings can also be specified with single quotes: 'abc', ''

To have quotes as part of the string use the opposite quote type for encapsulation: "It's" ,  ' Shannon said, "Hey!" ' 

Variables are specified with this symbol: $ as in: $x and $y

The interpreter doesn't know what to do with: [, speed = 10]

 

Chapter 1: The "AutoIt Window Info" tool

AutoIt often comes with a, "AutoIt Window Info" program that can be used as a tool to report GUI control information.  The control information can be used to specify buttons to click without using the mouse.

Run your CCleaner thing, run the "AutoIt Window Info" tool.  Then on the "AutoIt Window Info" click the Finder Tool and drag to to CCleaner control you wish to click.

You can use the ID, Class and Instance, or Text  listed in "AutoIt Window Info" to specify the button to click without automating the mouse.

Have a look at ControlClick after you see if you can find your information with the "AutoIt Window Info", sometimes the tool doesn't report the control information.

Example of ControlClick:

ControlClick("CCleaner", "", $GUI_CONTROL_ID)

Where $GUI_CONTROL_ID is the ID returned by "AutoIt Window Info".

and "CCleaner" is the window title on your Cleaner app.  Idk what it's exact name is :)

 

Code that uses ControlClick() and ControlSend() is more reliable than automating the mouse without control information.  B/c if the wrong window becomes active or user interrupts it is more likely to break the expected flow of a script that relies on Send() and MouseClick() :)

Edited by Xandy
Link to comment
Share on other sites

You might be able to use a ShellExecute() the run your CCleaner too.

Something like this: ShellExecute($PATH_TO_CCLEANER)

If ShellExecute() doesn't work have a look at Run()

The more specific (without sending keys and automating mouse) your script is, the more reliable it will be. :)

Edited by Xandy
Link to comment
Share on other sites

@killergoose75

I think you need to post your code this way here when posting in forum.

56 minutes ago, Xandy said:

If ShellExecute() doesn't work have a look at Run()

I prefer to use the suggested response from @Xandy to use Run() instead of ShellExecute(). Sometimes ShellExecute() will prompt if to run your program or not, while Run() will run it with no prompting.

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

  • Moderators
7 hours ago, KickStarter15 said:

Sometimes ShellExecute() will prompt if to run your program or not, while Run() will run it with no prompting.

Can you give an example of when you see this, other than either the UAC or Windows not knowing how to open the file (both expected actions)? 

"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

16 hours ago, JLogan3o13 said:

Can you give an example of when you see this, other than either the UAC or Windows not knowing how to open the file (both expected actions)? 

@JLogan3o13, With respect sir, but as what I've noticed from both is that when the program was compiled to ".exe" ShellExecute() will prompted to run the called ".exe" file (tried it couple times testing however) but when trying to change the code with "Run()" there is no confirmation to run the program and somehow it will run once called.

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

Link to comment
Share on other sites

  • Moderators

@KickStarter15 merely asking for some reference where you have seen this, as I personally do not recall observing the behavior. Can you give an example of a program that exhibits this behavior?

"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

@JLogan3o13,

I have attached snippet of what I mean. This prompting issue is because of some security check if the program should be run from the server or not (I think this is basic security check for a certain company that involving application and software). If the .exe file was path in your local then ShellExecute() is running smoothly but if it involved server base, then there is confirmation prompted. Sorry I need to shade the path from that prompting, it's confidential.^_^

ShellExecute.png

But, if we use Run() from that code, then this confirmation will not prompt (Tested).:)

 

Edited by KickStarter15

Programming is "To make it so simple that there are obviously no deficiencies" or "To make it so complicated that there are no obvious deficiencies" by C.A.R. Hoare.

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