Rawox Posted December 25, 2008 Share Posted December 25, 2008 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 More sharing options...
sandin Posted December 25, 2008 Share Posted December 25, 2008 expandcollapse popup#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 Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
FireFox Posted December 25, 2008 Share Posted December 25, 2008 #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 More sharing options...
Rawox Posted December 25, 2008 Author Share Posted December 25, 2008 Beautifull Script! Exactly what I needed, almost I want to have it that way that it runs an other script when the user clicks start... Could you maken that?? expandcollapse popup#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 More sharing options...
sandin Posted December 25, 2008 Share Posted December 25, 2008 (edited) like this? (note there must be "Script1" or "Script2" in the same folder as your running script in order for line 37 to work: expandcollapse popup#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 December 25, 2008 by sandin Some cool glass and image menu | WinLIRC remote controler | Happy Holidays to all... | Bounce the sun, a game in which you must save the sun from falling by bouncing it back into the sky | Hook Leadtek WinFast TV Card Remote Control Msges | GDI+ sliding toolbar | MIDI Keyboard (early alpha stage, with lots of bugs to fix) | Alt+Tab replacement | CPU Benchmark with pretty GUI | Ini Editor - Edit/Create your ini files with great ease | Window Manager (take total control of your windows) Pretty GUI! | Pop-Up window from a button | Box slider for toolbar | Display sound volume on desktop | Switch hotkeys with mouse scroll Link to comment Share on other sites More sharing options...
Rawox Posted December 25, 2008 Author Share Posted December 25, 2008 Yeah! So many thanks! It works . 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: expandcollapse popup#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 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