Jump to content

Pause script until Audio and Mouse Moves are Executed


Recommended Posts

Hello All,

  I am about 3 weeks new to AutoIT, so let me just say thank you to anyone who may provide help on this topic. My coding skills are dated as I haven't coded since 2001 in college, learning VB, C and Fortran. So please forgive me if there is an easily accessible reference for this type of question.

  I am attempting to play an audio file and perform mouse moves at the same time. I want the script to wait for both the audio clip and the mouse moves to complete, before moving on to the next audio clip and mouse moves. Here is the code I currently have that only waits for audio clip to finish before moving to next line of the autoIT script.

SoundPlay("C:\Audio\HelloWorld.mp3",1)
MouseMove(386,547,50)
MouseDown("left")
MouseMove(385,547,50)
MouseUp("left")
MouseClick("left",388,559,1,50)
MouseMove(386,549,50)
MouseDown("left")
MouseMove(634,553,50)
MouseUp("left")

I need the script to hold here until both audio and mouse moves have executed, then move on to the next step.

SoundPlay("C:\Audio\YouAreHere.mp3",1)
MouseClick("left",124,44,1,50)

 

Any help is much appreciated. Thank you.

 

Link to comment
Share on other sites

I believe SoundPlay is internally asynchronous so there is no indication as to when the sound finishes, MouseMove is synchronous so that's fine.

Remarks on soundplay mention an open handle though, so It might actually be possible to monitor that handle somehow, but unfortunately I'm unaware how at this time.

You might try playing the file via some other method such as using bass.dll udf. to achieve your goal.

EDIT:

Another possibility is to get some metadata (length) of that file and wait until that time has passed.

Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

I thought this might also have worked, but alas, it does not.

$iPID = Run(@AutoItExe & ' /AutoIt3ExecuteLine "SoundPlay(''C:\Windows\media\tada.wav'')"')

While ProcessExists($iPID)
    Sleep(50)
WEnd

 

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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