Josbe Posted October 6, 2004 Posted October 6, 2004 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 AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
Administrators Jon Posted October 7, 2004 Author Administrators Posted October 7, 2004 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. expandcollapse popup#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 Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Valik Posted October 7, 2004 Posted October 7, 2004 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.
this-is-me Posted October 7, 2004 Posted October 7, 2004 @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?
jpm Posted October 8, 2004 Posted October 8, 2004 @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.
Valik Posted October 8, 2004 Posted October 8, 2004 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 EndFuncThen 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.
jpm Posted October 8, 2004 Posted October 8, 2004 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 EndFuncThen 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.
ezzetabi Posted October 8, 2004 Posted October 8, 2004 ... What about the option GUITaskbarEntry? How can I hide the taskbar now?
Administrators Jon Posted October 8, 2004 Author Administrators Posted October 8, 2004 ... 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". Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Valik Posted October 8, 2004 Posted October 8, 2004 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.
Administrators Jon Posted October 8, 2004 Author Administrators Posted October 8, 2004 I've never actually been that keen that users know of the hidden window tbh... Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Josbe Posted October 8, 2004 Posted October 8, 2004 or just a @hWnd macro<{POST_SNAPBACK}>Yes! AUTOIT > AutoIt docs / Beta folder - AutoIt latest beta
CyberSlug Posted October 8, 2004 Posted October 8, 2004 Is there any reason GuiSendMsg and GuiRecvMsg were not renamed to GuiCtrlSendMsg and GuiCtrlSendMsg? I prefer the shorter name, but it seems the longer name would be more consistent Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
this-is-me Posted October 8, 2004 Posted October 8, 2004 @larry, do you mean @GUI_WINHANDLE ? Who else would I be?
Valik Posted October 8, 2004 Posted October 8, 2004 @larry, do you mean @GUI_WINHANDLE ?<{POST_SNAPBACK}>No, we are talking about the hidden AutoIt window, not any user-created GUI windows.
piccaso Posted October 9, 2004 Posted October 9, 2004 (edited) im using this udfFunc _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 October 9, 2004 by piccaso CoProc Multi Process Helper libraryTrashBin.nfshost.com store your AutoIt related files here!AutoIt User Map
Administrators Jon Posted October 11, 2004 Author Administrators Posted October 11, 2004 Updated: - GuiSetOnEvent docs (thanks JP) - GuiGetCursorInfo() now returns the ID of the control it is over (or 0 if none) Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/
Chris_1013 Posted October 11, 2004 Posted October 11, 2004 Just went to use this function un-documented. This'll help, and makes sooo much more sense to me to code this way.
jpm Posted October 11, 2004 Posted October 11, 2004 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
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