Sign in to follow this  
Followers 0
MrCreatoR

GUIRegisterMsg Problem

4 posts in this topic

#1 ·  Posted (edited)

Hi all,

My problem is with GUIRegisterMsg() func.. I create a parent Gui, then i register a message for it (WM_NOTIFY_EVENTS), i also have child Gui (as UDF), and that child is called by Hotkey, but when i call it quickly many times (just after closing it i call it again), the program is hangs up and you must then close the app.

Here is most closest example that reproduces this behaviour wich i can make, if you want to see the full script that have this issue, please look at Desktop Icons Restorator in my signature...

#include <GuiConstants.au3>
Opt('GuiOnEventMode', 1)

Global $Notify = False

$Gui = GuiCreate("Test", 400, 300)
GUISetOnEvent(-3, "Quit")

$LV = GUICtrlCreateListView("Column", 20, 20, 360, 250)
GUICtrlCreateListViewItem("Item", $LV)

GUIRegisterMsg(0x004E, "WM_NOTIFY_EVENTS")

GUISetState()

While 1
    Sleep(10)
    If WinExists($Gui) Then
        HotKeySet("^o", "CallChild")
    Else
        HotKeySet("^o")
    EndIf
    
    If $Notify Then
        $Notify = False
        ConsoleWrite("Double Click on LV Item" & @LF)
    EndIf
WEnd

Func CallChild()
    _ChildGui("Title", "Text", 300, 100, $Gui)
EndFunc

Func _ChildGui($Title,$Text,$Width,$Height,$hWnd=0)
    HotKeySet("^o")
    
    Local $Old_Opt_GOEM = Opt('GuiOnEventMode', 0)
    If $hWnd <> 0 Then WinSetState($hWnd, "", @SW_DISABLE)
    
    $Gui_MsgBox = GuiCreate($Title, $Width, $Height, -1, -1, -1, -1, $hWnd)
    
    GUISetState()
    
    While 1
        $Gui_Msg = GUIGetMsg()
        Select
            Case $Gui_Msg = -3
                ExitLoop
        EndSelect
    Wend
    
    If $hWnd <> 0 Then WinSetState($hWnd, "", @SW_ENABLE)
    GUIDelete($Gui_MsgBox)
    GUISwitch($hWnd)
    Opt('GuiOnEventMode', $Old_Opt_GOEM)
EndFunc

Func Quit()
    Exit
EndFunc

Func WM_NOTIFY_EVENTS($hWnd, $MsgID, $wParam, $lParam)
    If $hWnd <> $Gui Then Return $GUI_RUNDEFMSG
    Local $tagNMHDR = DllStructCreate("int;int;int", $lParam)
    If @error Then Return $GUI_RUNDEFMSG
    Local $Code = DllStructGetData($tagNMHDR, 3)
    If $wParam = $LV And $Code = -3 Then $Notify = True
    Return $GUI_RUNDEFMSG
EndFunc

Here i just run the script, and quickly press Ctrl o, sometimes it happend on the first try, but if you not lucky as i am, please move your mouse to the X button (closing button), then your second hand place over the Ctrl O hotkeys on your keyboard, and now just close the child Gui with the mose and very quickly press Ctrl O - the app is ok? not hangs? don't worry, try more couple of times, i sure you get lucky at the end :) (i am always do).

Can someone please tell my why this happend? and most important, is how to fix it (if it not an AutoIt bug).

Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites



Hi, as a guess (probly the wrong guess)

That would probly be because the notify event function has been called in the first instance then while in that function the Gui is sending another notify call before returning the control to back to the gui...

Share this post


Link to post
Share on other sites

Thanks for replying smashly.

I think if HotKeySet() will act just like regular event function, it probably will solve the issue...

Or maybe some one know how to fix the problem with current behaviour of the func? some workaround maybe?


 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: 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 Program

AutoIt_Icon_small.pngUDFs: 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
 
AutoIt_Icon_small.pngExamples: 
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 AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Share this post


Link to post
Share on other sites

Thanks for replying smashly.

I think if HotKeySet() will act just like regular event function, it probably will solve the issue...

Or maybe some one know how to fix the problem with current behaviour of the func? some workaround maybe?

There is an example of buffering hotkeys in my signature maybe that will help?

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0