AndroidZero Posted November 9, 2013 Share Posted November 9, 2013 Hello, Small desscription what I want to do: Step1: I start my reg.au3. The au3 script must read a text document (code.txt) and save as a variable "$text = FileRead(@ScriptDir & "code.txt")" ------------------------------------------------------ Step2: Inside the "code.txt" is a command "Guictrlcreatebutton("Test",10,90,50,50)" for the au3 scriipt. The variable $text is now "Guictrlcreatebutton("Test",10,90,50,50)" ------------------------------------------------------- Step3: Now I want that the variable starts inside my reg.au3 but how ? I tryed just write the variable in a line but doesn't works. Here is the script and the Text Document Please help expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <Debug.au3> #include <String.au3> #include <NetShare.au3> #include <Array.au3> #include <EditConstants.au3> #Include <Misc.au3> #include <array.au3> #include <GuiStatusBar.au3> #include <GuiButton.au3> #include <File.au3> #include <Array.au3> #include <Inet.au3> #include <GuiStatusBar.au3> #include <Timers.au3> #include <ProgressConstants.au3> #include <GuiMenu.au3> Opt("GUIOnEventMode",1) ;OnEvent Modus für GUIs' , die dem User als Tool dienen. Opt("TrayIconHide", 0) ;0 Zeigt TrayIcon des Programms, 1 versteck TrayIcon Opt("GUICloseOnESC",1) ;Schließt das Programm beim Drücken der ESC Taste ;~ Opt("SendCapslockMode", 0) ;******************SOLUTION MENÜ************************************* $main_gui = GUICreate("EDV",281, 300, 500,200) ;***************S T E U E R E L E M E N T E******** GUISetOnEvent($GUI_EVENT_CLOSE, "close_main_gui") $text = FileRead(@ScriptDir & "\code.txt") start > $text WinSetTrans($main_gui,"",220) GUISetBkColor(0xFFFFFF) GUISwitch($main_gui) GUISetState(@SW_SHOW) While 1 Sleep(0) WEnd Func close_main_gui() Exit EndFunc code.txt Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 9, 2013 Moderators Share Posted November 9, 2013 (edited) AndroidZero,You cannot do what you want directly. You will have to do one of 2 things:- 1. Create a new file and run it:; Define initial lines $sStart_Lines = '#include <GUIConstantsEx.au3>' & @CRLF & _ 'Opt("GUIOnEventMode", 1)' & @CRLF & _ '$main_gui = GUICreate("EDV", 281, 300, 500, 200)' & @CRLF & _ 'GUISetOnEvent($GUI_EVENT_CLOSE, "close_main_gui")' & @CRLF ; Read in new lines $sAdded_lines = FileRead(@ScriptDir & "\code.txt") & @CRLF ; Define ending lines $sEnding_Lines = 'WinSetTrans($main_gui, "", 220)' & @CRLF & _ 'GUISetBkColor(0xFFFFFF)' & @CRLF & _ 'GUISwitch($main_gui)' & @CRLF & _ 'GUISetState(@SW_SHOW)' & @CRLF & _ 'While 1' & @CRLF & _ @TAB & 'Sleep(10)' & @CRLF & _ 'WEnd' & @CRLF & _ 'Func close_main_gui()' & @CRLF & _ @TAB & 'Exit' & @CRLF & _ 'EndFunc ;==>close_main_gui' ; Create file to run Global $sRun_File = @ScriptDir & "\Runit.au3" If FileExists($sRun_File) Then FileDelete($sRun_File) EndIf FileWrite($sRun_File, $sStart_Lines & $sAdded_lines & $sEnding_Lines) ; And then run it Run('AutoIt3.exe /AutoIt3ExecuteScript "' & $sRun_File & '"')- 2. Write code to parse the line you read in and write the code directly:#include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) $main_gui = GUICreate("EDV", 281, 300, 500, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "close_main_gui") ; Read in new line $sAdded_lines = FileRead(@ScriptDir & "\code.txt") ; Parse the line $aSplit_1 = StringSplit($sAdded_lines, "(") ; Confirm type of command If $aSplit_1[1] = "GUICtrlCreateButton" Then ; Parse the parameters $aSplit_2 = StringSplit($aSplit_1[2], ",") ; Create the control GUICtrlCreateButton($aSplit_2[1], Number($aSplit_2[2]), Number($aSplit_2[3]), Number($aSplit_2[4]), Number($aSplit_2[5])) EndIf WinSetTrans($main_gui, "", 220) GUISetBkColor(0xFFFFFF) GUISwitch($main_gui) GUISetState(@SW_SHOW) While 1 Sleep(10) WEnd Func close_main_gui() Exit EndFuncI would strongly recommend using the first of those techniques as the parsing of commands will rapidly become a unmanageable task - imagine having to do it for each AutoIt command listed in the Help file! Please ask if anything is unclear. M23 Edited November 9, 2013 by Melba23 Typo AndroidZero 1 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted November 9, 2013 Share Posted November 9, 2013 Could it not be as simple as Execute? expandcollapse popup#include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <StructureConstants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <Debug.au3> #include <String.au3> #include <NetShare.au3> #include <Array.au3> #include <EditConstants.au3> #Include <Misc.au3> #include <array.au3> #include <GuiStatusBar.au3> #include <GuiButton.au3> #include <File.au3> #include <Array.au3> #include <Inet.au3> #include <GuiStatusBar.au3> #include <Timers.au3> #include <ProgressConstants.au3> #include <GuiMenu.au3> Opt("GUIOnEventMode",1) ;OnEvent Modus für GUIs' , die dem User als Tool dienen. Opt("TrayIconHide", 0) ;0 Zeigt TrayIcon des Programms, 1 versteck TrayIcon Opt("GUICloseOnESC",1) ;Schließt das Programm beim Drücken der ESC Taste ;~ Opt("SendCapslockMode", 0) ;******************SOLUTION MENÜ************************************* $main_gui = GUICreate("EDV",281, 300, 500,200) ;***************S T E U E R E L E M E N T E******** GUISetOnEvent($GUI_EVENT_CLOSE, "close_main_gui") ;$text = 'Guictrlcreatebutton("Test",10,90,50,50)' $text = FileRead(@ScriptDir & "\code.txt") Execute($text) WinSetTrans($main_gui,"",220) GUISetBkColor(0xFFFFFF) GUISwitch($main_gui) GUISetState(@SW_SHOW) While 1 Sleep(0) WEnd Func close_main_gui() Exit EndFunc AndroidZero 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted November 9, 2013 Moderators Share Posted November 9, 2013 JohnOne,It works for a single line with no dependencies, but I can see a few problems if that is not the case. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
JohnOne Posted November 9, 2013 Share Posted November 9, 2013 Of course, thanks for reminder M23. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
AndroidZero Posted November 9, 2013 Author Share Posted November 9, 2013 Thank you both ! I will test it first with "execute" because I don't really need to give the GuiCtrl commands a variable. My plan is that the user can open the reg.au3 with their own configurations. For example: -they start the "reg.au3". -a small gui opens with a combobox -the combobox read out a (hidden folder) inside the folder are text documents with scripts. -if he select for example the text document "code.txt" then a the small GUI closes and a new bigger GUI opens with the button "Test" Of corse the text documents will be much bigger The reason why I decided for text documents and not directly creating new au3.scrupts in a folder is because the users who will use this reg.au3 - if finished I will convert to exe - don't have autoit installed. Next step is creating an option maybe in a menubar which allows the user to create an own user-defined gui saved in a text document. It's is hard to explain so I will post soon my finished script. I'm sure that this is an usefull script if it is finished. See you Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now