InjkttxD Posted October 7, 2010 Share Posted October 7, 2010 Hey guys, i've just finished my scripts and i wanna link them all together using the GUI i've made. Basically everything is set except for the fact that i need to add the scripts too it. I have two check boxes, and i want it so that if i check one box, on the script associated with the check box runs when i hit the GO button on my gui and vice versa. Also, Because there's two buttons, one to run the scripts and one to open the exe of the installer i want to script how do i do that? So in short, i need to know; how to link scripts to check boxes. How to run the selected scripts (selected by which check box is ticked) with the Run! Button And How to link the exe file to my go! button. Thanks guys, Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 7, 2010 Moderators Share Posted October 7, 2010 InjkttxD,This is absolutely basic AutoIt stuff. If you do not know how to this, your scripting career will be very short! Reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) will help you enormously. You should also look at the excellent tutorials that you will find here and here - you will find other tutorials in the Wiki (the link is at the top of the page). There are even video tutorials on YouTube if you prefer watching to reading. Just to get you started, here is a very basic outline of how you might go about what you want: #include <GUIConstantsEx.au3> $hGUI = GUICreate("Form1", 500, 500) GUICtrlCreateLabel("Select a Script to run/install", 10, 10) GUICtrlCreateGroup("", 10, 30, 200, 70) $hRadio1 = GUICtrlCreateRadio(" Script 1", 20, 40, 170, 20) $hRadio2 = GUICtrlCreateRadio(" Script 2", 20, 70, 170, 20) GUICtrlCreateGroup("", -99, -99, 1, 1) ;close group $hButton1 = GUICtrlCreateButton("Run", 10, 120, 80, 30) $hButton2 = GUICtrlCreateButton("Install", 10, 170, 80, 30) GUISetState() While 1 $Msg = GuiGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $hButton1 If BitAND(GUICtrlRead($hRadio1), $GUI_CHECKED) = $GUI_CHECKED then MsgBox (0, "Action", "This runs Script 1") ElseIf BitAND(GUICtrlRead($hRadio2), $GUI_CHECKED) = $GUI_CHECKED Then MsgBox (0, "Action", "This runs Script 2") Else MsgBox (0, "Error", "Nothing was selected!") EndIf Case $hButton2 If BitAND(GUICtrlRead($hRadio1), $GUI_CHECKED) = $GUI_CHECKED then MsgBox (0, "Action", "This installs Script 1") ElseIf BitAND(GUICtrlRead($hRadio2), $GUI_CHECKED) = $GUI_CHECKED Then MsgBox (0, "Action", "This installs Script 2") Else MsgBox (0, "Error", "Nothing was selected!") EndIf EndSwitch WEndDo not ask any questions until AFTER you have gone through the tutorials - they will explain most things. 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...
InjkttxD Posted October 7, 2010 Author Share Posted October 7, 2010 Haha thanks, it's my first time using coding/AutoIt. IK've looked up tuts etc but i just don't understand, it's not untill someone shows me the code and i compare it then i understand. My code thus far is : #include <GuiConstantsEx.au3> #include <AVIConstants.au3> #include <TreeViewConstants.au3> ; GUI GuiCreate("Sample GUI", 250, 300) GuiSetIcon(@SystemDir & "\mspaint.exe", 0) ; PIC GuiCtrlCreatePic("Untitled-2 copy.jpg",0,0, 250,100) GuiCtrlCreatePic("Untitled-3.jpg",85,80, 165,141) GuiCtrlSetColor(-1,0xffffff) ; DATE GuiCtrlCreateDate("", 5, 280, 200, 20) GuiCtrlCreateLabel("(Date control expands into a calendar)", 10, 305, 200, 20) ; BUTTON GuiCtrlCreateButton("[color="#FF0000"]Start![/color]", 5, 230, 120, 30) ; CHECKBOX GuiCtrlCreateCheckbox("[color="#FF0000"]COntrol[/color]", 5, 175, 80, 20) GuiCtrlSetState(-1, $GUI_CHECKED) GuiCtrlCreateCheckbox("[color="#FF0000"]CLick[/color]", 5, 195, 80, 20) GuiCtrlSetState(-2, $GUI_CHECKED) ; GUI MESSAGE LOOP GuiSetState() While GuiGetMsg() <> $GUI_EVENT_CLOSE WEnd which is just an edit of the Example Autoit gives us. I've got everything setup where i want it too be etc. But i have no idea how to link it, the texts in red are what i need my scripts to link too. Hopefully you understand, i'm all new to this sorry Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 7, 2010 Moderators Share Posted October 7, 2010 InjkttxD,i'm all new to this sorryNo need to be sorry - we all started at that point! It is important to understand the basics of how AutoIt works if you want to code anything other than a GUI with a few controls on it. That is the easy part - the difficult bit is tying it all together as you have discovered. Remember, it is up to you to make some effort to get to grips with AutoIt coding - we will help you get over problems, but we will not write it all for you. Think of the old saying: "Give a man a fish, you feed him for a day; give a man a net and you feed him forever". We try to be net makers and repairers, not fishmongers. Look at the code I posted above - it shows how to check within the GUIGetMsg loop for actions on the controls created in the GUI. In this script I am firing MsgBoxes to indicate that a button control was pressed and that a particular Checkbox was checked. You would have to insert code at that point to run the scripts you say you have perfected.What about that simple script do you find hard to understand? 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...
InjkttxD Posted October 7, 2010 Author Share Posted October 7, 2010 I just don't know how to make it so when i click the button it executes, like i said, i've made my whole GUI and now all i've got too do is link it.. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 7, 2010 Moderators Share Posted October 7, 2010 InjkttxD,I cannot make it any simpler than this: #include <GUIConstantsEx.au3> ; Create the GUI $hGUI = GUICreate("Test", 500, 500) ; Create a control $hButton = GUICtrlCreateButton("Go!", 10, 10, 80, 30) GUISetState() While 1 ; Look for a control being activated Switch GUIGetMsg() ; If it is the [X] then exit Case $GUI_EVENT_CLOSE Exit ; If it is the button Case $hButton ; Show a MsgBox MsgBox(0, "Button Press", "You pressed the button!") EndSwitch WEndYou need to put some code in place of the MsgBox to run the scripts you already have.If they are compiled, then use:Run(My_Compiled_Script_Name.exe)If they are still in .au3 format, then use:ShellExecute("C:\Program Files\AutoIt3\AutoIt3.exe", "My_Script_Name.au3")You might have to change the path for AutoIt if you did a non-standard install. Now, can you follow that? 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...
InjkttxD Posted October 9, 2010 Author Share Posted October 9, 2010 Ok, i understand the shellexecute function. However. Example Run("C:\Users\Rodd James\Desktop\55.exe") will not execute the Installer file, but if i replace the "55.exe" with "Clicker.exe" It will run the compiled script. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 9, 2010 Moderators Share Posted October 9, 2010 InjkttxD,will not execute the Installer fileDoes the installer run when you enter the same path into a command prompt? 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...
InjkttxD Posted October 9, 2010 Author Share Posted October 9, 2010 So i just put in the same cfode i used for the Autoit? i've never used command prompt before Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 9, 2010 Moderators Share Posted October 9, 2010 InjkttxD,I was just trying to see if you had the correct path for your installer executable. As you have seen, the command works fine with your compiled script - so are you sure that the installer path is as written? 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...
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