3

Like this question: Automate GUI tasks?

I'm asking for a way to automate GUI tasks. I understand that those 2 apps are what's used for that sort of stuff, but those 2 apps are hard to use.

OK, here's my script attempt using autoscript writer II:

I first open up the app, then open a file using the app. I believe this part is opening the file and then double clicking on it:

Clicking the open button

MouseClick, left,  63,  100
Sleep, 100
WinWait, Open, 
IfWinNotActive, Open, , WinActivate, Open, 
WinWaitActive, Open, 

Double clicking to select file:

MouseClick, left,  144,  111
MouseClick, left,  144,  111

I need for the above portion of the script to select the next file for each iteration.

Then it does stuff in the app:

WinWait, App Unicode, 
IfWinNotActive, App Unicode, , WinActivate, App Unicode, 
WinWaitActive, App Unicode, 
MouseClick, left,  304,  459
Sleep, 100
MouseClick, left,  405,  467
Sleep, 100
MouseClick, left,  219,  133
Sleep, 100

And then saves it:

WinWait, Save As, 
IfWinNotActive, Save As, , WinActivate, Save As, 
WinWaitActive, Save As, 
MouseClick, left,  527,  366
Sleep, 100

The app open window goes directly to a folder with all my files in it. I just need to open up each file in turn with autohotkey.

Thanks!

3 Answers 3

2

Without knowing exactly what you're doing, I can't write any sort of script for it, but assuming it's an explorer window, you could use a loop:

Loop %RepeatCount% {
    ...
}

and use some maths to work out when to go down a row, so on.

Better than that, though, see the "Loop (files & folders)" section of the readme. Looks like you'd make the .ahk inside the directory, then do something like

Loop *.fileWhatIsBoringToManipulate
{
Run p:\ath\to\executable [command line option to load file]
WinWaitActive, Manipulator
//mouseclicks and stuff
}

The latter would be vastly superior, but if your application doesn't support command line input, then you'd be better off putting the files in list view and using a send {down}{return} instead of fancy positional mousing.

6
  • thanks a lot for your help. About the using math to work out when to go down a row, :( esp since the window would need to be scrolled too.
    – Ben
    Oct 1, 2009 at 20:55
  • About the second option, I don't understand what to put here: Run p:\ath\to\executable [command line option to load file] The app is a GUI app, I don't think setting the exe would work.
    – Ben
    Oct 1, 2009 at 20:56
  • About doing send down return, can you give an example? How do you select the previous file so that the next file is selected after down?
    – Ben
    Oct 1, 2009 at 20:57
  • 1)Yep, nasty stuff :( 2)Most GUI apps also support command line stuffs, like to open c:\html.html in firefox, you could do "firefox c:\html.html" - it would simply make the opening process much cleaner. 3)Sending down would mean you'd fire off the script with the explorer window open, and give it focus once the automation was done for one file. That'd move down one file (in list view, the next file) and launch it. Next iteration, it'd go to the next file, so on.
    – Phoshi
    Oct 1, 2009 at 21:00
  • This is too hard for me. I think I give up :)
    – Ben
    Oct 1, 2009 at 21:18
1

If the problem you are having is trying to select the next file, perhaps it would be simpler to always select the first file in the list, operate on it, then move it to a different folder. Then the first file in the folder would be what was the second file previously.

1

Just a thought but after opening the dialog, use some math to figure out how many times to hit the down key or something to select the next file (instead of using mouse clicks). This way at least the scrolling will be sorted out automatically. Except for that and the obvious command line argument option, I'm with eleven81 on actually moving the file after being done with it so the next file is at the same place as the first one...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .