borreo 2 Posted January 13 Share Posted January 13 I would like to add to most of my scripts a status window that stays always on top, but never gets activated. I wrote a sample script to show what I mean: it just keeps typing an A every 3 seconds (just as a proof of concept); the status window displays the countdown, and stops the script when the status window is closed. I run the script, then open a blank file on a text editor (activating it) and wait for the A to appear. Everything works, except that the status window does not come to the front. I tried different parameters to GuiSetState, but no luck. What shoudl I do? #include <GUIConstants.au3> $Main = GUICreate("StatusBar GUI") $label = GUICtrlCreateLabel("Default StatusBar Text", 0, 380, 400, 20, $SS_SUNKEN + $SS_CENTER) ;GUISetState (@SW_SHOWNOACTIVATE) $NextPause = 3 While 1 ;GUISetState (@SW_SHOWNOACTIVATE) GUISetState (@SW_SHOWNA) GUICtrlSetData($label, $NextPause) Sleep( 1000 ) ; If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop $NextPause = $NextPause - 1 If $NextPause <= 0 Then Send( "A" ) $NextPause = 3 EndIf Wend Link to post Share on other sites
SOLVE-SMART 110 Posted January 13 Share Posted January 13 Hi @borreo, please have a look at: GUISetStyle(-1, $WS_EX_TOPMOST, $Main) for your example case. This should set your status window to the top (in the foreground). Besides that, I suggest you to refactor your code 😅 . Best regards Sven Stay innovative! Spoiler 🌍 Au3Forums 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔍 Forum search 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to post Share on other sites
borreo 2 Posted January 13 Author Share Posted January 13 It is not working, the windows stays behind #include <GUIConstants.au3> $Main = GUICreate("StatusBar GUI") $label = GUICtrlCreateLabel("Default StatusBar Text", 0, 380, 400, 20, $SS_SUNKEN + $SS_CENTER) ;GUISetState (@SW_SHOWNOACTIVATE) $NextPause = 3 While 1 ;GUISetState (@SW_SHOWNOACTIVATE) GUISetState (@SW_SHOWNA) GUICtrlSetData($label, $NextPause) GUISetStyle(-1, $WS_EX_TOPMOST, $Main) Sleep( 1000 ) ; If GUIGetMsg() = $GUI_EVENT_CLOSE Then ExitLoop $NextPause = $NextPause - 1 If $NextPause <= 0 Then Send( "A" ) $NextPause = 3 EndIf Wend Link to post Share on other sites
SOLVE-SMART 110 Posted January 13 Share Posted January 13 No, please move the line under line 2 "$Main = ...", as line 3, then it should work. Best regardsSven Stay innovative! Spoiler 🌍 Au3Forums 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔍 Forum search 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to post Share on other sites
borreo 2 Posted January 13 Author Share Posted January 13 Well yes, it works, in the sense that it is opened on top. But if I manually click on another window, then the GUI window goes to the back. Is it possible to mark the window to always stay on top, whatever I click? Link to post Share on other sites
Solution Lepes 2 Posted January 13 Solution Share Posted January 13 this seems to work #include <GUIConstants.au3> $Main = GUICreate("StatusBar GUI", 380, 400,-1,-1, -1, $WS_EX_TOPMOST) $label = GUICtrlCreateLabel("Default StatusBar Text", 0, 380, 400, 20, $SS_SUNKEN + $SS_CENTER) GUISetState (@SW_SHOWNA, $Main) $NextPause = 3 While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then Exit GUICtrlSetData($label, $NextPause) Sleep( 1000 ) $NextPause = $NextPause - 1 If $NextPause <= 0 Then Send( "A" ) $NextPause = 3 EndIf Wend It is important to use @SW_SHOWNA or @SW_SHOWNOACTIVATE, if you use anything different, it seems to loose the TopMost feature (in my test, not sure why). borreo 1 Link to post Share on other sites
SOLVE-SMART 110 Posted January 13 Share Posted January 13 (edited) To be honest, I don't see the problem @borreo. Anyways, please try this and tell me please if this fits your expectations and requirements? By the way: No problem with @SW_SHOW 😀 . expandcollapse popup#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #AutoIt3Wrapper_Run_Au3Stripper=y #Au3Stripper_Parameters=/sf /sv /mo /rm /rsln #include <GUIConstants.au3> HotKeySet('{ESC}', '_DisposeAndExit') Global $hGui, $cLabel Global $iNextPause = 3 _CreateGui() While True _SetLabel() _WaitASecond() _DoSomething() Wend Func _CreateGui() $hGui = GUICreate('StatusBar GUI', 100, 100, Default, Default, -1, $WS_EX_TOPMOST) $cLabel = GUICtrlCreateLabel('Default StatusBar Text', 0, 80, Default, Default, $SS_SUNKEN + $SS_CENTER) GUISetState(@SW_SHOW, $hGui) EndFunc Func _DisposeAndExit() GUIDelete($hGui) Exit EndFunc Func _SetLabel() GUICtrlSetData($cLabel, $iNextPause) EndFunc Func _WaitASecond() Sleep(1000) EndFunc Func _DoSomething() $iNextPause -= 1 If $iNextPause <= 0 Then Send('A') $iNextPause = 3 EndIf EndFunc Best regards Sven Edited January 13 by SOLVE-SMART borreo 1 Stay innovative! Spoiler 🌍 Au3Forums 📊 AutoIt limits/defaults 💎 Code Katas: [...] (comming soon) 🎭 Collection of GitHub users with AutoIt projects 🐞 False-Positives 🔍 Forum search 🔮 Me on GitHub 💬 Opinion about new forum sub category 📑 UDF wiki list ✂ VSCode-AutoItSnippets 📑 WebDriver FAQs 👨🏫 WebDriver Tutorial (coming soon) Link to post Share on other sites
borreo 2 Posted January 13 Author Share Posted January 13 Thanks to both for the answers. They both work, sorry I can only accept one. Lepes and SOLVE-SMART 2 Link to post Share on other sites
marcus_tong 0 Posted January 18 Share Posted January 18 can you try this, WinSetOnTop it works for me. Link to post Share on other sites
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