upendk Posted January 13, 2010 Share Posted January 13, 2010 Hi, I am new to AutoIt Scripting, I have created a Tree View, Just want to add Double Mouse Click Funtion (Like if user double click on the option it, the scripts redirects it to the corresponding path as mentioned in the script) for the Child option. If anyone could help me out in this. Regards, Upendk Link to comment Share on other sites More sharing options...
PsaltyDS Posted January 13, 2010 Share Posted January 13, 2010 Demo detects double click on either the GUI or the treeview: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI, $idTV $hGUI = GUICreate("Test", 300, 300) $idTV = GUICtrlCreateTreeView(20, 20, 260, 100) For $i = 1 To 5 $idItem = GUICtrlCreateTreeViewItem("Item " & $i, $idTV) For $c = 1 To 5 $idChild = GUICtrlCreateTreeViewItem("Child " & $c, $idItem) Next Next GUIRegisterMsg($WM_LBUTTONDBLCLK, "_WM_LBUTTONDBLCLK") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tagNMHDR = "int hwndFrom; int idFrom; int code" Switch $wParam Case $idTV Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If @error Then Return If DllStructGetData($tNMHDR, "code") = $NM_DBLCLK Then ConsoleWrite("Double click on TreeView: Hwnd = " & DllStructGetData($tNMHDR, "hwndFrom") & _ "; ID = " & DllStructGetData($tNMHDR, "idFrom") & @LF) EndIf EndSwitch $tNMHDR = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Func _WM_LBUTTONDBLCLK($hWnd, $iMsg, $iwParam, $ilParam) Local $iX = BitAND($ilParam, 0xFFFF) Local $iY = BitShift($ilParam, 16) ConsoleWrite("Double click on GUI: Hwnd = " & $hWnd & "; X = " & $iX & "; Y = " & $iY & @CRLF) EndFunc ;==>_WM_LBUTTONDBLCLK Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
upendk Posted January 14, 2010 Author Share Posted January 14, 2010 Demo detects double click on either the GUI or the treeview: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $hGUI, $idTV $hGUI = GUICreate("Test", 300, 300) $idTV = GUICtrlCreateTreeView(20, 20, 260, 100) For $i = 1 To 5 $idItem = GUICtrlCreateTreeViewItem("Item " & $i, $idTV) For $c = 1 To 5 $idChild = GUICtrlCreateTreeViewItem("Child " & $c, $idItem) Next Next GUIRegisterMsg($WM_LBUTTONDBLCLK, "_WM_LBUTTONDBLCLK") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tagNMHDR = "int hwndFrom; int idFrom; int code" Switch $wParam Case $idTV Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If @error Then Return If DllStructGetData($tNMHDR, "code") = $NM_DBLCLK Then ConsoleWrite("Double click on TreeView: Hwnd = " & DllStructGetData($tNMHDR, "hwndFrom") & _ "; ID = " & DllStructGetData($tNMHDR, "idFrom") & @LF) EndIf EndSwitch $tNMHDR = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Func _WM_LBUTTONDBLCLK($hWnd, $iMsg, $iwParam, $ilParam) Local $iX = BitAND($ilParam, 0xFFFF) Local $iY = BitShift($ilParam, 16) ConsoleWrite("Double click on GUI: Hwnd = " & $hWnd & "; X = " & $iX & "; Y = " & $iY & @CRLF) EndFunc ;==>_WM_LBUTTONDBLCLK Link to comment Share on other sites More sharing options...
Der_Andi Posted August 9, 2010 Share Posted August 9, 2010 Hi, I tested the demo script, but when I double click the TV items (parent or child) nothing happens - except the expanding/collapsing thing. The console output is not printed. Any idea, what could be wrong? Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 9, 2010 Share Posted August 9, 2010 Are you running it in SciTE? The console is the bottom pane of the SciTE window, not the CMD shell console. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Der_Andi Posted August 10, 2010 Share Posted August 10, 2010 Of course it runs in Scite. The bottom pane does not display your "Double click on treeview..." output.(I've been working with AutoIt/Scite for over 6 years now, so I'm not that kind of new guy... )Here's the log created while running your script, double clicking and a few of the "child" TVI's:>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\Andreas\Desktop\demo_dblclick.au3" /autoit3dir "C:\Program Files (x86)\AutoIt3" /UserParams +>13:56:22 Starting AutoIt3Wrapper v.2.0.0.3 Environment(Language:0407 Keyboard:00000407 OS:WIN_VISTA/ CPU:X64 OS:X64) >Running AU3Check (1.54.19.0) from:C:\Program Files (x86)\AutoIt3 +>13:56:22 AU3Check ended.rc:0 >Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "C:\Users\Andreas\Desktop\demo_dblclick.au3" Double click on GUI: Hwnd = 0x00000000000106AA; X = 137; Y = 198 +>13:56:36 AutoIT3.exe ended.rc:0 +>13:56:37 AutoIt3Wrapper Finished >Exit code: 0 Time: 15.401My OS is Win7, not WinVista as stated in that log. Link to comment Share on other sites More sharing options...
PsaltyDS Posted August 10, 2010 Share Posted August 10, 2010 (edited) Oh, wow. I'm getting weirdness on Vista SP2 32-bit. I was sure that used to work on the old XP load it was written on! >"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Temp\Test1.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>12:08:23 Starting AutoIt3Wrapper v.2.0.1.22 Environment(Language:0409 Keyboard:00000409 OS:WIN_VISTA/Service Pack 2 CPU:X64 OS:X86) >Running AU3Check (1.54.19.0) from:C:\Program Files\AutoIt3 +>12:08:24 AU3Check ended.rc:0 >Running:(3.3.6.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Temp\Test1.au3" Double click on TreeView: Hwnd = 1443026; ID = 3 Double click on TreeView: Hwnd = 1443026; ID = 3 Double click on TreeView: Hwnd = 1443026; ID = 3 +>12:17:24 AutoIT3.exe ended.rc:0 >Exit code: 0 Time: 543.119 Notice I get the opposite failure: _WM_NOTIFY() triggers, but _WM_LBUTTONDBLCLK() does not. You seem to be seeing _WM_LBUTTonclick() because you're getting the X/Y coord (of the GUI) from lwparam instead of the ID. I'm confusing myself. I messed around with another version that works fine for both the GUI and treeview using the UDF functions, and can be run compiled: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiTreeView.au3> #include <WinAPI.au3> Global $hGUI, $hTV, $idTV, $idEdit, $hItem, $hChild $hGUI = GUICreate("Test", 300, 400) $hTV = _GUICtrlTreeView_Create($hGUI, 20, 20, 260, 100) $idTV = _WinAPI_GetDlgCtrlID($hTV) For $i = 1 To 5 $hItem = _GUICtrlTreeView_Add($hTV, 0, "Item " & $i) For $c = 1 To 5 $hChild = _GUICtrlTreeView_AddChild($hTV, $hItem, "Child " & $c) Next Next $idEdit = GUICtrlCreateEdit("", 20, 140, 260, 240) ControlSetText($hGUI, "", $idEdit, ControlGetText($hGUI, "", $idEdit) & _ "Initilize script: " & @CRLF & _ "$hGUI = " & $hGUI & @CRLF & _ "$hTV = " & $hTV & "; $idTV = " & $idTV & @CRLF & _ "$idEdit = " & $idEdit & @CRLF) GUIRegisterMsg($WM_LBUTTONDBLCLK, "_WM_LBUTTONDBLCLK") GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() Do Until GUIGetMsg() = $GUI_EVENT_CLOSE Func _WM_NOTIFY($hWnd, $Msg, $wParam, $lParam) Local $tagNMHDR = "int hwndFrom; int idFrom; int code" Switch $wParam Case $idTV Local $tNMHDR = DllStructCreate($tagNMHDR, $lParam) If @error Then Return If DllStructGetData($tNMHDR, "code") = $NM_DBLCLK Then ControlSetText($hGUI, "", $idEdit, ControlGetText($hGUI, "", $idEdit) & _ "Double click on TreeView: Hwnd = " & DllStructGetData($tNMHDR, "hwndFrom") & _ "; ID = " & DllStructGetData($tNMHDR, "idFrom") & @CRLF) EndIf EndSwitch $tNMHDR = 0 Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY Func _WM_LBUTTONDBLCLK($hWnd, $iMsg, $iwParam, $ilParam) Local $iX = BitAND($ilParam, 0xFFFF) Local $iY = BitShift($ilParam, 16) ControlSetText($hGUI, "", $idEdit, ControlGetText($hGUI, "", $idEdit) & _ "Double click on GUI: Hwnd = " & $hWnd & "; X = " & $iX & "; Y = " & $iY & @CRLF) EndFunc ;==>_WM_LBUTTONDBLCLK To compare, I went back and tried the original again and it also works fine for both (to the console). I think when I tried it a little while ago, I kept hitting the treeview and not the GUI. All this is working on 32-bit Vista, maybe we have a 64-bit issue here? Don't have it to test on here. Edited August 10, 2010 by PsaltyDS Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Der_Andi Posted August 10, 2010 Share Posted August 10, 2010 When I run this script in 32-bit mode likeC:\Program Files\AutoIt3\AutoIt3.exe C:\temp\demo_dblclick.au3TVI double clicks are working. In 64-bit, they are not.I replaced ConsoleWrite() with MsgBox() for this test, because I don't have SciTE's console here.So I reinstalled AutoIt3 without use of 64-bit tools and this seems to be the trick. The demo script works as intended.Now SciTE runs the script with 32-bit version of AutoIt3.exe.[...] >Running:(3.3.6.1):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\Andreas\Desktop\demo_dblclick.au3" Double click on treeview: Hwnd = 655774; ID = 3 Double click on GUI: Hwnd = 0x000F0798; X = 176; Y = 236 [...]But you are already running a 32-bit OS, so this makes your problem really strange. You could try, setting the compatibility mode for your AutoIt3.exe to WinXP, but I doubt it will change anything. Could be also a Vista thing, as it isn't that mature als Win7 . Link to comment Share on other sites More sharing options...
Der_Andi Posted August 10, 2010 Share Posted August 10, 2010 (edited) All this is working on 32-bit Vista, maybe we have a 64-bit issue here? Don't have it to test on here.I can confirm the 32-bit result on Win7. But both versions don't run in 64-bit. Edited August 10, 2010 by Der_Andi 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