MrCreatoR Posted January 14, 2008 Posted January 14, 2008 (edited) Hi, I need to call some function while user is selecting listview items, i know that there is $LVN_MARQUEEBEGIN event, but that's only when user starts to select, and i need to catch the period of time that user actualy selecting the items... Somethink like this: expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> GUICreate("LV Get Selected Notification", 400, 300) $hListView = GUICtrlCreateListView("Column1|Column2", 2, 2, 394, 268, $LVS_SHOWSELALWAYS) GUICtrlCreateListViewItem("Item1|SubItem1", $hListView) GUICtrlCreateListViewItem("Item2|SubItem2", $hListView) $Status_Mark = 0 $Status_Label = GUICtrlCreateLabel("", 20, 280, 200) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While GUIGetMsg() <> $GUI_EVENT_CLOSE If $Status_Mark = 1 Then GUICtrlSetData($Status_Label, "") $Status_Mark = 0 EndIf WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $NM_CUSTOMDRAW ;If $Status_Mark = 0 Then GUICtrlSetData($Status_Label, "Selecting....") ;$Status_Mark = 1 ;EndIf Case $LVN_MARQUEEBEGIN ConsoleWrite("Selecting BEGIN" & @LF) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Now the status update once we hovering the items, if we uncomment the lines with $Status_Mark, it will updated only while we selecting the items, but i need that this will happen without any "marks" and only by notification, so my function will not bein called when it's not needed. Is it possible? Thanks. Edited January 15, 2008 by MsCreatoR Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
GaryFrost Posted January 14, 2008 Posted January 14, 2008 $LVN_ITEMCHANGED SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
MrCreatoR Posted January 15, 2008 Author Posted January 15, 2008 Thanks.But this event is called even if i press on item/check item, and i need only when the selecting box is there (user selecting items)... Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Siao Posted January 15, 2008 Posted January 15, 2008 (edited) but i need that this will happen without any "marks" and only by notificationSo does this mean when converted to human language, that you don't want to use global variable?Because if doesn't, set the global flag upon LVN_MARQUEEBEGIN, reset it upon NM_RELEASEDCAPTURE. Process the item change notifications only if flag is set. Edited January 15, 2008 by Siao "be smart, drink your wine"
MrCreatoR Posted January 15, 2008 Author Posted January 15, 2008 set the global flag upon LVN_MARQUEEBEGIN, reset it upon NM_RELEASEDCAPTURE. Process the item change notifications only if flag is setIt work, but only if i call the function from the WM_NOTIFY, and i can not do that, because the called function trigger many operations, it's slowing down the main handler process, and the selection is bein a little ugly expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> Global $IsSelectingBegin = False GUICreate("LV Get Selected Notification", 400, 300) $hListView = GUICtrlCreateListView("Column1|Column2", 2, 2, 394, 268, $LVS_SHOWSELALWAYS) GUICtrlCreateListViewItem("Item1|SubItem1", $hListView) GUICtrlCreateListViewItem("Item2|SubItem2", $hListView) $Status_Label = GUICtrlCreateLabel("", 20, 280, 200) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While GUIGetMsg() <> $GUI_EVENT_CLOSE If Not $IsSelectingBegin Then GUICtrlSetData($Status_Label, "") Else ;uncomment this, and... (see WM_NOTIFY -> $LVN_MARQUEEBEGIN) ;MyFunc() EndIf WEnd Func MyFunc() GUICtrlSetData($Status_Label, "Selecting....") EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_MARQUEEBEGIN $IsSelectingBegin = True MyFunc() ;...comment this Case $NM_RELEASEDCAPTURE $IsSelectingBegin = False EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc It works as you can see, but then follow the comments, and you will see that this will not work Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Siao Posted January 15, 2008 Posted January 15, 2008 GUI is "frozen" as long as a mouse button is down (aka capture), so you won't ever get what you want to work from the main loop. "be smart, drink your wine"
MrCreatoR Posted January 15, 2008 Author Posted January 15, 2008 GUI is "frozen" as long as a mouse button is down (aka capture), so you won't ever get what you want to work from the main loop.You right, thanks I figured this out using cakllback timer expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> Global $IsSelectingBegin = False Global $ah_Timer GUICreate("LV Get Selected Notification", 400, 300) $hListView = GUICtrlCreateListView("Column1|Column2", 2, 2, 394, 268, $LVS_SHOWSELALWAYS) GUICtrlCreateListViewItem("Item1|SubItem1", $hListView) GUICtrlCreateListViewItem("Item2|SubItem2", $hListView) $Status_Label = GUICtrlCreateLabel("", 20, 280, 200) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Func MyFunc($hWnd, $iMsg, $iwParam, $ilParam) If GUICtrlRead($Status_Label) <> "Selecting...." Then GUICtrlSetData($Status_Label, "Selecting....") EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_MARQUEEBEGIN If Not $IsSelectingBegin Then $ah_Timer = _TimerStart("MyFunc", 10) $IsSelectingBegin = True EndIf Case $NM_RELEASEDCAPTURE If $IsSelectingBegin Then _TimerStop($ah_Timer[0], $ah_Timer[1]) $IsSelectingBegin = False GUICtrlSetData($Status_Label, "") EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _TimerStart($sFunction, $iTime=250) Local $hCallBack = DllCallbackRegister($sFunction, "none", "hwnd;int;int;dword") Local $aDll = DllCall("user32.dll", "int", "SetTimer", _ "hwnd", 0, _ "int", TimerInit(), _ "int", $iTime, _ "ptr", DllCallbackGetPtr($hCallBack)) Local $aRet[2] = [$hCallBack, $aDll[0]] Return $aRet EndFunc Func _TimerStop($hCallBack, $hTimer) DllCallBackFree($hCallBack) Local $aRet = DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $hTimer) Return $aRet[0] EndFunc Thanks Gary and Siao for your help! I think the issue is [sOLVED] Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
MrCreatoR Posted January 15, 2008 Author Posted January 15, 2008 Here is an example of what i really needed at the end: expandcollapse popup#include <GuiConstants.au3> #include <GuiListView.au3> Global $IsSelectingBegin = False Global $ah_Timer GUICreate("LV Get Selected Notification", 400, 300) $hListView = GUICtrlCreateListView("Column1|Column2", 5, 5, 390, 150, $LVS_SHOWSELALWAYS) GUICtrlCreateListViewItem("Item1|SubItem1", $hListView) GUICtrlCreateListViewItem("Item2|SubItem2", $hListView) GUICtrlCreateLabel("Selection:", 5, 165) GUICtrlSetFont(-1, 9, 800) $Selection_Edit = GUICtrlCreateEdit("", 5, 180, 390, 110) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While GUIGetMsg() <> $GUI_EVENT_CLOSE WEnd Func MyFunc($hWnd, $iMsg, $iwParam, $ilParam) Local $aSelected_Indices = _GUICtrlListView_GetSelectedIndices($hListView, 1) Local $sSelected_Items = "" Local $sEdit_Content = GUICtrlRead($Selection_Edit) For $i = 1 To UBound($aSelected_Indices)-1 $sSelected_Items &= _GUICtrlListView_GetItemText($hListView, $aSelected_Indices[$i]) & @CRLF Next $sSelected_Items = StringStripWS($sSelected_Items, 3) If $sEdit_Content <> $sSelected_Items Then GUICtrlSetData($Selection_Edit, $sSelected_Items) EndFunc Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_MARQUEEBEGIN If Not $IsSelectingBegin Then $ah_Timer = _TimerStart("MyFunc", 10) $IsSelectingBegin = True EndIf Case $NM_RELEASEDCAPTURE If $IsSelectingBegin Then _TimerStop($ah_Timer[0], $ah_Timer[1]) $IsSelectingBegin = False GUICtrlSetData($Selection_Edit, "") EndIf EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func _TimerStart($sFunction, $iTime=250) Local $hCallBack = DllCallbackRegister($sFunction, "none", "hwnd;int;int;dword") Local $aDll = DllCall("user32.dll", "int", "SetTimer", _ "hwnd", 0, _ "int", TimerInit(), _ "int", $iTime, _ "ptr", DllCallbackGetPtr($hCallBack)) Local $aRet[2] = [$hCallBack, $aDll[0]] Return $aRet EndFunc Func _TimerStop($hCallBack, $hTimer) DllCallBackFree($hCallBack) Local $aRet = DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "int", $hTimer) Return $aRet[0] EndFunc Spoiler Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1 AutoIt Russian Community My Work... Spoiler Projects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize ProgramUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF Examples: ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating ) * === My topics === * ================================================== ================================================== AutoIt is simple, subtle, elegant. © AutoIt Team
Xandl Posted January 15, 2008 Posted January 15, 2008 Hello, this is a nice solution, but I really would like to have an event driven way, where the listview id can be local, and does not have to be in the global scope. I read something about user parameters for callbacks, but I am neither sure if it would help, nor if it is going to be implemented. ciao Xandl
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