Jump to content

NT Scripting -> AutoIT


ixxy
 Share

Recommended Posts

Hello there!

I've used AutoIT for simple automation in the past, never really got around to doing anything advanced. I've had previous experience with NT Scripting language (batch scripting) which involves most of the console commands like DIR, FIND, etc.

Is there an equivalent to these in AutoIT? I've read through the documentation but it didn't really help. Or is there a way I could use existing commands through Autoit, and have it work in a hybrid sort of way?

ex:

find /i "hello" < "C:\list.txt" >C:\setm.m3u

Would there be a way to include that line in the script? (Also, would it be possible to output those results to a GUI instead of a file?)

Thanks!

Link to comment
Share on other sites

  • Moderators

Run(@Comspec & ' /c find /i "hello" < "C:\list.txt" >C:\setm.m3u')

Could try that and see if it works.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Would there be a way to include that line in the script? (Also, would it be possible to output those results to a GUI instead of a file?)

Yes on both counts:

#include <file.au3>

Global $sSrc = "C:\List.txt"
Global $sDest = "C:\setm.m3u"
Global $sSearch = "hello"
Global $avLines, $sResults

If Not _FileReadToArray($sSrc, $avLines) Then
    MsgBox(16, "Error", "Error reading file: " & $sSrc)
    Exit
EndIf

For $n = 1 To $avLines[0]
    If StringInStr($avLines[$n], $sSearch) Then
        $sResults &= $n & ": " & $avLines[$n] & @CRLF
    EndIf
Next

MsgBox(64, "Debug: $sResults", $sResults)
$hDest = FileOpen($sDest, 2) ; 2 = Overwrite
If $hDest = -1 Then
    MsgBox(16, "Error", "Error writing file: " & $sDest)
    Exit
EndIf
FileWrite($hDest, $sResults)
FileClose($hDest)

I came to AutoIt myself because my .cmd NT shell scripts were getting way too complicated. Welcome to AutoIt!

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Run(@Comspec & ' /c find /i "hello" < "C:\list.txt" >C:\setm.m3u')

Could try that and see if it works.

Yep it seems to work just fine.

1. Anyway to hide the console window?

2. Or does AutoIT have text/file manipulation commands of its own?

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