Valiante

Prevent GUI appearing on top of full-screen app (like RDP)

8 posts in this topic

#1 ·  Posted (edited)

Hi,

I've searched but can only find posts from people with the opposite problem (asking how to get their GUI to display on top of a full-screen app, usually a game.

I've created a toolbar which I use in a work environment, creating the GUI with the following styles;

$hwnd = GUICreate($title, $toolbarWidth, $height, $left, $top, $WS_POPUPWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
 
I want it to have a TOPMOST style as it's supposed to behave like the Windows taskbar (which it does in all but one scenario).
 
If I start a full-screen RDP session, I can still see my toolbar and have to close it.  Is there a way I can make it appear on top of all windows *except* full-screen apps (in the same way the taskbar allows full-screen apps on top of it)?
 
Thanks in advance.
 
Val.
Edited by Valiante

Share this post


Link to post
Share on other sites



I would just check if the active window fills the screen, and if it does, turn off on top of your toolbar.

I would do it like so: >link to topic.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Or you can get the handle to your toolbar and check it with WinGetState(), this will tell you if the application is maximized as well.


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

Thanks for your replies.  I could indeed introduce a loop to check for an active full-screen window, but I was hoping for a style constant (or combination thereof) which might do the trick and order it behind full-screen windows natively, much like the taskbar.

I'm not concerned about maximized windows as I'm using a combination of DllStructCreate and DllCall to leverage the SHAppBarMessage shell function and register my toolbar as an appbar, so its position and dimensions are respected in much the same way as the taskbar, and windows maximize up to it, not over it.

The only issue I've yet to overcome is full-screen windows.  Your suggestion is valid, I'm just hoping for something a little more elegant.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

What happens if you do:

WinSetOnTop($hwnd, "", 1)

Edit:

Sorry, I misread your request.  Indeed you could use WinSetOnTop() more than likely, but you'd have to verify (In a loop) what to look for.  There's no "conditional" constant you can put in the creation of a GUI.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Would that not just set my toolbar to the topmost window, in the same way the extended styles are on creation?

EDIT: Just to test the theory, I removed the $WS_EX_TOPMOST extended-style from my GUICreate line and added your line below.  The toolbar remains on top of all windows, including full-screen windows, so the behaviour is the same.

Rgds,

Val.

Edited by Valiante

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Indeed it would, like I said, I misread your initial request.  But like I said, without a checking the state of the active window, you cannot manage your issue correctly.

I've no idea if this will work or not, I do not have a full screen window to popup nor do I feel the urge to create one.

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $ghWnd = GUICreate("", 100, 30, 0, 0, $WS_POPUPWINDOW, $WS_EX_TOOLWINDOW)
WinSetState($ghWnd, "", 1)
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            ExitLoop
    EndSwitch
    _myWinOnTopIfFullSizeWin($ghWnd, False)
WEnd


Func _myWinOnTopIfFullSizeWin($hWndOnTop, $bOnTop = True)

    Local Const $iWidth = @DesktopWidth
    Local Const $iHeight = @DesktopHeight

    Local $hActive = WinActive("[ACTIVE]")
    If Not $hActive Then Return $hActive

    Local $aPos = WinGetPos($hActive)
    If Not IsArray($aPos) Then
        Return SetError(1, 0, 0)
    EndIf

    Local $iOnTop = 0

    If $aPos[0] <= 0 And $aPos[1] <= 0 And _
        $aPos[2] >= $iWidth And $aPos[3] >= $iHeight Then
        ; we have a full screen window
        $iOnTop = (($bOnTop) ? 1 : 0)
        WinSetState($hWndOnTop, "", $iOnTop)
        Return $hActive
    EndIf

    ; do the opposite if we're here of $bOnTop
    $iOnTop = (($bOnTop) ? 0 : 1)
    WinSetOnTop($hWndOnTop, "", $iOnTop)

    Return $hActive
EndFunc

.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites

Understood - didn't see your edit until just now.  Thanks.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • IAMK
      By IAMK
      Hello,
       
      I have a script which uses a GUI with two buttons. It gets shown and hidden., and pressing the buttons (including their hotkeys) highlights the button, making you able to press enter the next time.
      However, I don't want that.
       
      I've tried using WinActivate() to make enter do things on another program, but the enter is still tied to the AutoIT GUI (which still has the button highlighted).
       
      Here's the important part of my code:
      $MY_GUI = GUICreate("Check.exe", 400, 300, ((@DesktopWidth / 2) - 200), -500) WinSetOnTop($MY_GUI, "", 1) ;Keeps the window on the top. $Button1 = GUICtrlCreateButton("Pass (Ctrl+P)", 40, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $Button2 = GUICtrlCreateButton("Fail (Ctrl+F)", 240, 250, 120, 40, $WS_GROUP) GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif") $GUIText = GUICtrlCreateLabel("", 20, 10, 360, 230) GUICtrlSetFont(-1, 13, 400, 0, "MS Sans Serif") GUICtrlSetData($GUIText, Execute($stepMessage[$step])) $showGUI = "True" GUISetState(@SW_SHOW) While($showGUI = "True") $buttonPressed = GUIGetMsg() Switch $buttonPressed Case $Button1 ;Pass $pass = "True" $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) Case $Button2 ;Fail $buttonPressed = 0 $showGUI = "False" GUISetState(@SW_HIDE) While($message = "") $message = InputBox("Check.exe", "Please enter the reason the step failed." & @CRLF, "", "", 300, 200, ((@DesktopWidth / 2) - 150), -400) WEnd Return $message EndSwitch WEnd Local $pass = "False" ;Whether "Pass" or "Fail" was pressed. Local $failLog = xxxfunc($pass) ;Returns a message to log if the step failed. ##THIS CALLS THE CODE SNIPPET ABOVE## FileWrite($file, _Now() & ": Step " & $step & getStatus($pass) & "and took " & Ceiling(TimerDiff($timer) / 1000) & " seconds." & @CRLF) If($failLog <> "") Then FileWrite($file, "Logged comment: " & $failLog & @CRLF) EndIf WinActivate("[TITLE:ProgramName]") ;Hotkeys: HotKeySet("^{p}", "pressPass") HotKeySet("^{f}", "pressFail") Func pressPass() $buttonPressed = $Button1 EndFunc Func pressFail() $buttonPressed = $Button2 EndFunc  
      The GUI's button/hotkey pressing works correctly.
      The same WinActivate code works in another script of mine.
      Together, WinActivate is not take "Active" away from the GUI's last-pressed button. How do I fix this?
       
      Thank you in advance.
    • fatpig
      By fatpig
      Dear AutoIT Community.
      I am currently working on a program that will display lots of images in a scroll down GUI.
      I create the GUI based on the number of images, which works fine.
      But all images I place using GuiCtrlCreatePic above a threshold of around 32000 pixels (cant say exactly) are placed at negative locations and finally will reach 0 again
      and will then populate on top of the images placed there before.
      For $i = 1 To $Images[0] ; Get picture dimensions $hImage = _GDIPlus_ImageLoadFromFile($ImgRep & $Images[$i]) $iX = _GDIPlus_ImageGetWidth($hImage) $iY = _GDIPlus_ImageGetHeight($hImage) _GDIPlus_ImageDispose($hImage) ; Resize & place images in GUI $Pic[$i] = GUICtrlCreatePic($ImgRep & $Images[$i], $Spacer, Round($yPos, 0), $MaxImgWidth, $MaxImgWidth * ($iY / $iX)) $yPos = $yPos + $MaxImgWidth * ($iY / $iX) + $Spacer $log = $log & "|" & $yPos $currentlut = $Images[1] Next I have found a limit at 32767 pixels for some GUI elements when googling around.
      Can someone tell me how to circumvent that?
      thanks!
      cheers
      Felix
    • Shirdish_chakravarthi
      By Shirdish_chakravarthi
      Hello Guys this is my gui and i need the numeric value typed in the highlighted  inputbox. if this value is greater than 1 i need to perform some operations
      \
       
      Here is the summary about that field which i got from wininfo tool

      i tried writing the code as shown below.. but the msgbox is popping up empty value..when the same code is pasted under some button action i am able to access the value present in the field..but when placed alone as written in the attached script i am unable to fetch it... 

      here i am using the valu present in the field

      can you guys tell me what's wrong??? or how can i get that value?
       
      My_GUI.au3

    • Neonovaz
      By Neonovaz
      Hello
       
      Is there anyway to store word documents in Autoit GUI? For example I have a instruction sheet that I want to bundle up with the exe.

      So a user simply clicks the icon and the stored document will launch  (Something like how you can add objects like excel sheets in word documents )

      (I Know we can launch word files from script directory)

       
    • hemichallenger
      By hemichallenger
      Not sure if this is possible or if someone has already tackled this. Is it possible to embed PowerShell into a GUI? Autoit is great for quick function but sometime I need to run a command thru PowerShell. It be great to have PowerShell console embedded into the gui.