MouseMoveRel

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

MouseMoveRel

Post by RNIB » Thu Apr 21, 2016 12:08 pm

I'm trying to navigate to the list of files in a File Open window. Normally I'd just do this by tabbing but the tab order changes depending on what you last opened in that window. A real pain!

The only way I can think of doing this is by having the mouse click within the list of files but the window isn't always in the same position as people tend to move it around the screen.

I can't work out how to use the MouseMoveRel command properly, how do I work out what the coordinates are within the specified window? Do I need to use the GetActiveWindow command first, if so how?

This is the relevant part of my code so far:

Code: Select all

SRT>ReverseFiles
Wait>1
Press Enter
Wait>2
SetFocus>Open Append
//GetActiveWindow>Open Append,nXPos,nYPos,,
MouseMoverel>154,299
Wait>1
LClick
//select in reverse order
Wait>1
Press End
Press Shift
Press Home
Release Shift
Wait>1
//load audio
Press Enter
WaitWindowOpen>Adobe Audition - Untitled*
End>ReverseFiles

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: MouseMoveRel

Post by JRL » Thu Apr 21, 2016 1:44 pm

RNIB wrote:how do I work out what the coordinates are within the specified window?
An easy way to get the mouse coordinates of a location of a window is to have both the window in question and the Macro Scheduler editor window open. The Macro Scheduler editor displays the mouse coordinates to the right of its menu icons. So if you move the "Open Append" window such that its upper left corner sits at about the zero,zero point on your monitor, you can then move the mouse to the location in the window you want to MouseMoveRel> to, and observe the mouse coordinates in the Macro Scheduler editor.

RNIB wrote:Do I need to use the GetActiveWindow command first, if so how?
What version of Macro Scheduler are you using? A nice function that was introduced in v14.1 is WaitWindowFocused>. You could add that to the script right after the SetFocus>Open Append line.

If you have an older version of Macro Scheduler you could use GetActiveWindow> in a loop to wait for the Open Append window to have focus. Something like:

Code: Select all

Label>TestForOpenAppend
SetFocus>Open Append
Wait>0.3
GetActiveWindow>vTitle,vWinX,vWinY
If>vTitle=Open Append
Else
  GoSub>TestForOpenAppend
EndIf

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: MouseMoveRel

Post by RNIB » Thu Apr 21, 2016 1:57 pm

Aha perfect, that worked perfectly.

Unfortunately I only have MS10 to work with.

Thanks a lot!

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: MouseMoveRel

Post by JRL » Thu Apr 21, 2016 2:19 pm

Happy to help.

Re-reading your post I'm wondering what you are trying to accomplish. Why would you want to click on the list of files then highlight all of them which is what it looks like you are doing? Are you opening all of the files at once? Perhaps appending all of the files?

In any case I wanted to point out that Macro Scheduler has a wonderful set of functions for working with files without the need to manipulate a frustrating "Open Append" GUI. From what I see you might be better off using GetFileList> then Execute> or RunProgram> for the acquired list of files.

Sometimes the GUI is necessary. Software authors don't always provide methods outside of their GUIs to accomplish what you need to accomplish. In my experience its usually worth examining the possibility. Your script will be much more robust and reliable if you do not have to rely on automating a GUI. Particularly a GUI that changes arbitrarily.

Just a thought.
Dick

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: MouseMoveRel

Post by RNIB » Thu Apr 21, 2016 2:30 pm

Interesting. I didn't know that functionality existed in MS and good to know for the future. Unfortunately, I think, in this instance I'm stuck with using the GUI which is a shame as this method would be a lot easier and cleaner.

What I need to do is to open a set of WAV files in a folder using the Open Append function in Adobe Audition. This function automatically joins all the files together into one new file and drops in metadata markers at the joins.

I've had a quick look at the RunProgram command and it doesn't seem to give any control over what function of the program is run, so I could launch Audition but that would, by default, just open all the files as individual files rather than using the Open Append function. Unless of course I've missed something which is entirely possible :wink:

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Re: MouseMoveRel

Post by Marcus Tettmar » Thu Apr 21, 2016 2:44 pm

CTRL-A is the standard Windows shortcut for "Select All". Have you tried that?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: MouseMoveRel

Post by RNIB » Thu Apr 21, 2016 2:49 pm

Marcus Tettmar wrote:CTRL-A is the standard Windows shortcut for "Select All". Have you tried that?
Yeah unfortunately there are two problems with that.

1. Focus isn't initially in the list of files but in the file name field.
2. For reasons that I don't understand but I've seen it in other programs too, if you select all files in order the first and last files swap places. So lets say you have 10 files called 1-10. If you select them all then in the resulting file they play in this order 10,2,3,4,5,6,7,8,9,1

Ahh just thought of something. If I used the GetFileList could I just paste that into the file name field, that would be a far more elegant way of doing things?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: MouseMoveRel

Post by JRL » Thu Apr 21, 2016 3:11 pm

I've had a quick look at the RunProgram command and it doesn't seem to give any control over what function of the program is run
The RunProgram function runs a program with whatever functionality the program allows in command line parameters. A quick Google search for "adobe audition command line options" shows that there are no command line parameters beyond simply opening a file. On the other hand your idea to paste a list of names into the open file field might work. Two things to pay attention to.

File order sounds like it's important so you might need to reorder the files rather than using them in the order that GetFileList> provides.

The Open Append field may need a specific file delimiter to function properly. Will be easy to make a list of file names with any delimiter you choose, might not be easy to discover what that delimiter should be.

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: MouseMoveRel

Post by RNIB » Thu Apr 21, 2016 3:56 pm

JRL wrote:
The Open Append field may need a specific file delimiter to function properly. Will be easy to make a list of file names with any delimiter you choose, might not be easy to discover what that delimiter should be.
Yeah that's what I'm finding. Audition wants the files presented as:

"file1.wav" "file2.wav" "file3.wav"

So I guess I could use a delimiter of " " (assuming multiple character delimiters are allowed) and then manually add the opening and closing " " but that's a bit messy. I think it would be better to separate the list based on a standard ; delimiter, add the " " and then give it a new variable but that's proving harder than I thought especially with keeping the correct file order.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: MouseMoveRel

Post by JRL » Thu Apr 21, 2016 4:01 pm

Try something like this:

Code: Select all

GetFileList>YourPath\*.wav,vList,;
Separate>vList,;,vFile

Let>space=" "
Let>vNewList=
Let>kk=0
Repeat>kk
  Add>kk,1
  Let>value=vFile_%kk%
  Concat>vNewList,"%value%"%space%
Until>kk=vFile_Count

PutClipBoard>vNewList

SetFocus>Open Append
//Do what you need to get the focus as discussed earlier

Press ctrl
Send>v
Release ctrl
Or even shorter, your first idea:

Code: Select all

GetFileList>YourPath\*.wav,vList,;

StringReplace>vList,;," ",vList
Let>vNewList="%vList%"

PutClipBoard>vNewList

SetFocus>Open Append
//Do what you need to get the focus as discussed earlier

Press ctrl
Send>v
Release ctrl

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: MouseMoveRel

Post by RNIB » Fri Apr 22, 2016 10:47 am

Thanks for this, very much appreciated.

I'm having difficulty getting either to work unfortunately. Neither are quite formatting the file names in they way Audition needs them but also both methods cause the file order to be wrong.

Audition wants the file list presented as (the file names will change every time but they should always have a numeric prefix to denote the order:

"001_Intro.WAV" "002_Coming Up.WAV" "003_Paul Hollywood.WAV" "004_talking about.WAV" "005_dont tell me i can't.WAV" "006_life today.WAV" "007_telling it like it is.WAV" "008_ask suzie.WAV"

The first script created a list that looked like this:

"F:\116 Woman 160418\Side 1\008_ask suzie.WAV"" ""F:\116 Woman 160418\Side 1\007_telling it like it is.WAV"" ""F:\116 Woman 160418\Side 1\006_life today.WAV"" ""F:\116 Woman 160418\Side 1\005_dont tell me i can't.WAV"" ""F:\116 Woman 160418\Side 1\004_talking about.WAV"" ""F:\116 Woman 160418\Side 1\003_Paul Hollywood.WAV"" ""F:\116 Woman 160418\Side 1\002_Coming Up.WAV"" ""F:\116 Woman 160418\Side 1\001_Intro.WAV"" "

There are four issues with this:

1. It includes the path to the file which I don't think Audition likes.
2. There are additional " " between each file
3. There is a trailing " " at the end
4. The files are in reverse order

The second script created a list that looked like this:

"F:\116 Woman 160418\Side 1\008_ask suzie.WAV" "F:\116 Woman 160418\Side 1\007_telling it like it is.WAV" "F:\116 Woman 160418\Side 1\006_life today.WAV" "F:\116 Woman 160418\Side 1\005_dont tell me i can't.WAV" "F:\116 Woman 160418\Side 1\004_talking about.WAV" "F:\116 Woman 160418\Side 1\003_Paul Hollywood.WAV" "F:\116 Woman 160418\Side 1\002_Coming Up.WAV" "F:\116 Woman 160418\Side 1\001_Intro.WAV"

This is better in that there is the correct use of " " but the order is still reversed and it includes the path.

Just for info, earlier in the macro the paths for up to 4 folders containing the WAV files to be imported are captured and stored as the following variables:
AF1
AF2
AF3
AF4

After the paths are captured, because there are many stages of the process that are run multiple times, I've broken each stage down into subroutines

So each GetFileList bit will replace part of the Import Files and Reverse Files subroutines.

This is the full code there are a couple of bits I'm still working on which I've not finished so will look wrong one being the GetCheckBox which I can't seem to get to work

Code: Select all

//Make Sure Caps Lock is off
CapsOff
//Ask if the magazine has multiple parts
Let>INPUT_BROWSE=0
Input>TotalParts,How Many Parts Does This Magazine Have?,2
IF>TotalParts=""
Exit>0
EndIF
//Can never be 1,3 or more than 4 parts.
IF>TotalParts=1
Exit>0
Endif
If>TotalParts=2
Let>INPUT_BROWSE=2
Input>AF1,Please select the folder containing the files for Part 1.,
IF>AF1=""
Exit>0
EndIf
Let>INPUT_BROWSE=2
Input>AF2,Please select the folder containing the files for Part 2.,
IF>AF2=""
Exit>0
EndIf
Else
Let>INPUT_BROWSE=2
Input>AF1,Please select the folder containing the files for Part 1.,
IF>AF1=""
Exit>0
EndIf
Let>INPUT_BROWSE=2
Input>AF2,Please select the folder containing the files for Part 2.,
IF>AF2=""
Exit>0
EndIf
Let>INPUT_BROWSE=2
Input>AF3,Please select the folder containing the files for Part 3.,
IF>AF3=""
Exit>0
EndIf
Let>INPUT_BROWSE=2
Input>AF4,Please select the folder containing the files for Part 4.,
IF>AF4=""
Exit>0
EndIf
EndIF
//Continue with rest of data gathering
Let>INPUT_BROWSE=0
Input>ProdNumber,Please Enter The Production Number?,150
If>ProdNumber=""
Exit>0
EndIF
Let>INPUT_BROWSE=0
Input>PubDate,Please Enter The Publication Date As YYMMDD?,
If>PubDate=""
Exit>0
EndIF
Let>INPUT_BROWSE=0
Input>ProducerName,Please Enter The Initials of The Audio Producer,
If>ProducerName=""
Exit>0
EndIF
Let>INPUT_BROWSE=2
Input>SaveDrive,Please Select Where You Want The File Saved,
If>SaveDrive=""
Exit>0
EndIF

//If there are two parts use subroutines
If>TotalParts=2
GoSub>Part1
GoSub>Part2
Else
GoSub>Part1
GoSub>Part2
GoSub>Part3
GoSub>Part4
EndIF

//PART 1 SUBROUTINE
SRT>Part1
Let>PartNo=1
//Make Sure Caps Lock is off
CapsOff
GoSub>ImportFiles
Send>%AF1%
GoSub>ReverseFiles
GoSub>OddSides
GoSub>SaveFile
End>Part1
//PART 2 SUBROUTINE
SRT>Part2
Let>PartNo=2
//Make Sure Caps Lock is off
CapsOff
GoSub>ImportFiles
Send>%AF2%
GoSub>ReverseFiles
GoSub>EvenSides
GoSub>SaveFile
End>Part2
//PART 3 SUBROUTINE
SRT>Part3
Let>PartNo=3
//Make Sure Caps Lock is off
CapsOff
GoSub>ImportFiles
Send>%AF3%
GoSub>ReverseFiles
GoSub>OddSides
GoSub>SaveFile
End>Part3
//PART 4 SUBROUTINE
SRT>Part4
Let>PartNo=4
//Make Sure Caps Lock is off
CapsOff
GoSub>ImportFiles
Send>%AF4%
GoSub>ReverseFiles
GoSub>EvenSides
GoSub>SaveFile
End>Part4
//IMPORT FILES SUBROUTINE
SRT>ImportFiles
SetFocus>Adobe Audition*
//Maximise the window
WindowAction>1,Adobe Audition*
Wait>1
//makes sure Audition is set to Edit view
Send>8
//Open Append
Press ALT
Send>f
Release ALT
Wait>1
Send>d
WaitWindowOpen>Open Append
Wait>2
//Set Files of type to All Supported Media
Press Alt
Send>t
Release Alt
Press Down
Press Home
Press Enter
//Locate to File Name Field
Press Alt
Send>n
Release Alt
Wait>1
END>ImportFiles
//REVERSE FILES SUBROUTINE
SRT>ReverseFiles
Wait>1
Press Enter
Wait>2
SetFocus>Open Append
Wait>1
//GetActiveWindow>Open Append,nXPos,nYPos,,
MouseMoverel>98,146
Wait>1
LClick
//select in reverse order
Wait>1
Press End
Press Shift
Press Home
Release Shift
Wait>1
//load audio
Press Enter
WaitWindowOpen>Adobe Audition - Untitled*
End>ReverseFiles
//ODD SIDES METADATA SUBROUTINE
SRT>OddSides
//Zoom out full horizontally
//This is the default hotkey for zoom out full horizontally in Audition
Send>\
//Zoom in two levels this is based on an expected side length of around 37mins which should then move the marker point back from the end by 13 frames
//This is the default hotkey in Audition for Zoom in horizontally
Send>=
Send>=
Wait>1
//Jump to end of file
Press End
Wait>1
//Backup slightly from the end to avoid the bug where Audition won't save CD Tracks
//MUST HAVE A HOTKEYs DEFINED IN AUDITION RR Start = Ctrl+Shift+R & RR Stop = Ctrl+Shift+x
Press Ctrl
Press Shift
send>r
Release shift
Release Ctrl
Wait>0.1
Press Ctrl
Press Shift
send>x
Release shift
Release Ctrl
//open marker list
Press Alt
Send>8
Release Alt
Wait>1
//Add Track Marker to end
Press F8
Wait>1
//Rename CD Marker
Press Tab*3
Wait>1
Send>CD Track 01
//Set Marker Type to Track
Press Tab*4
Press Down
Press Home
Press Down*2
Press Enter
Wait>1
//Add r to the description
Press Tab*7
Wait>1
Send>r
Press Enter
Wait>1
//delete first track
Press Tab
Press Home
Press Del
Wait>1
MouseMoveRel>430,119
LClick
Wait>1
//Go to the first marker
Press Home
//Add s to the description
Press Tab*7
Send>s
Press Enter
Wait>1
//Click in the marker window. Needed to ensure the marker window is closed properly and that the macro can continue safely.
MouseMoveRel>430,119
LClick
Wait>1
Press Alt
Send>8
Release ALT
End>OddSides
//EVEN SIDES METADATA SUBROUTINE
SRT>EvenSides
//Zoom out full horizontally
//This is the default hotkey for zoom out full horizontally in Audition
Send>\
//Zoom in two levels this is based on an expected side length of around 37mins which should then move the marker point back from the end by 13 frames
//This is the default hotkey in Audition for Zoom in horizontally
Send>=
Send>=
Wait>1
//Jump to end of file
Press End
Wait>1
//Backup slightly from the end to avoid the bug where Audition won't save CD Tracks
//MUST HAVE A HOTKEYs DEFINED IN AUDITION RR Start = Ctrl+Shift+R & RR Stop = Ctrl+Shift+x
Press Ctrl
Press Shift
send>r
Release shift
Release Ctrl
Wait>0.1
Press Ctrl
Press Shift
send>x
Release shift
Release Ctrl
//open marker list
Press Alt
Send>8
Release Alt
//Add Track Marker to end
Press F8
Wait>1
//Rename CD Marker
Press Tab*3
Wait>1
Send>CD Track 01
//Set marker Type to Track
Press Tab*4
Press Down
Press Home
Press Down*2
Press Enter
Wait>1
//Add r to the description
Press Tab*7
Send>r
Press Enter
Wait>1
//delete first track
Press Tab
Press Home
Press Del
Wait>1
MouseMoveRel>430,119
LClick
Wait>1
//Select 2nd from last marker
Press End
Press Up
//Add s to the description
Press Tab*7
Send>s
Press Enter
Wait>1
//Click in the marker window. Needed to ensure the window is closed properly and the macro can continue safely.
MouseMoveRel>430,119
LClick
Wait>1
Press Alt
Send>8
Release Alt
End>EvenSides
//SAVE FILE SUBROUTINE
SRT>SaveFile
//save the file
Press Ctrl
Press Shift
Send>s
Release Shift
Release Ctrl
WaitWindowOpen>Save As
//Check if save extra non-audio information check box is ticked
GetCheckBox>Save As,Save extra non-audio information,bChecked
If>bChecked=1
Goto>end
Else
SetCheckBox>Save As,Save extra non-audio information,TRUE
Label>end
//Set Save As Type to WAV
Press Alt
Send>t
Release Alt
Press Down
Press End
Press Up
Press Enter
Press Alt
Send>n
Release Alt
Wait>1
Send>%SaveDrive%\%ProdNumber%_%PubDate%_%ProducerName%_%PartNo%.wav
Wait>1
Press Enter
WaitWindowOpen>Adobe Audition - %ProdNumber%_%PubDate%_%ProducerName%_%PartNo%*
Wait>2
Press Alt
Send>fc
Press Enter
Release Alt
End>SaveFile



hagchr
Automation Wizard
Posts: 331
Joined: Mon Jul 05, 2010 7:53 am
Location: Stockholm, Sweden

Re: MouseMoveRel

Post by hagchr » Fri Apr 22, 2016 2:14 pm

Hi, I tried JRL's second version and it works well on my machine (Audition CC, with full file paths), I just added a small wait before pasting. If you want to sort the files according to your numeric prefix you can use something like the code below.
(It assumes you have consecutive prefixes like 001_ 002_ 003_ etc. if not it needs to be modified).

Another comment is that (at least in Audition CC) you can define custom shortcuts and eg use ctrl+something to directly start the command for open append.

Code: Select all

Let>tmp="F:\116 Woman 160418\Side 1\008_ask suzie.WAV" "F:\116 Woman 160418\Side 1\007_telling it like it is.WAV" "F:\116 Woman 160418\Side 1\006_life today.WAV" "F:\116 Woman 160418\Side 1\005_dont tell me i can't.WAV" "F:\116 Woman 160418\Side 1\004_talking about.WAV" "F:\116 Woman 160418\Side 1\003_Paul Hollywood.WAV" "F:\116 Woman 160418\Side 1\002_Coming Up.WAV" "F:\116 Woman 160418\Side 1\001_Intro.WAV"

//Get number of files into var nm
RegEx>"[^"]+",tmp,0,m,nm,0

//Loop through and pick file containing id 001_ 002_ 003_ .... and produce file  
Let>res=
Let>k=0
While>k<nm
    Add>k,1
    RegEx>"[^"]+0+?%k%(?=_).+?",tmp,0,m1,nm1,0
    Let>res=%res% %m1_1%
EndWhile
MDL>res
Last edited by hagchr on Fri Apr 22, 2016 2:17 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: MouseMoveRel

Post by JRL » Fri Apr 22, 2016 2:16 pm

Sorry about the extra quotes in the first method. Version 14 has a built in system variable for "Space". It occured to me at the last minute that version 10 does not have the "space" variable so I added the line Let>space=" ". Should have been Let>space={" "}. Without the braces it actually adds the quotes. With the braces and the quotes the variable "space" becomes a space.

GetFileList> provides files in reverse alpha sort. You can either take its provided list and resort it to suit your needs or you can do what I do and use DOS dir to create the list rather than using GetFileList>. The following replaces GetFileList and provides a CRLF delimited list of file names sorted alphanumerically. Change /on to /o-n the reverse the sort order.

Code: Select all

DeleteFile>%temp_Dir%RNIB_File_List.txt
Let>RP_Wait=1
Let>RP_Windowmode=0
//In DOS, Dir /on puts files in alphanumeric order,  /o-n reverses order
//the /b provides just the file name
Run>cmd /c dir "Yourpath\*.wav" /b /on > %temp_Dir%RNIB_File_List.txt
//GetFileList>%temp_dir%s*.txt,vList,;
ReadFile>%temp_Dir%RNIB_File_List.txt,vList
DeleteFile>%temp_Dir%RNIB_File_List.txt

RNIB
Macro Veteran
Posts: 195
Joined: Thu Jan 10, 2008 10:25 am
Location: London, UK

Re: MouseMoveRel

Post by RNIB » Fri Apr 22, 2016 3:21 pm

Thanks both for your replies. I shall be having a look at this in more detail on Monday. I'm also trying to get my boss to buy me MS14 as there are numerous improvements that would be of benefit.

Interesting and frustrating that Audition CC accepts paths in file names. Unfortunately we are having to use Audition 3.0 because it's free and as a charity we need to keep our costs to a minimum. Must admit I hadn't realised that Open Append was in Audition CC as I thought it had been removed in Audition CS5.5 and above.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts