Jump to content

Need some help getting this to work


Recommended Posts

Hello there!

I am trying to use a mouse click command to click the "NO" button in a dialog box that pops up when a piece of software is launched. I know the coordinates of the "NO" button, but whenever I run the script I get this error message:

Capture.PNG.48297a7a717c93cf4687b09c6779bffc.PNG

 

What I'm trying to do is this: I'm deploying a computer to be used in a live stage environment with Ableton Live, where no user interaction can take place. Whenever the computer is shutdown (which can only be done via the power button), Ableton is closed abruptly and it is considered a "crash". When booting up the computer next time, a dialog box pops up asking if you want to restore the previous session. I cannot get around this dialog in any other way. So I tried to make something in autoIT to do it for me.

 

In my code, I have it set to launch the save file at startup, which works just fine. But then I get the above error when getting to the mouse click. If I can get this working, I have one more mouse click command I'd like to do, so I can start an audio track automatically after the program is started.

 

Quote

; Launch Ableton
ShellExecute("C:\Users\Midi\Desktop\test Project\test.als", "", @WorkingDir)

Sleep(9000)

Global $Var_1 = "Variable 1"

; Click NO in dialog box asking to restore last session
WinActive("Ableton Live 10 Suite")
MouseClick ($MOUSE_CLICK_LEFT [, 768, 474 [, clicks = 1 [, speed = 10]]] )

It doesn't look pretty, but I've been going through trial and error all night.

 

Thank you in advance.

Link to comment
Share on other sites

Lookup the MouseClick function in the help file.  Right below where the button constants are listed, it says that the constants are defined in AutoItConstants.au3.  If you look at the example near the bottom of the MouseClick function definition, you will see an example.  The first line of the MouseClick example includes the AutoItConstants.au3 file.  You need to add that line to your script. 

https://www.autoitscript.com/autoit3/docs/functions/MouseClick.htm

 

Link to comment
Share on other sites

24 minutes ago, TempestCatto said:

MouseClick ($MOUSE_CLICK_LEFT [, 768, 474 [, clicks = 1 [, speed = 10]]] )

Remove the brackets if you want to include these optional parameters.

That constant is defined in AutoItConstants.au3, so you'll need to #include that file at the beginning of your script.

You could also use WinWait to see if the dialog appears instead of blindly clicking.

Link to comment
Share on other sites

28 minutes ago, TheXman said:

Lookup the MouseClick function in the help file.  Right below where the button constants are listed, it says that the constants are defined in AutoItConstants.au3.  If you look at the example near the bottom of the MouseClick function definition, you will see an example.  The first line of the MouseClick example includes the AutoItConstants.au3 file.  You need to add that line to your script. 

https://www.autoitscript.com/autoit3/docs/functions/MouseClick.htm

 

 

27 minutes ago, Danp2 said:

Remove the brackets if you want to include these optional parameters.

That constant is defined in AutoItConstants.au3, so you'll need to #include that file at the beginning of your script.

You could also use WinWait to see if the dialog appears instead of blindly clicking.

 

EUREKA! It works! Thank you so much!

 

I also was able to add the click command to play a looping track when Ableton starts. Here's what whole thing looks like:

Quote

; Launch Ableton
ShellExecute("C:\Users\Midi\Desktop\test Project\test.als", "", @WorkingDir)

Sleep(3000)

#include <AutoItConstants.au3>

; Click NO in dialog box asking to restore last session
WinWait ("[CLASS:Ableton Live 10 Suite]", "", 5)
MouseClick ($MOUSE_CLICK_LEFT, 768, 474)

Sleep(3000)

; Click PLAY on LOOP track
#include <AutoItConstants.au3>

WinWait ("[CLASS:Ableton Live 10 Suite]", "", 6)
MouseClick ($MOUSE_CLICK_LEFT, 362, 110)

 

I hope I used the WinWait commands properly. It does all work. Again, thank you both!

Link to comment
Share on other sites

15 hours ago, Danp2 said:

-snip-

15 hours ago, TheXman said:

-snip

 

Can you guys help me with a new problem? I wanted to increase the speed of the cursor movement to instant. I followed the help file/website exactly, and I get this error:

Capture2.PNG.7305cd01108c40b5dc680a66c37f999b.PNG

 

Here's my code:

Quote

; Launch Ableton
ShellExecute("C:\Users\Midi\Desktop\test Project\test.als", "", @WorkingDir)

Sleep(3000)

#include <AutoItConstants.au3>

; Click NO in dialog box asking to restore last session
WinWait ("[CLASS:Ableton Live 10 Suite]", "", 5)
MouseClick ($MOUSE_CLICK_LEFT [, 768, 474 [, clicks = 1 [, speed = 0]]])

Sleep(3000)

; Click PLAY on LOOP track
#include <AutoItConstants.au3>

WinWait ("[CLASS:Ableton Live 10 Suite]", "", 6)
MouseClick ($MOUSE_CLICK_LEFT [, 362, 110 [, clicks = 1 [, speed = 0]]])

 

Thanks for your help!

 

Link to comment
Share on other sites

  • Developers

Have you actually read the answers you received before as you are making the same mistake again?

15 hours ago, Danp2 said:

Remove the brackets if you want to include these optional parameters.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

33 minutes ago, Jos said:

Have you actually read the answers you received before as you are making the same mistake again?

Jos

Well I removed the brackets as recommended. Why are they there on the help file/web page if there not supposed to be there at all?

I get a new error message now.

Capture3.PNG.fb5387971bd1f48c0def04de3d6daced.PNG

Link to comment
Share on other sites

19 minutes ago, TempestCatto said:

Why are they there on the help file/web page if there not supposed to be there at all?

Brackets ("[" & "]"), in function definitions, denote optional parameters.  When using an optional parameter, you do not include the brackets. 

Optional parameter definitions will usually show you the default value if you do not include it in your function.  So when you see "click=1", it means that if you do not include that parameter, it is assumed to be 1 click.  You do not actually use the parameter names in your function.

Look at the MouseClick examples in the help file.  As you will see, only the parameter values are used, not the brackets or the parameter names.

 

So for example, the last MouseClick function in your code would be:

MouseClick($MOUSE_CLICK_LEFT, 362, 110, 1, 0)

 

Edited by TheXman
Link to comment
Share on other sites

Also, you only need to #include any given file just once, preferably somewhere near the top of your script.

Link to comment
Share on other sites

17 minutes ago, TheXman said:

Brackets ("[" & "]"), in function definitions, denote optional parameters.  When using an optional parameter, you do not include the brackets. 

Optional parameter definitions will usually show you the default value if you do not include it in your function.  So when you see "click=1", it means that if you do not include that parameter, it is assumed to be 1 click.  You do not actually use the parameter names in your function.

Look at the MouseClick examples in the help file.  As you will see, only the parameter values are used, not the brackets or the parameter names.

 

So for example, the last MouseClick function in your code would be:

MouseClick($MOUSE_CLICK_LEFT, 362, 110, 1, 0)

 

It works! Thank you very much.

 

Here's what my code looks like now:

Quote

; Launch Ableton
ShellExecute("C:\Users\Midi\Desktop\test Project\test.als", "", @WorkingDir)

Sleep(3000)

#include <AutoItConstants.au3>

; Click NO in dialog box asking to restore last session
WinWait ("[CLASS:Ableton Live 10 Suite]", "", 5)
MouseClick ($MOUSE_CLICK_LEFT, 768, 474, 1, 0)

Sleep(3000)

; Click PLAY on LOOP track
#include <AutoItConstants.au3>

WinWait ("[CLASS:Ableton Live 10 Suite]", "", 6)
MouseClick ($MOUSE_CLICK_LEFT, 362, 110, 1, 0)

Thanks again!

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