Sign in to follow this  
Followers 0
Jon

v3.0.103 Unstable - Reloaded

221 posts in this topic

Updated:

- Fixed the flickering controls on state change (I think)

- Fixed the crash on minimize bug

- Add JPs doc updates.

<{POST_SNAPBACK}>

Thanks. Yeah, the flickering no longer is seen :)

Share this post


Link to post
Share on other sites



Updated some gui stuff.

The events/callbacks are no longer run through GuiGetMsg they are run independently. In order for this to work properly you put the script in EITHER normal msg mode (where you call GuiGetMsg regularly) or event mode where you set events/callbacks for everything and let the gui sort itself out.

New option: "GuiOnEventMode" which switches between the modes.

New function: "GuiSetOnEvent" which is the same as the control function except it is used for setting special events (GUI_EVENT_CLOSE, MINIMIZE, etc).

Not updated the docs yet - no time - but here is an example that should make things clear.

#include "GUIConstants.au3"

Opt("GUICoordMode",2)
Opt("GuiResizeMode", 1)
Opt("GuiOnEventMode", 1)

$parent1 = GuiCreate("Parent1")
GuiSetOnEvent($GUI_EVENT_CLOSE, "SpecialEvents")
GuiSetOnEvent($GUI_EVENT_MINIMIZE, "SpecialEvents")
GuiSetOnEvent($GUI_EVENT_RESTORE, "SpecialEvents")


$ok1 = GUICtrlCreateButton ("OK",  10, 30, 50)
GUICtrlSetOnEvent(-1, "OKPressed")

$cancel1 = GUICtrlCreateButton ( "Cancel",  0, -1)
GUICtrlSetOnEvent(-1, "CancelPressed")

GuiSetState(@SW_SHOW)


; Just idle around
While 1
    Sleep(10)
Wend


; END


Func OKPressed()
    MsgBox(0, "OK Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc


Func CancelPressed()
    MsgBox(0, "Cancel Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE & " CtrlHandle=" & @GUI_CTRLHANDLE)
EndFunc


Func SpecialEvents()
    

    Select
        Case @GUI_CTRLID = $GUI_EVENT_CLOSE
            MsgBox(0, "Close Pressed", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
            Exit
            
        Case @GUI_CTRLID = $GUI_EVENT_MINIMIZE
            MsgBox(0, "Window Minimized", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
            
        Case @GUI_CTRLID = $GUI_EVENT_RESTORE
            MsgBox(0, "Window Restored", "ID=" & @GUI_CTRLID & " WinHandle=" & @GUI_WINHANDLE)
            
    EndSelect
    
EndFunc

Share this post


Link to post
Share on other sites

Updated some gui stuff.

The events/callbacks are no longer run through GuiGetMsg they are run independently.  In order for this to work properly you put the script in EITHER normal msg mode (where you call GuiGetMsg regularly) or event mode where you set events/callbacks for everything and let the gui sort itself out.

New option: "GuiOnEventMode" which switches between the modes.

New function: "GuiSetOnEvent" which is the same as the control function except it is used for setting special events (GUI_EVENT_CLOSE, MINIMIZE, etc).

Not updated the docs yet - no time - but here is an example that should make things clear.

<snip>

<{POST_SNAPBACK}>

Thanks Jon. I've been waiting for this so I could finish cleaning up my GUI scripts.

Share this post


Link to post
Share on other sites

@Jon, You are the greatest. This will allow me to completely throw away my junky adlib code that I used for the guimsg stuff. I really appreciate it.


Who else would I be?

Share this post


Link to post
Share on other sites

@Jon, You are the greatest. This will allow me to completely throw away my junky adlib code that I used for the guimsg stuff. I really appreciate it.

<{POST_SNAPBACK}>

Great, great,...:)

I think we can add a GuiWaitClose instead of the loop and a GuiClose to be use by the onevent function is we want to terminate the GuiWaitClose.

GuiWaitClose can have a timeout as in WinWaitClose. :)

Share this post


Link to post
Share on other sites

Great, great,...:)

I think we can add a GuiWaitClose instead of the loop and a GuiClose to be use by the onevent function is we want to terminate the GuiWaitClose.

GuiWaitClose can have a timeout as in WinWaitClose.  :)

<{POST_SNAPBACK}>

If you add a GuiWaitClose(), I propose that it do something like this (This is an implementation in AutoIt):

Func GuiWaitClose($hWnd)
    While WinExists($hWnd)
        Sleep(100)
    Wend
EndFunc

Then in the $GUI_EVENT_CLOSE handler, simply calling GuiDelete() will destroy the window meaning the window with the HWND won't exist causing the loop to end. This would mean its not necessary for a new function to be added. It would also support multiple GUI's since the HWND to whichever GUI the user wants to wait on is passed as a parameter.

Share this post


Link to post
Share on other sites

If you add a GuiWaitClose(), I propose that it do something like this (This is an implementation in AutoIt):

Func GuiWaitClose($hWnd)
    While WinExists($hWnd)
        Sleep(100)
    Wend
EndFunc

Then in the $GUI_EVENT_CLOSE handler, simply calling GuiDelete() will destroy the window meaning the window with the HWND won't exist causing the loop to end.  This would mean its not necessary for a new function to be added.  It would also support multiple GUI's since the HWND to whichever GUI the user wants to wait on is passed as a parameter.

<{POST_SNAPBACK}>

I understand your point but my proposal was to get rid of the loop and to have as for win... functions a GuiWaitClose with timeout . The GuiClose was just a way to simulated an event inside an onevent handler. :)

Share this post


Link to post
Share on other sites

... What about the option GUITaskbarEntry?

How can I hide the taskbar now?

Share this post


Link to post
Share on other sites

... What about the option GUITaskbarEntry?

How can I hide the taskbar now?

Child windows don't have a taskbar entry, so create you main window, leave it hidden and then create the child window and use it as your "main".

Share this post


Link to post
Share on other sites

Jon, how about a new function:

AutoItWinGetHandle().

It would make it easier to create a child window since you could easily make the GUI a child of the hidden window.

GuiCreate("Window", -1, -1, -1, -1, -1, -1, AutoItWinGetHandle())

This should avoid the work-around of creating 2 windows and also make it a little bit easier and more reliable than using:

$parent = WinGetHandle(AutoItWinGetTitle())
GuiCreate("Window", -1, -1, -1, -1, -1, -1, $parent)

I can see that code getting screwed up because of multiple scripts running at once.

Share this post


Link to post
Share on other sites

@larry, do you mean @GUI_WINHANDLE ?


Who else would I be?

Share this post


Link to post
Share on other sites

@larry, do you mean @GUI_WINHANDLE ?

<{POST_SNAPBACK}>

No, we are talking about the hidden AutoIt window, not any user-created GUI windows.

Share this post


Link to post
Share on other sites

Ok.


Who else would I be?

Share this post


Link to post
Share on other sites

#77 ·  Posted (edited)

im using this udf

Func _AutoItWinGetHandle()
    Local $h, $t, $bt
    $t = Random(100000, 999999); Something unique
    $bt = AutoItWinGetTitle(); Backup old title
    AutoItWinSetTitle($t)    ; Set title to something unique
    $h = WinGetHandle($t)      ; Get the handle
    AutoItWinSetTitle($bt)   ; Restore old title
    Return $h
EndFunc

but a macro would be nice :)

... jeah i know Random(100000, 999999) isnt realy unique

Edited by piccaso

CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map

Share this post


Link to post
Share on other sites

Just went to use this function un-documented. This'll help, and makes sooo much more sense to me to code this way.

Share this post


Link to post
Share on other sites

Updated:

- GuiSetOnEvent docs (thanks JP)

- GuiGetCursorInfo() now returns the ID of the control it is over (or 0 if none)

<{POST_SNAPBACK}>

It's always a pleasure even without champagne

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