Psychoman Posted January 25, 2011 Share Posted January 25, 2011 (edited) ContextAfter playing with AutoIt for some time I'm trying to get a window topmost.I'd like to get the same effect as AutoIt v3 Window Info with the flag Always On Top set.The window can be put on top of all other windows with a button.GUII have this window with 2 buttons on it.The first button Set window topmost will change the style of the window to make it topmost.The second button Set window normal will reset the style of the window.By default he window is not topmost.Source codeexpandcollapse popup; -------- ; Includes ; -------- #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; --------- ; Variables ; --------- Global $varWindow, $varButtonTopmost, $varButtonNormal, $varLoop, $varMessage ; ---- ; Main ; ---- $varWindow = GUICreate("Win", 130, 75) $varButtonTopmost = GUICtrlCreateButton("Set window topmost", 10, 10, 110) $varButtonNormal = GUICtrlCreateButton("Set window normal", 10, 40, 110) GUISetState(@SW_SHOW) $varLoop = True While $varLoop $varMessage = GUIGetMsg() Select Case $varMessage = $GUI_EVENT_CLOSE $varLoop = False Exit Case $varMessage == $varButtonTopmost _Button_Topmost_Clicked() Case $varMessage == $varButtonNormal _Button_Normal_Clicked() EndSelect WEnd ; --------- ; Functions ; --------- Func _Button_Topmost_Clicked() Local $varStyles = GUIGetStyle($varWindow) GUISetStyle($varStyles[0], BitOr($varStyles[1], $WS_EX_TOPMOST), $varWindow) EndFunc Func _Button_Normal_Clicked() Local $varStyles = GUIGetStyle($varWindow) GUISetStyle($varStyles[0], BitXor($varStyles[1], $WS_EX_TOPMOST), $varWindow) EndFuncQuestionThe source code above doesn't work.The window just won't be placed topmost.Could someone tell me why this code doesn't work?As I have been browsing and searching this forum forever help would greatly be appreciated. Edited January 26, 2011 by Psychoman Link to comment Share on other sites More sharing options...
kaotkbliss Posted January 25, 2011 Share Posted January 25, 2011 in your functions, instead of using guictrlsetstate, have you tried WinSetOnTop? Func _Button_Topmost_Clicked() WinSetOnTop($varWindow,"",1) EndFunc Func _Button_Normal_Clicked() WinSetOnTop($varWindow,"",0) EndFunc 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
jaberwacky Posted January 25, 2011 Share Posted January 25, 2011 (edited) kaotkbliss beat me to it! FOILED once again! Edited January 25, 2011 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
kaotkbliss Posted January 25, 2011 Share Posted January 25, 2011 Would have gotten away with it too if it weren't for those meddling kids, Jabberwocky? 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
ShawnW Posted January 25, 2011 Share Posted January 25, 2011 Umm so if you are able to click the button, would the window not already be on top? Link to comment Share on other sites More sharing options...
Psychoman Posted January 25, 2011 Author Share Posted January 25, 2011 in your functions, instead of using guictrlsetstate, have you tried WinSetOnTop? Actually I didn't. I came across this function on the forum and in the help files. The documentation states that the first parameter has to be the name of the window. WinSetOnTop ( "title", "text", flag ) It's true that if you follow the link in the documentation you get a description on how to use the title parameter. Although I took a look at that documentation I must have missed the last part, stating that the parameter title can be replaced with a handle. Now it works like a charm. Thanks a lot kaotkbliss Link to comment Share on other sites More sharing options...
kaotkbliss Posted January 25, 2011 Share Posted January 25, 2011 Umm so if you are able to click the button, would the window not already be on top?It changes the flag of the window1 being always on top so no matter if you click another window afterwards the other will still be on top 010101000110100001101001011100110010000001101001011100110010000 001101101011110010010000001110011011010010110011100100001 My Android cat and mouse gamehttps://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek We're gonna need another Timmy! Link to comment Share on other sites More sharing options...
jaberwacky Posted January 26, 2011 Share Posted January 26, 2011 Would have gotten away with it too if it weren't for those meddling kids, Jabberwocky?Next time, next time. Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
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