mohan93 Posted September 1, 2014 Share Posted September 1, 2014 Hello Guys, I have not worked with creating Button in autoit. Though this is common one, please help me with this. Am trying to create an GUI, only with 10 button and the GUI title name on top. On clicking each button, VBS will be opened from a repository in a notepad. (e.g: Delete Folder, Stop Service etc some 15 to 20 scripts) How to acheive this. Please assist. Link to comment Share on other sites More sharing options...
mikell Posted September 1, 2014 Share Posted September 1, 2014 You want the buttons to run the vbs or to open them for editing ? Link to comment Share on other sites More sharing options...
mohan93 Posted September 1, 2014 Author Share Posted September 1, 2014 You want the buttons to run the vbs or to open them for editing ? I want buttons to open VBS in read mode only (not even for editing) - Because the idea is: all the scipt templates will be in one repository, for users to access the code which they want they can click on respective button, and view only the code. (sorry till now i have not worked with GUIs and Buttons) Cheers, Link to comment Share on other sites More sharing options...
mikell Posted September 1, 2014 Share Posted September 1, 2014 (edited) Pick the code for gui/buttons in the helpfile samples, and use this in the script main loop While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn_vbs1 Run('notepad.exe ".\folder\vbs1.vbs" ') ; here use the full or relative path of the vbs file EndSwitch WEnd Edited September 1, 2014 by mikell mohan93 1 Link to comment Share on other sites More sharing options...
Muzaiyan Posted September 1, 2014 Share Posted September 1, 2014 Use >Koda Form Designer to design a GUI and buttons I think ShellExecute() function can b used to execute VB scripts See GUIGetmsg() function to perform action on button clicking. Link to comment Share on other sites More sharing options...
mohan93 Posted September 2, 2014 Author Share Posted September 2, 2014 Pick the code for gui/buttons in the helpfile samples, and use this in the script main loop While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $btn_vbs1 Run('notepad.exe ".\folder\vbs1.vbs" ') ; here use the full or relative path of the vbs file EndSwitch WEnd Thanks for your post. I use the below script to try open the VBS file in Notepad. #include <GUIConstantsEx.au3> GUICreate("Script Template", 180, 600) $Install = GUICtrlCreateButton("Install.vbs", 15, 50, 150) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $Install Run('notepad.exe "C:tempInstall.vbs" ') I have new requirement now, instead of opening the VBS file directly in notepad.. i want to read the contents of the file and display it in Listview or watever which will be easy. am reading the file using _FileReadToArray but not able to write it to a listview.. tried using _GUICtrlListView_AddItem but am spoiling the scipt somewhere. #include <file.au3> Dim $aRecords If Not _FileReadToArray("C:tempSample.txt",$aRecords) Then MsgBox(4096,"Error", " Error reading log to Array error:" & @error) Exit EndIf Please assist how do i show this content in a Listview Link to comment Share on other sites More sharing options...
Muzaiyan Posted September 3, 2014 Share Posted September 3, 2014 you have an option to use Label or Edit control to show script try this piece of code: $control = GUICtrlCreateEdit("",10,10,200,200) $data = FileRead("Install.vbs") ; read whole file GUICtrlSetData($control,$data) taypatte 1 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