Jump to content

About GUI.


Recommended Posts

  • Moderators

fury0n,

I am afraid your request makes little sense - normally you would have the one While...WEnd loop and do different things within it depending on which checkbox was checked. Can you explain in a little more detail what you are trying to do. :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

fury0n,

I am afraid your request makes little sense - normally you would have the one While...WEnd loop and do different things within it depending on which checkbox was checked. Can you explain in a little more detail what you are trying to do. :huh:

M23

Haha I'm making such a fool of myself, I wish I had any clue what I was rambling about, no wonder why I make no sense.

I hadn't gotten my cup of coffe just yet, I'll try to explain in more detail.

 
#include <Constants.au3>
#include <GUIConstantsEx.au3>

Local $GUI = GUICreate("GUI", 180, 80)
Local $radiobutton1 = GUICtrlCreateRadio("Option 1", 10, 10, 60)
Local $radiobutton2 = GUICtrlCreateRadio("Option 2", 110, 10, 60)
Local $button = GUICtrlCreateButton("OK", 10, 40, 160)
GUISetState(@SW_SHOW, $GUI)

While 1
   Local $Msg = 0
    $Msg = GUIGetMsg()
    Switch $Msg
        Case $radiobutton1
            MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 1.")
        Case $radiobutton2
            MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 2.")
Case $button
MsgBox($MB_SYSTEMMODAL, "Title", "I want the chosen option to run now.")
        Case $GUI_EVENT_CLOSE
            ExitLoop
EndSwitch
WEnd

This is what I have right now. The issue here is that I don't want it to say "You have chosen option 1/2" until I've actually pressed the button.

I'm still really new when it comes to AutoIt and I don't really know where to go from here, if you want me to explain it further I'll do my absolute best to do so.

Edited by fury0n
Link to comment
Share on other sites

  • Moderators

fury0n,

How about this: ;)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Local $GUI = GUICreate("GUI", 180, 80)
Local $radiobutton1 = GUICtrlCreateRadio("Option 1", 10, 10, 60)
Local $radiobutton2 = GUICtrlCreateRadio("Option 2", 110, 10, 60)
Local $button = GUICtrlCreateButton("OK", 10, 40, 160)
GUISetState(@SW_SHOW, $GUI)

While 1
    Switch GUIGetMsg()
        Case $button
            If GUICtrlRead($radiobutton1) = 1 Then
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 1.")
            Else
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 2.")
            EndIf
            MsgBox($MB_SYSTEMMODAL, "Title", "I want the chosen option to run now.")
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
Please ask if you have any questions. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

fury0n,

How about this: ;)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Local $GUI = GUICreate("GUI", 180, 80)
Local $radiobutton1 = GUICtrlCreateRadio("Option 1", 10, 10, 60)
Local $radiobutton2 = GUICtrlCreateRadio("Option 2", 110, 10, 60)
Local $button = GUICtrlCreateButton("OK", 10, 40, 160)
GUISetState(@SW_SHOW, $GUI)

While 1
    Switch GUIGetMsg()
        Case $button
            If GUICtrlRead($radiobutton1) = 1 Then
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 1.")
            Else
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 2.")
            EndIf
            MsgBox($MB_SYSTEMMODAL, "Title", "I want the chosen option to run now.")
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
Please ask if you have any questions. :)

M23

 

This has actually helped me a lot, thank you!

How would I move on with three options instead? 

 

I added a little more. How would I do to make the MsgBox when I press OK to output whatever I input in the input boxes?

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Local $GUI = GUICreate("GUI", 360, 160)
Local $radiobutton1 = GUICtrlCreateRadio("Option 1", 10, 10, 60)
Local $radiobutton2 = GUICtrlCreateRadio("Option 2", 110, 10, 60)
Local $button = GUICtrlCreateButton("OK", 10, 120, 160)
Local $input1 = GUICtrlCreateInput("", 10, 40, 160)
Local $input2 = GUICtrlCreateInput("", 10, 80, 160)
GUISetState(@SW_SHOW, $GUI)

While 1
    Switch GUIGetMsg()
        Case $button
            If GUICtrlRead($radiobutton1) = 1 Then
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 1.")
            Else
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 2.")
            EndIf
            MsgBox($MB_SYSTEMMODAL, "Title", "You have written " & $input1 & " and " & $input2)
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
Link to comment
Share on other sites

  • Moderators

fury0n,

 

How would I move on with three options instead?

If GUICtrlRead($radiobutton1) = 1 Then
    MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 1.")
ElseIf GUICtrlRead($radiobutton2) = 1 Then
    MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 2.")
Else
    MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 3.")
EndIf
If you have more than 3 I would start thinking about arrays. ;)

 

How would I do to make the MsgBox when I press OK to output whatever I input in the input boxes?

Look at GUICtrlRead in the Help file. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
Share on other sites

fury0n,

 

If GUICtrlRead($radiobutton1) = 1 Then
    MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 1.")
ElseIf GUICtrlRead($radiobutton2) = 1 Then
    MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 2.")
Else
    MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 3.")
EndIf
If you have more than 3 I would start thinking about arrays. ;)

 

Look at GUICtrlRead in the Help file. :)

M23

 

Until now I'll use ElseIf, gotta move on slowly, haha.

I have really tried everything! It's so hard to learn programming from scratch when I don't know which functions there are, argh!

Local $input1 = GUICtrlCreateInput("", 10, 40, 160)
Local $input2 = GUICtrlCreateInput("", 10, 80, 160)
$input1text = GUICtrlRead($input1)
$input2text = GUICtrlRead($input2)

            MsgBox($MB_SYSTEMMODAL, "Title", "You have written " & $input1text & " and " & $input2text)

I tried doing this but no luck. But I noticed that when I put any text in between the commas, like this:

Local $input2 = GUICtrlCreateInput("asd", 10, 80, 160)

It would output the asd, no matter what I typed in the input box after.

I'm stuck again... :(

Link to comment
Share on other sites

  • Moderators

fury0n,

If you read the inputs immediately after creation they will not give you their current content. You need to read them when you press the button - like this: ;)

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Local $GUI = GUICreate("GUI", 360, 160)
Local $radiobutton1 = GUICtrlCreateRadio("Option 1", 10, 10, 60)
Local $radiobutton2 = GUICtrlCreateRadio("Option 2", 110, 10, 60)
GUICtrlSetState($radiobutton1, $GUI_CHECKED) ; Set a default selection <<<<<<<<<<<<<<<<<<<<<<<<<<<
Local $button = GUICtrlCreateButton("OK", 10, 120, 160)
Local $input1 = GUICtrlCreateInput("abc", 10, 40, 160)
Local $input2 = GUICtrlCreateInput("def", 10, 80, 160)
; Do not read the inputs here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
GUISetState(@SW_SHOW, $GUI)

While 1
    Switch GUIGetMsg()
        Case $button
            If GUICtrlRead($radiobutton1) = 1 Then
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 1.")
            Else
                MsgBox($MB_SYSTEMMODAL, "GUI Event", "You have chosen option 2.")
            EndIf
            ; Read the inputs now <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            $input1text = GUICtrlRead($input1)
            $input2text = GUICtrlRead($input2)
            MsgBox($MB_SYSTEMMODAL, "Title", "You have written " & $input1text & " and " & $input2text)
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
WEnd
All clear? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...