jakalspop Posted July 12, 2011 Share Posted July 12, 2011 i try create script using treeview can user use tree to select item so when i use script While 1 $nMsg = GUIGetMsg() Select Case $nMsg = $1 ;tree item While 1 $msg = GUIGetMsg() Select Case $msg = $menu ;menu item wend EndSelect Case $nMsg = $2 ;tree item While 1 $msg = GUIGetMsg() Select Case $msg = $menu ;menu item wend EndSelect EndSelectwhen script running it take to long to respond (More then 6 Sec) for menu and tree item how can i use just function to control treeview and menu to be script likewith out use GUIGetMsg()to make script faster?GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFYmenu") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFYtree") While 1 sleep(250) Wend Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 12, 2011 Moderators Share Posted July 12, 2011 jakalspop, If I had a menu and a treeview to click on I would do this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Global $aData[5] = [4, "Tree Item 1", "Tree Item 2", "Tree Item 3", "Tree Item 4"] Global $aItem_Handles[UBound($aData)] Global $hMain_GUI = GUICreate("TreeView Demo", 500, 500) $mMenu = GUICtrlCreateMenu("Menu") $mItem_1 = GUICtrlCreateMenuItem("Menu Item 1", $mMenu) $mItem_2 = GUICtrlCreateMenuItem("Menu Item 2", $mMenu) $mItem_3 = GUICtrlCreateMenuItem("Menu Item 3", $mMenu) $hTree = GUICtrlCreateTreeView(10, 10, 480, 480) $hRoot = GUICtrlCreateTreeViewItem("Tree Root", $hTree) For $i = 1 To $aData[0] $aItem_Handles[$i] = GUICtrlGetHandle(GUICtrlCreateTreeViewItem($aData[$i], $hRoot)) Next _GUICtrlTreeView_Expand(GUICtrlGetHandle($hTree)) GUISetState() ; Initialise "Click on TreeView function" GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY") Global $fClick = False While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $mItem_1 MsgBox(0, "Hit", "You clicked on Menu Item 1") Case $mItem_2 MsgBox(0, "Hit", "You clicked on Menu Item 2") Case $mItem_3 MsgBox(0, "Hit", "You clicked on Menu Item 3") EndSwitch ; Check if tree view clicked If $fClick = True Then $sText = _GUICtrlTreeView_GetText($hTree, _GUICtrlTreeView_GetSelection($hTree)) MsgBox(0, "Hit", "You clicked on " & $sText ) $fClick = False EndIf WEnd Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Switch $wParam Case $hTree Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_CLICK Then $fClick = True EndSwitch $tagNMHDR = 0 EndFunc ;==>MY_WM_NOTIFY Is that fast enough? 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...
jakalspop Posted July 12, 2011 Author Share Posted July 12, 2011 no you got worn idea when you select item form treeview it will create new tools i have many problem to switch between treeview item it take to many time because there are to many item treeview and other tools (listview , Button,GUICtrlCreateEdit) will create after select item form treeview i need make every Variables have function GUIGetMsg() will revise all Variables in GUI that make script slow and while in while Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 12, 2011 Moderators Share Posted July 12, 2011 jakalspop, I understand that you are using the TreeView to select the controls to display on your GUI. If so, then you can do it like this: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> Global $aData[4] = [3, "Tree Item 1", "Tree Item 2", "Tree Item 3"] Global $aItem_Handles[UBound($aData)] Global $hMain_GUI = GUICreate("TreeView Demo", 500, 520) $mMenu = GUICtrlCreateMenu("Menu") $mItem_1 = GUICtrlCreateMenuItem("Menu Item 1", $mMenu) $mItem_2 = GUICtrlCreateMenuItem("Menu Item 2", $mMenu) $mItem_3 = GUICtrlCreateMenuItem("Menu Item 3", $mMenu) $hTree = GUICtrlCreateTreeView(10, 10, 480, 180) $hRoot = GUICtrlCreateTreeViewItem("Tree Root", $hTree) For $i = 1 To $aData[0] $aItem_Handles[$i] = GUICtrlGetHandle(GUICtrlCreateTreeViewItem($aData[$i], $hRoot)) Next _GUICtrlTreeView_Expand(GUICtrlGetHandle($hTree)) ; Noew create the different sets of controls ; These will be shown when Menu/Tree Item 1 is clicked $hEdit_1 = GUICtrlCreateEdit("", 10, 250, 480, 200) $hButton_1 = GUICtrlCreateButton("Test 1", 10, 460, 80, 30) ; These will be shown when Menu/Tree Item 2 is clicked $hListView_2 = GUICtrlCreateListView("Header Text", 10, 250, 480, 200) For $i = 1 To 20 GUICtrlCreateListViewItem("Item " & $i, $hListView_2) Next $hButton_2 = GUICtrlCreateButton("Test 2", 210, 460, 80, 30) ; These will be shown when Menu/Tree Item 2 is clicked $hCombo_3 = GUICtrlCreateCombo("", 10, 250, 200, 20) GUICtrlSetData(-1, "1|2|3|4|5|6|7|8|9") $hButton_3 = GUICtrlCreateButton("Test 3", 410, 460, 80, 30) ; Hide all 2 & 3 controls For $i = $hListView_2 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next GUISetState() ; Initialise "Click on TreeView function" GUIRegisterMsg($WM_NOTIFY, "MY_WM_NOTIFY") Global $fClick = False While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $mItem_1 ; Hide all controls For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next ; Show all 1 controls For $i = $hEdit_1 To $hButton_1 GUICtrlSetState($i, $GUI_SHOW) Next Case $mItem_2 For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next For $i = $hListView_2 To $hButton_2 GUICtrlSetState($i, $GUI_SHOW) Next Case $mItem_3 For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next For $i = $hCombo_3 To $hButton_3 GUICtrlSetState($i, $GUI_SHOW) Next EndSwitch ; Check if tree view clicked If $fClick = True Then Switch _GUICtrlTreeView_GetText($hTree, _GUICtrlTreeView_GetSelection($hTree)) Case "Tree Item 1" For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next For $i = $hEdit_1 To $hButton_1 GUICtrlSetState($i, $GUI_SHOW) Next Case "Tree Item 2" For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next For $i = $hListView_2 To $hButton_2 GUICtrlSetState($i, $GUI_SHOW) Next Case "Tree Item 3" For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next For $i = $hCombo_3 To $hButton_3 GUICtrlSetState($i, $GUI_SHOW) Next EndSwitch $fClick = False EndIf WEnd Func MY_WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Switch $wParam Case $hTree Local $tagNMHDR = DllStructCreate("int;int;int", $lParam) If @error Then Return If DllStructGetData($tagNMHDR, 3) = $NM_CLICK Then $fClick = True EndSwitch ;$tagNMHDR = 0 EndFunc ;==>MY_WM_NOTIFY Am I getting closer? 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...
jakalspop Posted July 13, 2011 Author Share Posted July 13, 2011 thank but in you example you have only Tow Variables to show or hide if to there are 10 how can use For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_HIDE) Next ;OR For $i = $hEdit_1 To $hButton_3 GUICtrlSetState($i, $GUI_SHOW) Next Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 13, 2011 Moderators Share Posted July 13, 2011 jakalspop,First, you need to understand how the ControlIDs are allocated. AutoIt has an internal array which holds the data for all the controls created by the native (GUICtrlCreate*) functions. The ControlID returned by these functions is actually the index of this array in which the details of the control are stored. AutoIt always looks for the first empty element of this array to use for the next created control. Now to your question. If you create the controls for each group you want to Show/Hide in IMMEDIATE SUCCESSION, and no controls created earlier have been deleted, the ControlIDs of these controls should be in a single block. So you can a loop to hide them - just as I did in the example I posted: For $i = $iFirst_ControlID_In_Group To $iLast_ControlID_In_Group GUICtrlSetState($i, $GUI_HIDE) NextBe aware that this is a trick - there is no guarantee that it will always be true in future releases - although I believe it will be because a lot of us depend on it! And it will only be true if no controls created earlier have been deleted (unless you recreate the same number of controls immediately after the deletion).I hope that is all clear - please ask again if not. 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