inm101 Posted December 3, 2010 Share Posted December 3, 2010 (edited) Is there a way to assign a specific window ("Window A") to always stay above another specific window ("Window B")? At the same time, I don't want Window A to be on top of all windows, just above Window B when it is maximized. Edited December 3, 2010 by inm101 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 3, 2010 Moderators Share Posted December 3, 2010 inm101,Look at _WinAPI_SetWindowPos in the Helpfile - the $hAfter parameter allows you to position the window just above another in the z-order. 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...
inm101 Posted December 3, 2010 Author Share Posted December 3, 2010 inm101,Look at _WinAPI_SetWindowPos in the Helpfile - the $hAfter parameter allows you to position the window just above another in the z-order. M23Thank you for the suggestion. I understand what you are saying, but I don't understand how to use it because the helpfile doesn't give an example of its usage like in the other help file topics. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 3, 2010 Moderators Share Posted December 3, 2010 inm101, Try something like this: ; You will need this at the top of your script #include <WinAPI.au3> ; Window B is already created and has handle $hGUI_B ; Create Window A $hGUI_A = GUICreate("GUI A", $iWidth, $iHeight, $iX, $iY) ; Now set it in z-order just above Window B _WinAPI_SetWindowPos($hGUI_A, $hGUI_B, $iX, $iY, $iWidth, $iHeight, $SWP_NOACTIVATE) ; And then show it GUISetState(@SW_SHOW, $hGUI_A) And that should do the trick. 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...
inm101 Posted December 3, 2010 Author Share Posted December 3, 2010 inm101, Try something like this: ; You will need this at the top of your script #include <WinAPI.au3> ; Window B is already created and has handle $hGUI_B ; Create Window A $hGUI_A = GUICreate("GUI A", $iWidth, $iHeight, $iX, $iY) ; Now set it in z-order just above Window B _WinAPI_SetWindowPos($hGUI_A, $hGUI_B, $iX, $iY, $iWidth, $iHeight, $SWP_NOACTIVATE) ; And then show it GUISetState(@SW_SHOW, $hGUI_A) And that should do the trick. M23 I think this is the magic line I'm after: _WinAPI_SetWindowPos($hGUI_A, $hGUI_B, $iX, $iY, $iWidth, $iHeight, $SWP_NOACTIVATE) It's blowing up on the last part "$SWP_NOACTIVATE". I don't know why it's blowing up there. AutoIt3 Syntax Checker v1.54.8 Copyright © Tylo 2007 C:\Scripting\EMR_Sign\EMR_Sign.au3(56,87) : WARNING: $SWP_NOACTIVATE: possibly used before declaration. _WinAPI_SetWindowPos($handle1,$handle2, $iX, $iY, $iWidth, $iHeight, $SWP_NOACTIVATE) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Scripting\EMR_Sign\EMR_Sign.au3(56,87) : ERROR: $SWP_NOACTIVATE: undeclared global variable. _WinAPI_SetWindowPos($handle1,$handle2, $iX, $iY, $iWidth, $iHeight, $SWP_NOACTIVATE) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Scripting\EMR_Sign\EMR_Sign.au3 - 1 error(s), 1 warning(s) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 3, 2010 Moderators Share Posted December 3, 2010 inm101,Looks like you need to add another #include file: #include <Constants.au3>M23P.S. When you reply please use the "Add Reply" button at the top and bottom of the page rather then the "Reply" button in the post itself. That way you do not get the contents of the previous post quoted in your reply and the whole thread becomes easier to read. 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...
inm101 Posted December 3, 2010 Author Share Posted December 3, 2010 (edited) Thanks for the tip about readability. It's still not behaving as I'd like it to. Again, I want Window A ("$GuiTitle") to always (and only) be above Window B ("$WinTitle"), but I still can't make it happen. BTW...$WinTitle is not an Auto IT GUI. expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> $Wintitle = "MIS Sign Documents" $GuiTitle = "My GUI" while 1 sleep(1000) $handle ="" $handle = ControlGetHandle($wintitle,"","[CLASS:RATeditwindow; INSTANCE:1]") if StringLen($handle)>0 Then Example1() Else WinClose($GuiTitle) EndIf wend Func Example1() Local $msg,$Button_1 $iX = 40 $iY = 40 $iWidth = 200 $iHeight = 675 $hGUI_A = GUICreate($GuiTitle, $iX, $iY, $iWidth, $iHeight,$WS_POPUP) $Button_1 = GUICtrlCreateButton("Sign", 0, 0, 40, 40) $handle2 = WinGetHandle($wintitle) Consolewrite ($handle2) _WinAPI_SetWindowPos($hGUI_A,$handle2, $iWidth, $iHeight, $iX, $iY, $SWP_NOACTIVATE) GUISetState(@SW_SHOW) While WinExists($wintitle) ;_WinAPI_SetWindowPos($hGUI_A,$handle2, $iWidth, $iHeight, $iX, $iY, $SWP_NOACTIVATE) $msg = GUIGetMsg() WinMove($Wintitle,"",0,0) ;WinSetOnTop($Guititle, "", 1) WinSetState("My GUI","",@SW_SHOW) Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 WinMove($Wintitle,"",0,0) $pos = MouseGetPos() ClipPut ("") MouseClick("left",105,143,1,1) MouseClick("left",79,143,1,1) MouseClick("left",105,143,1,1) $clip = ClipGet() Consolewrite($clip & @CRLF) $result1 = StringInStr($clip, "[*]") $result2 = StringInStr($clip, "[]") If $result1 > 0 or $result2 > 0 Then ConsoleWrite("Found [*] or []" & @CRLF) MouseMove($pos[0], $pos[1], 0) MsgBox(16, "Warning", "Please finish editing this report before attempting to sign it.") Else GUISetState(@SW_HIDE) MouseClick("left",221,698,1,1) GUISetState(@SW_SHOW) EndIf MouseMove($pos[0], $pos[1], 0) EndSelect WEnd GUIDelete() EndFunc Edited December 3, 2010 by inm101 Link to comment Share on other sites More sharing options...
GEOSoft Posted December 3, 2010 Share Posted December 3, 2010 From the help file WinSetOnTop()Third-party programs which add an "Always On Top" context menu entry might not update their menu entry to reflect the AutoIt-induced change in TOPMOST status. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
inm101 Posted December 3, 2010 Author Share Posted December 3, 2010 The non AutoIT window does not have an "Always On Top" option in the context menu of the app. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 3, 2010 Moderators Share Posted December 3, 2010 (edited) inm101,Checking a script in which I have used _WinAPI_SetWindowPos I see that I created the "on-top" GUI using the "beneath" GUI as the parent and created the controls after the API call. So try this:$handle2 = WinGetHandle($wintitle) Consolewrite ($handle2) $hGUI_A = GUICreate($GuiTitle, $iX, $iY, $iWidth, $iHeight,$WS_POPUP, -1, $handle2) _WinAPI_SetWindowPos($hGUI_A,$handle2, $iWidth, $iHeight, $iX, $iY, $SWP_NOACTIVATE) $Button_1 = GUICtrlCreateButton("Sign", 0, 0, 40, 40) GUISetState(@SW_SHOW)Fingers crossed! M23Edit: Just seen the posts above - my "beneath" GUI is also a non-AutoIt app and my script works. Edited December 3, 2010 by Melba23 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...
GEOSoft Posted December 3, 2010 Share Posted December 3, 2010 From the help file WinSetOnTop()Third-party programs which add an "Always On Top" context menu entry might not update their menu entry to reflect the AutoIt-induced change in TOPMOST status.The exstyle $WS_EX_TOPMOST and most Window UDF functions suffer from the same limitation. That's a Windows limitation, not one that is AutoIt specific. George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
inm101 Posted December 3, 2010 Author Share Posted December 3, 2010 MELBA, IT WORKS!!!!!!!!!!!!! WOOT, WOOT! You rule.I think the part that put me over the top was your suggestion to use this:$handle2 = WinGetHandle($wintitle) $iX = 40 $iY = 40 $iWidth = 200 $iHeight = 675 $hGUI_A = GUICreate($GuiTitle, $iX, $iY, $iWidth, $iHeight,$WS_POPUP, -1, $handle2) _WinAPI_SetWindowPos($hGUI_A,$handle2, $iWidth, $iHeight, $iX, $iY, $SWP_NOACTIVATE)Here's the final code. Thank you so much for your help.expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> $Wintitle = "MIS Sign Documents" $GuiTitle = "My GUI" while 1 sleep(1000) $handle ="" $handle = ControlGetHandle($wintitle,"","[CLASS:RATeditwindow; INSTANCE:1]") if StringLen($handle)>0 Then Example1() Else WinClose($GuiTitle) EndIf wend Func Example1() Local $msg,$Button_1 $handle2 = WinGetHandle($wintitle) $iX = 40 $iY = 40 $iWidth = 200 $iHeight = 675 $hGUI_A = GUICreate($GuiTitle, $iX, $iY, $iWidth, $iHeight,$WS_POPUP, -1, $handle2) _WinAPI_SetWindowPos($hGUI_A,$handle2, $iWidth, $iHeight, $iX, $iY, $SWP_NOACTIVATE) $Button_1 = GUICtrlCreateButton("Sign", 0, 0, 40, 40) GUISetState(@SW_SHOW) While WinExists($wintitle) $msg = GUIGetMsg() WinMove($Wintitle,"",0,0) Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_1 WinMove($Wintitle,"",0,0) $pos = MouseGetPos() ClipPut ("") MouseClick("left",105,143,1,1) MouseClick("left",79,143,1,1) MouseClick("left",105,143,1,1) $clip = ClipGet() Consolewrite($clip & @CRLF) $result1 = StringInStr($clip, "[*]") $result2 = StringInStr($clip, "[]") If $result1 > 0 or $result2 > 0 Then ConsoleWrite("Found [*] or []" & @CRLF) MouseMove($pos[0], $pos[1], 0) MsgBox(16, "Warning", "Please finish editing this report before attempting to sign it.") Else GUISetState(@SW_HIDE) MouseClick("left",221,698,1,1) GUISetState(@SW_SHOW) EndIf MouseMove($pos[0], $pos[1], 0) EndSelect WEnd GUIDelete() EndFunc Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 3, 2010 Moderators Share Posted December 3, 2010 inm101, My pleasure. Sorry it took a few tries to get it to work - I will check on the working code first next time rather than relying on the little grey cells! 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...
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