usera Posted April 20, 2009 Share Posted April 20, 2009 Greeting, According to example file: c:\Program Files\AutoIt3\Examples\Helpfile\ControlTreeView.au3 I did some changes for my request as below: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ ; Author: Zedna #include <GUIConstantsEx.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> $gui = GUICreate("ControlTreeview test", 212, 212) $treeview = GUICtrlCreateTreeView(6, 6, 200, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) $h_tree = ControlGetHandle($gui, "", $treeview) $root = GUICtrlCreateTreeViewItem("Root", $treeview) $item1 = GUICtrlCreateTreeViewItem("Copy file", $root) $item2 = GUICtrlCreateTreeViewItem("Delete File", $root) $item3 = GUICtrlCreateTreeViewItem("Rename File", $root) $item4 = GUICtrlCreateTreeViewItem("Print", $root) $item41 = GUICtrlCreateTreeViewItem("Report 1", $item4) $item42 = GUICtrlCreateTreeViewItem("Report 2", $item4) $item5 = GUICtrlCreateTreeViewItem("Item 5", $root) GUISetState(@SW_SHOW) ; some examples ControlTreeView ($gui, "", $h_tree, "Expand", "Root") ControlTreeView ($gui, "", $h_tree, "Exists", "Root|Print") ControlTreeView ($gui, "", $h_tree, "Check", "Root|Print") ControlTreeView ($gui, "", $h_tree, "Select", "Root|Print") ControlTreeView ($gui, "", $h_tree, "Expand", "Root|Print") While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd ------------------------------------------------------------------------------------------------------------------------- just want to know how: 1. can I get the information what the user did check. for example usera want to copy file and print report1 ; but userb want to rename file and print report1 and report2. 2. How can I add an ok button blew, let the user close the selection windows and the program go ahead do what they want to do. Thanks Link to comment Share on other sites More sharing options...
usera Posted April 20, 2009 Author Share Posted April 20, 2009 Thanks for help if you can Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 20, 2009 Moderators Share Posted April 20, 2009 usera,First point: Please do not bump your own thread within 24 hours. ;-)Second point: As you evidently do not yet know enough about AutoIt to solve this very simple question yourself, I recommend reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) as this will help you enormously. You should also look at the excellent tutorials that you will find here and here.To give you an idea of what you can do, this amended version of your script will write to the SciTE console window when you check the 'Copy file' box. To complete the script you would need to write functions for each of the checkboxes (the very simple version of the Copy_File function should give you the idea) so that each time you press the button you run the relevant functions:expandcollapse popup#include <GUIConstantsEx.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> $gui = GUICreate("ControlTreeview test", 200, 220) $treeview = GUICtrlCreateTreeView(10, 10, 180, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) $h_tree = ControlGetHandle($gui, "", $treeview) $root = GUICtrlCreateTreeViewItem("Root", $treeview) $item1 = GUICtrlCreateTreeViewItem("Copy file", $root) $item2 = GUICtrlCreateTreeViewItem("Delete File", $root) $item3 = GUICtrlCreateTreeViewItem("Rename File", $root) $item4 = GUICtrlCreateTreeViewItem("Print", $root) $item41 = GUICtrlCreateTreeViewItem("Report 1", $item4) $item42 = GUICtrlCreateTreeViewItem("Report 2", $item4) $item5 = GUICtrlCreateTreeViewItem("Item 5", $root) $hButton = GUICtrlCreateButton("Go!", 60, 180, 80, 30) GUISetState(@SW_SHOW) Global $aAction[$item5 + 1] $aAction[$item1] = "Copy_File" $aAction[$item2] = "Delete_File" $aAction[$item3] = "Rename_File" $aAction[$item41] = "Print_Report_1" $aAction[$item42] = "Print_Report_2" $aAction[$item5] = "Do_Item_5" ControlTreeView ($gui, "", $h_tree, "Expand", "Root") ControlTreeView ($gui, "", $h_tree, "Expand", "Root|Print") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton For $i = $root To $item5 If BitAnd(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then Call($aAction[$i]) Next EndSwitch WEnd Func Copy_File() ConsoleWrite("Copy File" & @CRLF) EndFuncIf you do not understand the advice or the amended code - you really do need to read the Help file and tutorials! But do not get discouraged - everyone has to start somewhere.Have a go at writing another version of the script yourself - we are here if you run into problems.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...
usera Posted April 20, 2009 Author Share Posted April 20, 2009 Thanks, that is what I am looking for. you are GREAT!!! usera, First point: Please do not bump your own thread within 24 hours. ;-) Second point: As you evidently do not yet know enough about AutoIt to solve this very simple question yourself, I recommend reading the Help file (at least the first few sections - Using AutoIt, Tutorials and the first couple of References) as this will help you enormously. You should also look at the excellent tutorials that you will find here and here. To give you an idea of what you can do, this amended version of your script will write to the SciTE console window when you check the 'Copy file' box. To complete the script you would need to write functions for each of the checkboxes (the very simple version of the Copy_File function should give you the idea) so that each time you press the button you run the relevant functions:expandcollapse popup#include <GUIConstantsEx.au3> #include <TreeviewConstants.au3> #include <WindowsConstants.au3> $gui = GUICreate("ControlTreeview test", 200, 220) $treeview = GUICtrlCreateTreeView(10, 10, 180, 160, BitOR($TVS_HASBUTTONS, $TVS_HASLINES, $TVS_LINESATROOT, $TVS_CHECKBOXES), $WS_EX_CLIENTEDGE) $h_tree = ControlGetHandle($gui, "", $treeview) $root = GUICtrlCreateTreeViewItem("Root", $treeview) $item1 = GUICtrlCreateTreeViewItem("Copy file", $root) $item2 = GUICtrlCreateTreeViewItem("Delete File", $root) $item3 = GUICtrlCreateTreeViewItem("Rename File", $root) $item4 = GUICtrlCreateTreeViewItem("Print", $root) $item41 = GUICtrlCreateTreeViewItem("Report 1", $item4) $item42 = GUICtrlCreateTreeViewItem("Report 2", $item4) $item5 = GUICtrlCreateTreeViewItem("Item 5", $root) $hButton = GUICtrlCreateButton("Go!", 60, 180, 80, 30) GUISetState(@SW_SHOW) Global $aAction[$item5 + 1] $aAction[$item1] = "Copy_File" $aAction[$item2] = "Delete_File" $aAction[$item3] = "Rename_File" $aAction[$item41] = "Print_Report_1" $aAction[$item42] = "Print_Report_2" $aAction[$item5] = "Do_Item_5" ControlTreeView ($gui, "", $h_tree, "Expand", "Root") ControlTreeView ($gui, "", $h_tree, "Expand", "Root|Print") While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $hButton For $i = $root To $item5 If BitAnd(GUICtrlRead($i), $GUI_CHECKED) = $GUI_CHECKED Then Call($aAction[$i]) Next EndSwitch WEnd Func Copy_File() ConsoleWrite("Copy File" & @CRLF) EndFunc If you do not understand the advice or the amended code - you really do need to read the Help file and tutorials! But do not get discouraged - everyone has to start somewhere. Have a go at writing another version of the script yourself - we are here if you run into problems. M23 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 20, 2009 Moderators Share Posted April 20, 2009 usera,Glad I could help, but please use the 'Add Reply' button which is about 1cm lower then the 'Reply' button you pressed to post the above. That way you do not copy the entire preceding post into your post.It makes the thread much easier to read! :-)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