Jump to content

Several Options


Rawox
 Share

Recommended Posts

Hi,

I want to make something with several options. It can be in TreeView or with Checkboxes (or maybe something else) It needs to be a 'selector'. A window where the user can choose in which (sub)script he wants to launch.

- TreeView Example:

Windows XP -> Mozilla Firefox -> 1280 X 800

(Operating System -> Browser -> Scr. Resolution)

Explanation: If the user is at the end of the treeview (so you can't open (+) it further) the user needs to click "start" and the script that is selected must be started.

- CheckBox Example:

[] Browser: Mozilla Firefox

Operating System: Windows XP

Screen Resolution: 1280 X 800

Explanation: All the different options can be viewed in a window and the user can only select one checkbox at a time. If the user selected the right one he can click "start" and the selected script will be started.

Can someone please make a simple start of one of those scripts? Just simple with a really small treeview or just a few checkboxes and a simple MsgBox when the user clicks the button.

I would really appreciate that! Coz I can't get it to work :)

Bye, Rawox

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

$Form1 = GUICreate("Form1", 200, 400)
$iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
$hTreeView = _GUICtrlTreeView_Create($Form1, 0, 0, 200, 380, $iStyle, $WS_EX_CLIENTEDGE)

_GUICtrlTreeView_BeginUpdate($hTreeView)
$parent1 = _GUICtrlTreeView_Add($hTreeView, 0, "Windows XP")
$child11 = _GUICtrlTreeView_AddChild($hTreeView, $parent1, "Mozilla Firefox")
$child12 = _GUICtrlTreeView_AddChild($hTreeView, $child11, "1280 x 800")
$parent2 = _GUICtrlTreeView_Add($hTreeView, 0, "Some OS")
$child21 = _GUICtrlTreeView_AddChild($hTreeView, $parent2, "Browser")
$child22 = _GUICtrlTreeView_AddChild($hTreeView, $child21, "Resolution")
_GUICtrlTreeView_EndUpdate($hTreeView)

$Start_Button = GUICtrlCreateButton("Start", 0, 380, 100, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
$Exit_Button = GUICtrlCreateButton("Exit", 100, 380, 100, 20)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Exit_Button
            Exit
        case $Start_Button
            Local $current = _GUICtrlTreeView_GetSelection($hTreeView)
            Local $parent_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current)))
            Local $middle_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current))
            Local $last_x = _GUICtrlTreeView_GetText($hTreeView, $current)
            MsgBox(0, "listview item:", "First item: " & $parent_x & @CRLF _
                                        & "Second item: " & $middle_x & @CRLF _
                                        & "Last item: " & $last_x)
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom;  144 80
        Case $hWndTreeview
            Switch $iCode
                Case $TVN_SELCHANGED, $TVN_SELCHANGEDW
                    if _GUICtrlTreeView_GetChildCount($hTreeView, _GUICtrlTreeView_GetSelection($hTreeView)) = -1 Then
                        if GUICtrlGetState($Start_Button) <> 80 then GUICtrlSetState($Start_Button, $GUI_ENABLE)
                    Else
                        if GUICtrlGetState($Start_Button) <> 144 then GUICtrlSetState($Start_Button, $GUI_DISABLE)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY

Link to comment
Share on other sites

#include <GuiConstants.au3>
Opt("GuiOnEventMode", 1)

GUICreate("GUI", 120, 100)
$R1 = GUICtrlCreateRadio("Mozilla Firefox", 5, 5)
$R2 = GUICtrlCreateRadio("Windows XP", 5, 25)
$R3 = GUICtrlCreateRadio("1280 X 800", 5, 45)
GUICtrlCreateButton("Check !", 5, 70, 50, 20)
GUICtrlSetOnEvent(-1, "_Func")
GUISetState()

Func _Func()
    If GUICtrlRead($R1) = $GUI_CHECKED Then
        MsgBox(64, "", "Radio 1 checked !")
    ElseIf GUICtrlRead($R2) = $GUI_CHECKED Then
        MsgBox(64, "", "Radio 2 checked !")
    ElseIf GUICtrlRead($R3) = $GUI_CHECKED Then
        MsgBox(64, "", "Radio 3 checked !")
    Else
        MsgBox(64, "", "No Radio checked !")
    EndIf
EndFunc   ;==>_Func

While 1
    Sleep(250)
WEnd

Merry xmas,

FireFox

Link to comment
Share on other sites

Beautifull Script! Exactly what I needed, almost :o I want to have it that way that it runs an other script when the user clicks start...

Could you maken that?? :)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

$Form1 = GUICreate("Form1", 200, 400)
$iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
$hTreeView = _GUICtrlTreeView_Create($Form1, 0, 0, 200, 380, $iStyle, $WS_EX_CLIENTEDGE)

_GUICtrlTreeView_BeginUpdate($hTreeView)
$parent1 = _GUICtrlTreeView_Add($hTreeView, 0, "Windows XP")
$child11 = _GUICtrlTreeView_AddChild($hTreeView, $parent1, "Mozilla Firefox")
$child12 = _GUICtrlTreeView_AddChild($hTreeView, $child11, "1280 x 800")
$parent2 = _GUICtrlTreeView_Add($hTreeView, 0, "Some OS")
$child21 = _GUICtrlTreeView_AddChild($hTreeView, $parent2, "Browser")
$child22 = _GUICtrlTreeView_AddChild($hTreeView, $child21, "Resolution")
_GUICtrlTreeView_EndUpdate($hTreeView)

$Start_Button = GUICtrlCreateButton("Start", 0, 380, 100, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
$Exit_Button = GUICtrlCreateButton("Exit", 100, 380, 100, 20)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Exit_Button
            Exit
        case $Start_Button
            Local $current = _GUICtrlTreeView_GetSelection($hTreeView)
            Local $parent_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current)))
            Local $middle_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current))
            Local $last_x = _GUICtrlTreeView_GetText($hTreeView, $current)
            MsgBox(0, "listview item:", "First item: " & $parent_x & @CRLF _
                                        & "Second item: " & $middle_x & @CRLF _
                                        & "Last item: " & $last_x)
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom;  144 80
        Case $hWndTreeview
            Switch $iCode
                Case $TVN_SELCHANGED, $TVN_SELCHANGEDW
                    if _GUICtrlTreeView_GetChildCount($hTreeView, _GUICtrlTreeView_GetSelection($hTreeView)) = -1 Then
                        if GUICtrlGetState($Start_Button) <> 80 then GUICtrlSetState($Start_Button, $GUI_ENABLE)
                    Else
                        if GUICtrlGetState($Start_Button) <> 144 then GUICtrlSetState($Start_Button, $GUI_DISABLE)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Link to comment
Share on other sites

like this? (note there must be "Script1" or "Script2" in the same folder as your running script in order for line 37 to work:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

$Form1 = GUICreate("Form1", 200, 400)
$iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
$hTreeView = _GUICtrlTreeView_Create($Form1, 0, 0, 200, 380, $iStyle, $WS_EX_CLIENTEDGE)

_GUICtrlTreeView_BeginUpdate($hTreeView)
$parent1 = _GUICtrlTreeView_Add($hTreeView, 0, "Windows XP")
$child11 = _GUICtrlTreeView_AddChild($hTreeView, $parent1, "Mozilla Firefox")
$child12 = _GUICtrlTreeView_AddChild($hTreeView, $child11, "Script1")
$parent2 = _GUICtrlTreeView_Add($hTreeView, 0, "Some OS")
$child21 = _GUICtrlTreeView_AddChild($hTreeView, $parent2, "Browser")
$child22 = _GUICtrlTreeView_AddChild($hTreeView, $child21, "Script2")
_GUICtrlTreeView_EndUpdate($hTreeView)

$Start_Button = GUICtrlCreateButton("Start", 0, 380, 100, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
$Exit_Button = GUICtrlCreateButton("Exit", 100, 380, 100, 20)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Exit_Button
            Exit
        case $Start_Button
            Local $current = _GUICtrlTreeView_GetSelection($hTreeView)
;~          Local $parent_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current)))
;~          Local $middle_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current))
            Local $last_x = _GUICtrlTreeView_GetText($hTreeView, $current)
;~          MsgBox(0, "listview item:", "First item: " & $parent_x & @CRLF _
;~                                      & "Second item: " & $middle_x & @CRLF _
;~                                      & "Last item: " & $last_x)
            ShellExecute(@ScriptDir & "\" & $last_x & ".au3")
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $TVN_SELCHANGED, $TVN_SELCHANGEDW
                    if _GUICtrlTreeView_GetChildCount($hTreeView, _GUICtrlTreeView_GetSelection($hTreeView)) = -1 Then
                        if GUICtrlGetState($Start_Button) <> 80 then GUICtrlSetState($Start_Button, $GUI_ENABLE)
                    Else
                        if GUICtrlGetState($Start_Button) <> 144 then GUICtrlSetState($Start_Button, $GUI_DISABLE)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
Edited by sandin
Link to comment
Share on other sites

Yeah! So many thanks! It works :o. Only need to style it :) But I can do that myself. Thnx Thnx Thnx

like this? (note there must be "Script1" or "Script2" in the same folder as your running script in order for line 37 to work:

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <GuiTreeView.au3>

$Form1 = GUICreate("Form1", 200, 400)
$iStyle = BitOR($TVS_EDITLABELS, $TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_DISABLEDRAGDROP, $TVS_SHOWSELALWAYS)
$hTreeView = _GUICtrlTreeView_Create($Form1, 0, 0, 200, 380, $iStyle, $WS_EX_CLIENTEDGE)

_GUICtrlTreeView_BeginUpdate($hTreeView)
$parent1 = _GUICtrlTreeView_Add($hTreeView, 0, "Windows XP")
$child11 = _GUICtrlTreeView_AddChild($hTreeView, $parent1, "Mozilla Firefox")
$child12 = _GUICtrlTreeView_AddChild($hTreeView, $child11, "Script1")
$parent2 = _GUICtrlTreeView_Add($hTreeView, 0, "Some OS")
$child21 = _GUICtrlTreeView_AddChild($hTreeView, $parent2, "Browser")
$child22 = _GUICtrlTreeView_AddChild($hTreeView, $child21, "Script2")
_GUICtrlTreeView_EndUpdate($hTreeView)

$Start_Button = GUICtrlCreateButton("Start", 0, 380, 100, 20)
GUICtrlSetState(-1, $GUI_DISABLE)
$Exit_Button = GUICtrlCreateButton("Exit", 100, 380, 100, 20)
GUISetState(@SW_SHOW)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE, $Exit_Button
            Exit
        case $Start_Button
            Local $current = _GUICtrlTreeView_GetSelection($hTreeView)
;~          Local $parent_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current)))
;~          Local $middle_x = _GUICtrlTreeView_GetText($hTreeView, _GUICtrlTreeView_GetParentHandle($hTreeView, $current))
            Local $last_x = _GUICtrlTreeView_GetText($hTreeView, $current)
;~          MsgBox(0, "listview item:", "First item: " & $parent_x & @CRLF _
;~                                      & "Second item: " & $middle_x & @CRLF _
;~                                      & "Last item: " & $last_x)
            ShellExecute(@ScriptDir & "\" & $last_x & ".au3")
    EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
    #forceref $hWnd, $iMsg, $iwParam
    Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview
    $hWndTreeview = $hTreeView
    If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView)
    $tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
    $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
    $iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
    $iCode = DllStructGetData($tNMHDR, "Code")
    Switch $hWndFrom
        Case $hWndTreeview
            Switch $iCode
                Case $TVN_SELCHANGED, $TVN_SELCHANGEDW
                    if _GUICtrlTreeView_GetChildCount($hTreeView, _GUICtrlTreeView_GetSelection($hTreeView)) = -1 Then
                        if GUICtrlGetState($Start_Button) <> 80 then GUICtrlSetState($Start_Button, $GUI_ENABLE)
                    Else
                        if GUICtrlGetState($Start_Button) <> 144 then GUICtrlSetState($Start_Button, $GUI_DISABLE)
                    EndIf
            EndSwitch
    EndSwitch
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_NOTIFY
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...