Eng

Why so complicated? Typical batch: Open, send keys, end, again

6 posts in this topic

#1 ·  Posted

Hi dear community,

Before starting this topic, I've searched on manuals, examples and forums but I couldn't find. In my opinion this should be a fundamental request. For my part all newbies are curious about this.

Batch processes are big deal. Could you explain simply by giving an example? How can we do the following loop:

  1. List files on specific directory (maybe by extension, for example *.txt)
  2. Take the first file, open it with an external application.
  3. Send keystrokes or anything... on the external application.
  4. End the process of the external application.
  5. Take the 2nd file, and open...

I really appreciate any help you can provide.

Share this post


Link to post
Share on other sites



#2 ·  Posted

Open the Helpfile and search for:

  1. FileFindFirstFile / FileFindNextFile /  _FileListToArray
  2. Run / ShellExecute
  3. Send() / ControlSend()
  4. ProcessClose()
  5. For ... Next

Can't be that hard ;)

Jos

2 people like this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thanks for replying, sir. Do not be annoyed with me. Without an example I do not understand. So I tried changing the example in the help file. The end part is wrong, of course. :sweating:

#include <MsgBoxConstants.au3>

Example()

Func Example()
    Local $hSearch = FileFindFirstFile("*.txt")

    ; Check if the search was successful, if not display a message and return False.
    If $hSearch = -1 Then
        MsgBox($MB_SYSTEMMODAL, "", "Error: No files/directories matched the search pattern.")
        Return False
    EndIf

    ; Assign a Local variable the empty string which will contain the files names found.
    Local $sFileName = "", $iResult = 0

    While 1
        $sFileName = FileFindNextFile($hSearch)
        ; If there is no more file matching the search.
        If @error Then ExitLoop

        ; Do it
        ShellExecute ($sFileName)
        Sleep(2000)
        Send("^k")
        Sleep(1000)
        Send("{ENTER}")
        Sleep(1000)
        Send("{ENTER}")
        Send("!{F4}")
        Sleep(2000)
        ExitLoop;
    WEnd

    ; Close the search handle.
    FileClose($hSearch)
EndFunc   ;==>Example

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

I assume it only does one file?  That last ExitLoop looks wrong and should be removed.
Else describe if you still have a question or not. ;) 

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted

Wow thank you! It works. By the way your brain works like a compiler.

I feel very stupid myself. Why am I trying so hard to understand the commands?

Best regards.

Share this post


Link to post
Share on other sites

#6 ·  Posted

21 minutes ago, Eng said:

Wow thank you! It works. By the way your brain works like a compiler.

They didn't tell you on your way in?  ...  I am a robot. ;)

2 people like this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
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