lark Posted July 17, 2012 Posted July 17, 2012 Hello everyone. I have run into a problem that is somewhere along the lines of GUISetStyle() does not really function as it should. In one of my programs, I had $WS_EX_TOPMOST as the extended style of the GUI. When I added functionality for a tray item to change whether or not the GUI had this style applied, I found that GUISetStyle did not do anything. Maybe I did something wrong? But then, I set up a test program and found that if I created the GUI without setting the style, and then using GUISetStyle() right afterwards, nothing happened (the GUI did not stay on top of the other windows). Here is the test program that I used. Did I use the function wrong, or why is the style not being set? Thanks. Here is the program: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Constants.au3> Opt("TrayMenuMode", 1) Opt("TrayOnEventMode", 1) TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "trayExit") TrayCreateItem("Keep GUI On Top of Other Windows") TrayItemSetState(-1, $TRAY_CHECKED) TrayItemSetOnEvent(-1, "trayKeepGUIOnTop") Global $boolKeepGUIOnTop = True Global $hForm = GUICreate("Lark Autoclicker", 580, 550) ConsoleWrite(GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), $WS_EX_TOPMOST, $hForm) & @CRLF & @CRLF) GUISetState() Do Until GUIGetMsg() = -3 Func trayKeepGUIOnTop() If $boolKeepGUIOnTop Then; if its true then set it to false and get rid of the style of the GUI ConsoleWrite("true" & @CRLF) $boolKeepGUIOnTop = False ConsoleWrite(GUISetStyle(BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU), 0) & @CRLF & @CRLF); set the GUI to its default style Else ConsoleWrite("false" & @CRLF) $boolKeepGUIOnTop = True; its false so set it to true GUISetStyle(-1, $WS_EX_TOPMOST); set the GUI to stay on top EndIf EndFunc Func trayExit(); for the tray item "Exit" Exit EndFunc
bogQ Posted July 17, 2012 Posted July 17, 2012 (edited) Isnt $WS_EX_TOPMOST used for Guis when creating more than 1 Gui to set on top of other gui or not?if your looking to set on top useWinSetOnTop($hForm, "", 1)play around with#include <Constants.au3> #include <WindowsConstants.au3> Opt("TrayMenuMode", 1) Opt("TrayOnEventMode", 1) TrayCreateItem("Exit") TrayItemSetOnEvent(-1, "trayExit") TrayCreateItem("Keep GUI On Top of Other Windows") TrayItemSetState(-1, $TRAY_CHECKED) TrayItemSetOnEvent(-1, "trayKeepGUIOnTop") Global $boolKeepGUIOnTop = True Global $hForm = GUICreate("Lark Autoclicker1", 580, 550) Global $hForm1 = GUICreate("Lark Autoclicker2", 580, 550) GUISetState(@SW_SHOW,$hForm) GUISetState(@SW_SHOW,$hForm1) GUISetStyle(-1, $WS_EX_TOPMOST,$hForm1) Do Until GUIGetMsg() = -3 Func trayKeepGUIOnTop() If $boolKeepGUIOnTop Then; if its true then set it to false and get rid of the style of the GUI $boolKeepGUIOnTop = False ;~ WinSetOnTop($hForm, "", 0) Else $boolKeepGUIOnTop = True; its false so set it to true ;~ WinSetOnTop($hForm, "", 1) EndIf EndFunc ;==>trayKeepGUIOnTop Func trayExit(); for the tray item "Exit" Exit EndFunc ;==>trayExitchange fromGUISetStyle(-1, $WS_EX_TOPMOST,$hForm1)toGUISetStyle(-1, $WS_EX_TOPMOST,$hForm)for effect Edited July 17, 2012 by bogQ TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
lark Posted July 17, 2012 Author Posted July 17, 2012 WinSetOnTop() is just what I needed. Thanks bogQ
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