Sign in to follow this  
Followers 0
tomashen

running a script out of a txt file

24 posts in this topic

hi forumers :D

as the title says i wana do that ..for example

this is example.txt

guicreate("example gui", 200, 200)
 
guisetstate()
 
while 1
wend

and the example.exe will run that example.txt as a script liked compiled script but the script will be in a txt file.

is this posible? if yes how? :S

and thnx


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites



Yes, look at /AutoIt3ExecuteScript in the Help file & Forum.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

thnx found it and worked very nice!


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

um i got problem ...

im using this comamnd to run a txt file with source code

Run(@AutoItExe & " /AutoIt3ExecuteScript " & "file.txt")

but i dont want to actualy run it.. i want to include the data from the text file so it will act as if its being runned from the text file


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

Look at #include in the help file.


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

Look at #include in the help file.

nope :/

i want something like #include but i dont want the text file to be inside exe i want the text to be just included into the exe when exe is opened and exe needs some data at certain lines


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

any helps lads?


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

Do not be so impatient - please wait 24hrs before bumping your own thread. :D

i want the text to be just included into the exe when exe is opened

I do not belive this is possible without running the file - as explained by guinness above.

exe needs some data at certain lines

But this is. You would need to read the file as the exe starts (FileRead or _FileReadToArray) and then parse the content when needed. :)

The example you gave in the original post is of the first type - you cannot "inject" code into the exe - you can only run it externally. However, if what you want is "data" to be acted UPon by the exe then you can easily do what I explained above. :rip:

Which is it you really want to do: :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

thnx for the reply and sry for bumping so early

but on the topic now

i want the kind of thing like with FileRead u know...

i tryed using "iniread" but that is only for .ini files

so i want to use txt file not ini :D

so u say if i do FileRead("example.txt") at the very begining of exe loading

then i what i do ?

maybe i do sumtin like :

for example now i wana have a progress bar in the gui but the progress bar code has to be in example.txt

so i write in the exe

FileReadLine("example.txt", 5)

and then what? :oops:


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

but the progress bar code has to be in example.txt

I have already explained - you cannot run code that is in an external file unless you do as guinness explained and use /AutoIt3ExecuteScript on a valid AutoIt script. :oops:

Why do you insist on sections of your code being external to the exe file? :D

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

if i use /AutoIt3ExecuteScript then i cant put variables or anything on txt file bcz that requires the "#include" files... ;/

i just wana put some of the code into txt file so that i can edit the gui on the go if i dont have the autoit on the pc :D

is there no way to do sumtin like #include does?

like #include "example.txt"

at certain points of lines ?


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

tomashen,

#include only works at compile time - it cannot work at run time. :D

so that i can edit the gui on the go if i dont have the autoit on the pc

Then you need to use /AutoIt3ExecuteScript and run an external script. Remember that the external file does not need to have a .au3 extension - you can use any extension you want (added because GEOSoft has just PM'd me!). :oops:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

hm would i be able to do something like

FileReadLine(Run(@AutoItExe & "/AutoIt3ExecuteScript" & "example.txt"), 1)

read and run first line out of the txt?

:D just go a hint of that

lol im sry for being pain in the ass heh but noobs can learn only from pros :oops: tell me im wrong.. ;D


Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

How about showing us exactly how you want the text file to be formatted, a working example of exactly what you would like in one as an example.

If you're thinking to do something like this:

guicreate("example gui", 200, 200)
guisetstate()
while 1
    Sleep(10)
wend

12
example of something in the text file

"some random text"

MsgBox(64, "Error", "Random error message")

If you're looking for something like that where you're mixing code and random text, then you're going to have to be able to figure out what's random text and what's code and how you're going run that random code.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

tomashen,

hm would i be able to do something like

NO! :D

Please try and understand - what you want is impossible. However, you can go some way towards your goal by using the information we have already given you - namely /AutoIt3ExecuteScript. :oops:

im sry for being pain in the ass

You have just used up your PIA points for next few years! :)

M23

P.S. And now I hand over to BrewManNH - and the very best of luck to him! :rip:


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

"use example.txt here to insert a "guicreate" line here"
<br><br><br>GUISetState(@SW_SHOW)<br><br>
While 1<br> 
Switch GUIGetMsg()<br>  
   Case $GUI_EVENT_CLOSE<br>      
ExitLoop<br>    
EndSwitch<br>
WEnd

i wana sumtin like this BrewManNH

but as Melba23 sayd its imposible then that sux :D

hm also as melba u sayd

FileRead("lala.txt")

at begining...

then how can i pick up some line from that file to insert into a line on exe upon execution of .exe ?

Edited by tomashen

Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

What about you try to:

- write normal English for starters.

- start reading about the Autoit3 language

- be clear about your intentions and first try some coding yourselfa?

I am sure your life will be easier in this forum.


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

#18 ·  Posted (edited)

im not english so... :D cant write any better english than this...

ive read autoit 2-3 years ago and today

and im trying all i can think of but i fail :oops:

hers what i just tryed lol

$LINE = FileRead("gui.txt")
 
Run(@AutoItExe & ' /AutoIt3ExecuteScript  ' & $LINE) ;here i want it to insert a one line from the gui.txt fle....
 
GUISetState(@SW_SHOW)
 
While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
        ExitLoop
    EndSwitch
WEnd

and here is what the gui.txt file has

guicreate("test", 200, 200)
Edited by tomashen

Proud of AutoIt Proud of MySelf :)

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Form4: AutoIt3.exe [/ErrorStdOut] /AutoIt3ExecuteLine "command line"

Execute one line of code.

To execute a single line of code, use the command:

Run(@AutoItExe & ' /AutoIt3ExecuteLine "MsgBox(0, ''Hello World!'', ''Hi!'')"')

From the help file.

Just be aware, you will only be able to run one line at a time, and they won't interact with each other, in other words, you can't run functions line by line or loops, it doesn't work that way.

Edited by BrewManNH

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

i saw this and tryed but maybe i used it wrong i duno... but dont work for me :///

any advice ? or example ?

heres how i use it

Run(@AutoItExe & ' /AutoIt3ExecuteLine ' & Fileread("gui.txt"))

and i get errors

like

Posted Image

this is what the file has

guicreate("test", 200, 200)

Proud of AutoIt Proud of MySelf :)

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