Sign in to follow this  
Followers 0
goldenix

[solved] GUI_UN_RegisterMsg Question

6 posts in this topic

#1 ·  Posted (edited)

Hi

I have this script where you can drag & drop files into. & it tooltips you the filepath.

All is nice & works, but I would like to exit the script after it has shown me all processed files.

But I dont understand how does it work. You see, the sleep is above all the functions so after it processes the file it should exit, but it does not. so im confused.

simply put: exit script after it shows you all dropped filepaths.

can someone explain this ?

Global $File, $GUI

Opt("GUIOnEventMode", 1)

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate('Renamer', 139, 97, -1, -1,-1,$WS_EX_ACCEPTFILES)
    GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

GUIRegisterMsg(0x233, "On_WM_DROPFILES")
GUISetOnEvent($GUI_EVENT_CLOSE, "_exit")

While 1
    Sleep(100)
WEnd


Func On_WM_DROPFILES($hWnd, $Msg, $wParam, $lParam)
    Local $tDrop, $aRet, $iCount
    ;string buffer for file path
    $tDrop = DllStructCreate("char[260]")
    ;get file count
    $aRet = DllCall("shell32.dll", "int", "DragQueryFile", _
                                            "hwnd", $wParam, _
                                            "uint", -1, _
                                            "ptr", DllStructGetPtr($tDrop), _
                                            "int", DllStructGetSize($tDrop) _
                                            )
    $iCount = $aRet[0]
    ;get file paths
    For $i = 0 To $iCount-1
        $aRet = DllCall("shell32.dll", "int", "DragQueryFile", _
                                                "hwnd", $wParam, _
                                                "uint", $i, _
                                                "ptr", DllStructGetPtr($tDrop), _
                                                "int", DllStructGetSize($tDrop) _
                                                )

        $File = DllStructGetData($tDrop, 1)
        _move()
    Next
    ;finalize
    DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam)
    Return
EndFunc

Func _move()

    ToolTip('Working...' & $File,0,0)

    Sleep(500)

    ToolTip('')
EndFunc

Func _exit()
    Exit
EndFunc
Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites



Global $Quit = False

...

While 1
    Sleep(100)
    If $Quit Then
        ExitLoop
    EndIf
WEnd

Func On_WM_DROPFILES($hWnd, $Msg, $wParam, $lParam)
    
    ...
    
    $Quit = True
    Return
EndFunc

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

It works, thanx.

But why does it work ? I mean for each file On_WM_DROPFILES() function is called but meanwhile its looping while 1 loop, so if you call the function once $Quit is set to True & it should exit after processing first file.

Why doesnt it?

Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

It works, thanx.

But why does it work ? I mean for each file On_WM_DROPFILES() function is called but meanwhile its looping while 1 loop, so if you call the function once $Quit is set to True & it should exit after processing first file.

Why doesnt it?

On_WM_DROPFILES() is not called for each file, it calls for all files that you dragged.

Share this post


Link to post
Share on other sites

aa i see so I can simply put instead, thanx

;finalize
    DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam)
    _exit()
    Return

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites

aa i see so I can simply put instead, thanx

;finalize
    DllCall("shell32.dll", "int", "DragFinish", "hwnd", $wParam)
    _exit()
    Return

Of course it works, but quit from the program directly from the interrupt function is not a good idea.

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