PsaltyDS Posted July 26, 2007 Share Posted July 26, 2007 (edited) I seem to remember there was a better way... I hope there is a better way... I have a basic ListView Demo that I would like to take action when a ListViewItem is double-clicked. This works, but misses a lot: expandcollapse popup#include <GUIConstants.au3> Opt("GuiOnEventMode", 1) Global $LastClickID, $LastClickTime GUICreate("listview items", 220, 250, 100, 200) GUISetOnEvent($GUI_EVENT_CLOSE, "_Quit") GUISetBkColor(0x00E0FFFF) ; will change background colo $listview = GUICtrlCreateListView("col1 |col2|col3 ", 10, 10, 200, 150) GUICtrlSetOnEvent(-1, "_LVHit") $item1 = GUICtrlCreateListViewItem("item2|col22|col23", $listview) GUICtrlSetOnEvent(-1, "_LVHit") $item2 = GUICtrlCreateListViewItem("item1|col12|col13", $listview) GUICtrlSetOnEvent(-1, "_LVHit") $item3 = GUICtrlCreateListViewItem("item3|col32|col33", $listview) GUICtrlSetOnEvent(-1, "_LVHit") $button = GUICtrlCreateButton("Value?", 75, 170, 70, 20) GUICtrlSetOnEvent(-1, "_ButtonHit") $input1 = GUICtrlCreateInput("", 20, 200, 180) GUISetState() While 1 Sleep(20) WEnd Func _LVHit() If TimerDiff($LastClickTime) < 750 And $LastClickID = @GUI_CtrlId Then _ButtonHit() $LastClickID = @GUI_CtrlId $LastClickTime = TimerInit() EndFunc ;==>_LVHit Func _ButtonHit() GUICtrlSetData($input1, GUICtrlRead(GUICtrlRead($listview))) EndFunc ;==>_ButtonHit Func _Quit() Exit EndFunc ;==>_Quit Is there a faster/more-reliable way to do the double-click detection? Edited July 26, 2007 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...
PsaltyDS Posted July 26, 2007 Author Share Posted July 26, 2007 (edited) http://www.autoitscript.com/forum/index.ph...;hl=DoubleClick Doesn't work for me. Did it work when you ran that code? I modified it slightly to give me some more debug info: expandcollapse popup#include <GUIConstants.au3> Opt("MustDeclareVars", 1) Global Const $DebugIt = 1 Global Const $WM_COMMAND = 0x0111 Global $Hovered = 0 Global $Button, $status _Main() Func _Main() Local $x = 48, $y = 88, $msg, $Form2 $Form2 = GUICreate("Blash", 716, 561, 155, 134, BitOR($WS_MAXIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_TABSTOP)) $Button = GUICtrlCreateButton("Button Test", 10, 10, 89, 41) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc ;==>_Main Func Button_Click(ByRef $ctrl_id) ;~ _DebugPrint("Button_Click") EndFunc ;==>Button_Click Func Button_DblClick(ByRef $ctrl_id) ;~ _DebugPrint("Button_DblClick") MsgBox(0, "Test", "Button_DblClick") EndFunc ;==>Button_DblClick Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam) ConsoleWrite(@MIN & ":" & @SEC & " Debug: MY_WM_COMMAND(" & $hWnd & ", " & $msg & ", " & $wParam & ", " & $lParam & ") called" & @LF) Local Const $BN_CLICKED = 0; Local Const $BN_PAINT = 1; Local Const $BN_HILITE = 2; Local Const $BN_PUSHED = $BN_HILITE; Local Const $BN_UNHILITE = 3; Local Const $BN_UNPUSHED = $BN_UNHILITE; Local Const $BN_DISABLE = 4; Local Const $BN_DOUBLECLICKED = 5; Local Const $BN_DBLCLK = $BN_DOUBLECLICKED; Local Const $BN_SETFOCUS = 6; Local Const $BN_KILLFOCUS = 7; Local $nNotifyCode = _HiWord($wParam) ConsoleWrite(@MIN & ":" & @SEC & " Debug: $nNotifyCode = " & $nNotifyCode & @LF) Local $nID = _LoWord($wParam) ConsoleWrite(@MIN & ":" & @SEC & " Debug: $nID = " & $nID & @LF) Local $hCtrl = $lParam If $nID <> 2 Then Switch $nNotifyCode Case $BN_CLICKED ;~ _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hwnd & @LF & _ ;~ "MsgID" & @TAB & ":" & $Msg & @LF & _ ;~ "wParam" & @TAB & ":" & $wParam & @LF & _ ;~ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ ;~ "WM_COMMAND - Infos:" & @LF & _ ;~ "-----------------------------" & @LF & _ ;~ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ ;~ "CtrlID" & @TAB & ":" & $nID & @LF & _ ;~ "CtrlHWnd" & @TAB & ":" & $hCtrl) ;~ Button_Click ($nID) Case $BN_PAINT _DebugPrint("$BN_PAINT") Case $BN_PUSHED, $BN_HILITE _DebugPrint("$BN_PUSHED, $BN_HILITE") Case $BN_UNPUSHED, $BN_UNHILITE _DebugPrint("$BN_UNPUSHED") Case $BN_DISABLE _DebugPrint("$BN_DISABLE") Case $BN_DBLCLK, $BN_DOUBLECLICKED ;~ _DebugPrint("$BN_DBLCLK, $BN_DOUBLECLICKED") _DebugPrint("$BN_CLICKED: " & @LF & "GUIHWnd" & @TAB & ":" & $hWnd & @LF & _ "MsgID" & @TAB & ":" & $msg & @LF & _ "wParam" & @TAB & ":" & $wParam & @LF & _ "lParam" & @TAB & ":" & $lParam & @LF & @LF & _ "WM_COMMAND - Infos:" & @LF & _ "-----------------------------" & @LF & _ "Code" & @TAB & ":" & $nNotifyCode & @LF & _ "CtrlID" & @TAB & ":" & $nID & @LF & _ "CtrlHWnd" & @TAB & ":" & $hCtrl) Button_DblClick($nID) Case $BN_SETFOCUS _DebugPrint("$BN_SETFOCUS") Case $BN_KILLFOCUS _DebugPrint("$BN_KILLFOCUS") EndSwitch EndIf ; Proceed the default Autoit3 internal message commands. ; You also can complete let the line out. ; !!! But only 'Return' (without any value) will not proceed ; the default Autoit3-message in the future !!! Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Func _DebugPrint($s_text) $s_text = StringReplace($s_text, @LF, @LF & "-->") ConsoleWrite( _ "!===========================================================" & @LF & _ "+===========================================================" & @LF & _ "-->" & $s_text & @LF & _ "+===========================================================" & @LF) EndFunc ;==>_DebugPrint And this is the output I got: +>17:17:39 Starting AutoIt3Wrapper v.1.8.3 >Running AU3Check (1.54.7.0) from:C:\Program Files\AutoIt3 +>17:17:39 AU3Check ended.rc:0 >Running:(3.2.4.9):C:\Program Files\AutoIt3\autoit3.exe "C:\Temp\Test\Test1.au3" 17:41 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 17:41 Debug: $nNotifyCode = 0 17:41 Debug: $nID = 3 17:41 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 17:41 Debug: $nNotifyCode = 0 17:41 Debug: $nID = 3 17:53 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 17:53 Debug: $nNotifyCode = 0 17:53 Debug: $nID = 3 17:53 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 17:53 Debug: $nNotifyCode = 0 17:53 Debug: $nID = 3 17:56 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 17:56 Debug: $nNotifyCode = 0 17:56 Debug: $nID = 3 17:57 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 17:57 Debug: $nNotifyCode = 0 17:57 Debug: $nID = 3 18:00 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 18:00 Debug: $nNotifyCode = 0 18:00 Debug: $nID = 3 18:00 Debug: MY_WM_COMMAND(0x00B401E6, 273, 0x00000003, 0x011E015A) called 18:00 Debug: $nNotifyCode = 0 18:00 Debug: $nID = 3 +>17:18:05 AutoIT3.exe ended.rc:0 +>17:18:06 AutoIt3Wrapper Finished >Exit code: 0 Time: 27.893 If I single click, I get $nNotifyCode = 0 and $nID = 3. If I double click, I just get two of the same... Gary, where are you? Edited February 1, 2008 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...
PsaltyDS Posted July 26, 2007 Author Share Posted July 26, 2007 This one worked... you'll never believe who started the topic evenDarned good looking fellow too, isn't he? That one works for me too.. obviously fell into one of the holes in the swiss cheese brain! 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...
GaryFrost Posted July 26, 2007 Share Posted July 26, 2007 $Button = GUICtrlCreateButton("Button Test", 10, 10, 89, 41, $BS_NOTIFY) SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 26, 2007 Author Share Posted July 26, 2007 $Button = GUICtrlCreateButton("Button Test", 10, 10, 89, 41, $BS_NOTIFY) Sure enough, that change gives me $nNotifyCode = 5 for double-click. And the other post's code works for a ListViewItem. After some study to commit it to LONG TERM memory this time, I should be set! Thanks! 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...
John117 Posted July 27, 2007 Share Posted July 27, 2007 (edited) Can this be set up for a list item to detect a double click or single click? (I think yes per your debug return, but want to make sure I understand) Purpose being: A list item is single clicked to alter one part of a GUI that displays info about that list item. (when you change list items, new item specific info is displayed) On double click, a child opens that references that list item. (My case being a message box for a userid that is the list item) Edited July 27, 2007 by Hatcheda Link to comment Share on other sites More sharing options...
John117 Posted July 27, 2007 Share Posted July 27, 2007 (edited) To answer my own question . . . Here is the result. I would like this as simple as possible. Can anyone tell me if I left anything in that could have came out and still work? Thanks! CODE#include <GuiConstants.au3> Opt("MustDeclareVars", 1) Global Const $WM_COMMAND = 0x0111 Global $Button, $status, $Edit1 _Main() Func _Main() Local $x = 48, $y = 88, $msg, $Form2 $Form2 = GUICreate("Blash", 716, 561, 155, 134) $Edit1 = GUICtrlCreateEdit("Type Message Here", 10, 30, 230, 60, $ES_WANTRETURN) $Button = GUICtrlCreateButton("Button Test", 10, 100, 89, 41, $BS_NOTIFY) GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND") GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd EndFunc ;==>_Main Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc ;==>_LoWord Func _HiWord($x) Return BitShift($x, 16) EndFunc ;==>_HiWord Func MY_WM_COMMAND($hWnd, $msg, $wParam) Local Const $BN_CLICKED = 0; Local Const $BN_DOUBLECLICKED = 5; Local Const $BN_DBLCLK = $BN_DOUBLECLICKED; Local $nID = _LoWord($wParam) Local $nNotifyCode = _HiWord($wParam) If $nID <> 2 Then Switch $nNotifyCode Case $BN_CLICKED GUICtrlSetData($Edit1, (GUICtrlRead($Edit1)+1)) Case $BN_DBLCLK, $BN_DOUBLECLICKED MsgBox(0, "Double", "Click") EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ;==>MY_WM_COMMAND Edit: Granted it's with buttons, for now! Edited July 27, 2007 by Hatcheda 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