Jump to content

ShellExecute many files, one at a time.


null0
 Share

Recommended Posts

Hello everyone,

I am woefully out of my depth but know that AUTOIT is my best chance at making this work.

I am in the process of trying to convert thousands of .wpa files to .doc. When you open .wpa it opens in it's own, special word processor which you can then click file - save as- save as .doc

After much trail/error/ and Google, I have been able to automate this processes, in not the most graceful way, but as you can see, only works for ONE file (a file named test.wpa). Code is below.

 

ShellExecute ("C:\convert\test.wpa")
Opt("WinTitleMatchMode", 2)
$winTitle ="Act! Word Processor"
winwait($wintitle)
sleep(50)
WinActivate($wintitle)
Send("{F10}{ENTER}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")
WinActivate("Save As")
Send("{TAB}{DOWN}{DOWN}{ENTER}{ENTER}")
Send("{F10}{ENTER}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")

The last Send command, cleanly closes out of Act! Word Processor, since you can't run multiple instances of it at once.

What I need to do is open each .wpa file in the shellexecute directory, one-at-a-time, have it run lines 2-9, then repeat but to the next file.
The filenames are all-over the place and do not follow any sort of pattern. Should I be looking at it open them one at a time by date modified?

What functions would you recommend I research in order to accomplish this?
 

Link to comment
Share on other sites

  • Moderators

@null0 if the files are all in one directory you can do something like this:

Opt("WinTitleMatchMode", 2)
#include <File.au3>

$aFiles = _FileListToArray("C:\Convert", "*.wpa", $FLTA_FILES, True)

    ;_ArrayDisplay($aFiles) - uncomment only if you would like to see what the array looks like
    
    
    For $file In $aFiles
       ShellExecute ($file)
       $winTitle ="Act! Word Processor"
       WinWait($wintitle)
       Sleep(50)
       WinActivate($wintitle)
       Send("{F10}{ENTER}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")
       WinActivate("Save As")
       Send("{TAB}{DOWN}{DOWN}{ENTER}{ENTER}")
       Send("{F10}{ENTER}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")
    Next

 

"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

Also, i think

Send("{F10}{ENTER}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{ENTER}")
;could be
Send("{F10}{ENTER}{DOWN 5}{ENTER}")

PS: maybe you can go up instead of down to exit?

Send("{F10}{ENTER}{UP}{ENTER}")

 

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

@JLogan3o13 Wow! Thank you! This has helped immensely. I can see the File Array which displays everything within the folder. 

The next issue I am having is when viewing the array, Row 0 has the number of total files in the folder, while rows 1 -2002 show all the files within the c:\convert folder. 

So while the script executes, it immediately stops because it says it cannot find file 2002. 

I attempted to modify the $iFlag to $FLTA_FILES (1) since  that should return files only, but I get the same result. 

Is there a way to exclude row 0 in the filter?

Link to comment
Share on other sites

  • Moderators

You can change the For Loop to this:

For $a = 1 to $aFiles[0]
       ShellExecute ($aFiles[$a])
       ...

 

"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 That did the trick! Thank you again! :)

I was going in the completely wrong direction with this. I was too busy messing with the _ArrayDisplay function. I ended up modifying the lint to:

_ArrayDisplay($aFiles, "Files to Convert", "1:2002") which showed me what I wanted, but still attempted to run row 0. 

 

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