Hypertrophy Posted July 14, 2009 Share Posted July 14, 2009 Is it possible to have gui's stay on certain windows if assigned to them. im running a 3rd party application and i want my 32x32 guis to be able to stay on that window only, if specified too, meaning if another window pops up then ky 32x32 window(s) will disappear with the window they are on top of. is it possible to do this and is there any scripts like this already? i didn't have any luck with searching... Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 14, 2009 Moderators Share Posted July 14, 2009 Hypertrophy,When I did this a while ago I created my GUI with the TOPMOST attribute and then used the following code in the While...WEnd loop:; Create My_GUI and use TOPMOST Global $hMy_GUI = GUICreate("My GUI", ###, ###, ###, ###, -1, $WS_EX_TOPMOST) ;.... While 1 ; Other loop code ; Correct position of My_GUI if required If WinActive($hExternal_Wnd) Or WinActive($hMy_GUI) Then $aExternal_Pos = WinGetPos($hExternal_Wnd) If $aExternal_Pos[0] <> $iLast_X Or $aExternal_Pos[1] <> $iLast_Y Then $iLast_X = $aExternal_Pos[0] $iLast_Y = $aExternal_Pos[1] WinMove($hMy_GUI, "", "Set x/y parameters as required") EndIf EndIf ; Hide My_GUI when External not active If BitAND(WinGetState($hExternal_Wnd), 8) <> 8 And $fToolBar_Vis = True Then GUISetState(@SW_HIDE, $hMy_GUI) ElseIf BitAND(WinGetState($hExternal_Wnd), 8) = 8 And $fToolBar_Vis = False Then GUISetState(@SW_SHOW, $hMy_GUI) EndIf WEndI thought it worked pretty well. If your GUI has buttons or other controls, you may well need to add the following additional code to make sure the external GUI gets the focus back once you have clicked on your GUI:; Reactivate external when My_GUI is activated If WinActive($hMy_GUI) Then WinActivate($hExternal_Wnd) EndIfPlease ask if anything is unclear.M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 15, 2009 Author Share Posted July 15, 2009 (edited) Melba, looks promising. I can't understand where $fToolBar_Vis comes from though? Edit: Can't even run the script because I have no idea where that variable came from. Edited July 15, 2009 by Hypertrophy Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 15, 2009 Moderators Share Posted July 15, 2009 Hypertrophy,Apologies, I copied the snippet from another script and thought I had updated all the variables.The "unknown" variable is a flag to see if My_GUI is already visible. If you do not test for this, you can end up using GUISetState every time you loop - which leads to flickering. This is true for all controls you have to toggle in this manner and is a good tip.The amended script is as follows:; Create My_GUI and use TOPMOST Global $hMy_GUI = GUICreate("My GUI", ###, ###, ###, ###, -1, $WS_EX_TOPMOST) ; Set visible flag (assuming it is visible to begin with!) $fMy_GUI_Vis = True While 1 ; Other loop code ; Correct position of My_GUI if required If WinActive($hExternal_Wnd) Or WinActive($hMy_GUI) Then $aExternal_Pos = WinGetPos($hExternal_Wnd) If $aExternal_Pos[0] <> $iLast_X Or $aExternal_Pos[1] <> $iLast_Y Then $iLast_X = $aExternal_Pos[0] $iLast_Y = $aExternal_Pos[1] WinMove($hMy_GUI, "", "Set x/y parameters as required") ; You obviously use your own params here based on the position of the external GUI EndIf EndIf ; Hide My_GUI when External not active If BitAND(WinGetState($hExternal_Wnd), 8) <> 8 And $fMy_GUI_Vis = True Then GUISetState(@SW_HIDE, $hMy_GUI) $fMy_GUI_Vis = False ; Reset flag ElseIf BitAND(WinGetState($hExternal_Wnd), 8) = 8 And $fMy_GUI_Vis = False Then GUISetState(@SW_SHOW, $hMy_GUI) $fMy_GUI_Vis = True ; Reset flag EndIf WEndHope you can get it working this time. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 17, 2009 Author Share Posted July 17, 2009 #include <WindowsConstants.au3> #include <GUIConstants.au3> ; Create My_GUI and use TOPMOST Global $hMy_GUI = GUICreate("My GUI", 300, 300, 20, 20, -1, $WS_EX_TOPMOST) $pad = WinGetHandle("Untitled - Notepad","") ; Set visible flag (assuming it is visible to begin with!) $fMy_GUI_Vis = True While 1 ; Other loop code ; Correct position of My_GUI if required If WinActive("Untitled - Notepad") Or WinActive($hMy_GUI) Then $aExternal_Pos = WinGetPos("Untitled - Notepad") If $aExternal_Pos[0] <> $iLast_X Or $aExternal_Pos[1] <> $iLast_Y Then $iLast_X = $aExternal_Pos[0] $iLast_Y = $aExternal_Pos[1] WinMove($hMy_GUI, "", 20, 20) EndIf EndIf ; Hide My_GUI when External not active If BitAND(WinGetState($pad), 8) <> 8 And $fMy_GUI_Vis = True Then GUISetState(@SW_HIDE, $hMy_GUI) ElseIf BitAND(WinGetState($pad), 8) = 8 And $fMy_GUI_Vis = False Then GUISetState(@SW_SHOW, $hMy_GUI) EndIf WEnd That's what everything looks like. Whenever I activate notepad after running your script I get an error on line 19 saying variable used without being declared? Pointing to $iLast_X. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2009 Moderators Share Posted July 17, 2009 Hypertrophy, That is what you get when you extract code from another script and do not check it first - missing declarations. This code works for me: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Run("Notepad") WinWaitActive("Untitled - Notepad") ; Create My_GUI and use TOPMOST Global $hMy_GUI = GUICreate("My GUI", 300, 300, 20, 20, -1, $WS_EX_TOPMOST) GUISetState(@SW_HIDE) ; Set visible flag (assuming it is visible to begin with!) Global $fMy_GUI_Vis = False ; Declare last position variables Global $iLast_X = 0 Global $iLast_Y = 0 While 1 ; Other loop code If GUIGetMsg() = $GUI_EVENT_CLOSE Then Exit ; Correct position of My_GUI if required If WinActive("Untitled - Notepad") Or WinActive($hMy_GUI) Then $aExternal_Pos = WinGetPos("Untitled - Notepad") If $aExternal_Pos[0] <> $iLast_X Or $aExternal_Pos[1] <> $iLast_Y Then $iLast_X = $aExternal_Pos[0] $iLast_Y = $aExternal_Pos[1] WinMove($hMy_GUI, "", $aExternal_Pos[0] + 40, $aExternal_Pos[1] + 60) EndIf EndIf ; Hide My_GUI when External not active If BitAND(WinGetState("Untitled - Notepad"), 8) <> 8 And $fMy_GUI_Vis = True Then GUISetState(@SW_HIDE, $hMy_GUI) $fMy_GUI_Vis = False ElseIf BitAND(WinGetState("Untitled - Notepad"), 8) = 8 And $fMy_GUI_Vis = False Then GUISetState(@SW_SHOW, $hMy_GUI) $fMy_GUI_Vis = True EndIf ; Reactivate External when My_GUI is activated If WinActive($hMy_GUI) Then WinActivate("Untitled - Notepad") EndIf WEnd M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 17, 2009 Author Share Posted July 17, 2009 Melba thank you. this works very good. Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 17, 2009 Author Share Posted July 17, 2009 Where would I put the $WS_EX_TOPMOST attribute if my window creation looked like this? GUICreate("", 24, 24, $aMainGUI_Pos[0] + $ipos[0] + 5, $aMainGUI_Pos[1] + $ipos[1] + 50, _ $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED)) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted July 17, 2009 Moderators Share Posted July 17, 2009 Hypertrophy,It is an extended style, so just BitOR it with the others:BitOR($WS_EX_TOOLWINDOW, $WS_EX_LAYERED, $WS_EX_TOPMOST)Nice to see that you are BitORing styles. Sometimes simple adding works, but not always - which can cause a lot of headscratching (I speak from bitter experience here!).M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Hypertrophy Posted July 17, 2009 Author Share Posted July 17, 2009 lol, thanks. 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