Sign in to follow this  
Followers 0
BALA

Executing commands from a text file

6 posts in this topic




#2 ·  Posted (edited)

yes

.....................

inside file..

RunNote

...............

Script

Call(FileReadLine($File, 1))

Func RunNote()

Run("Notepad.exe")

EndFunc

8)

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Valuater's example reads a text file. The text file has nothing in it but this:

RunNote

The script that he has reads that text file's first line which is RunNote and from there it then calls the function RunNote() that is located in the script. You could have it call any function in the script this way.

Another way you can do this is by using the /AutoIt3ExecuteScript method. Check out my External Excute UDF in my signature. It is a UDF that will allow a compiled script to execute other scripts that are in au3 or a3x format. This allows for a dynamic functionality, similar to dll files.

Edited by The Kandie Man

"So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire

Share this post


Link to post
Share on other sites

Another example:

script:

$read = IniRead("script.ini", "Section1", "1", "error")
If $read = "error" Then
    MsgBox(0, "ERROR", "An unknown error has occured.")
EndIf
$split = StringSplit($read, ",")
Select
    Case $split[0] = 0
        Call("MBox", 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 1
        Call($split[1], 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 2
        Call($split[1], 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 3
        Call($split[1], 0, "ERROR", "Undefined Parameters")
    Case $split[0] = 4
        Call($split[1], $split[2], $split[3], $split[4])
    Case $split[0] = 5
        Call($split[1], $split[2], $split[3], $split[4], $split[5])
EndSelect

Func MBox($flag, $title, $text, $timeout)
    MsgBox($flag, $title, $text, $timeout)
EndFunc

script.ini file:

[section1]

1 = MBox, 0, Testing My Function, Did it work right?, 3

Doesn't have to be .ini file, but i prefer to use .ini files in my scripting. Just another example to maybe help you understand.


- Dan [Website]

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
Sign in to follow this  
Followers 0