Sign in to follow this  
Followers 0
InjkttxD

Linking.

10 posts in this topic

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,

Share this post


Link to post
Share on other sites



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. :shocked:

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
WEnd

Do 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._______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

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

Share this post


Link to post
Share on other sites

InjkttxD,

i'm all new to this sorry

No need to be sorry - we all started at that point! :shocked:

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._______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

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..

Share this post


Link to post
Share on other sites

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

WEnd

You 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._______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

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.

Share this post


Link to post
Share on other sites

InjkttxD,

will not execute the Installer file

Does 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._______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

So i just put in the same cfode i used for the Autoit? i've never used command prompt before

Share this post


Link to post
Share on other sites

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._______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

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