Jump to content

How? GUI set always on top, *always*


Recommended Posts

This is a function I used to display a text on the screen:

func _CreateToolTip($name, $x, $y, $width=200, $height=15, $style=0x01, $bgcolor=0xC0C0C0, $fontsize=11, $fontface="Verdana", $fontcolor=0x0, $fixwidth=1)
    local $handle[7]
    $handle[0] = GUICreate($name, $width, $height, $x, $y, 0x80000000, 0x80)    ;$WS_POPUP = 0x80000000, $WS_EX_TOOLWINDOW = 0x80

    local $yy = int($height/2) - $fontsize*1.5 - 5    ;assume 2 lines
    $handle[1] = GUICtrlCreateLabel($name, 5, $yy, $width-10, 3*$fontsize, $style)    ;Create label with styled text
    GUICtrlSetFont ($handle[1], $fontsize, 400, 0, $fontface, 5)
    GUICtrlSetColor($handle[1], $fontcolor)

    GUISetState(@SW_HIDE, $handle[0])        ;No Show
    WinSetOnTop($handle[0], "", 1)            ;OnTop
    WinSetTrans($handle[0], "", 255)        ;Transparency

    $handle[2] = 0
    $handle[3] = $fixwidth
    $handle[4] = ''

func _HideToolTip(ByRef $handle)
    GUISetState(@SW_HIDE, $handle[0])       ;No Show

func _PrintToolTip(ByRef $handle, $text)
    ;local $h = WinGetHandle("[ACTIVE]")
    if $handle[4] = $text then  ;this prevents flickering of screen
        $handle[4] = $text
        GUICtrlSetData($handle[1], $text)
        GUISetState(@SW_SHOW, $handle[0])       ;Show
        ;if $handle[5]> 0 then GUISetState(@SW_SHOW, $handle[5])        ;Show
        ;if $handle[6]> 0 then GUISetState(@SW_SHOW, $handle[6])        ;Show

I used it by:

GLOBAL $FullScreen = _CreateToolTip("FullScreen", 0, 0, @DesktopWidth, @Desktopheight, 0x01, 0x000000, 60, "Verdana", 0xFFFF00, 1)

; Display a message
_PrintToolTip($FullScreen, "Computer is resting... Take this time to move around...")
; unDisplay the message

I want it to always be "OnTop" regardless whether user is running a web browser, watching youtube, watching video via VLC, or playing games - especially games.

It works flawlessly on my computer. Yet somehow, this popup is not displayed OnTop and getting covered by other apps on my Kid's computer. He managed to find a loophole, able to watch youtube, watch VLC, play games!

Any reason?


Link to comment
Share on other sites

  • 2 weeks later...

First, lol, that's hysterical. This sounds like something my brother would do :) Make sure that your script is still running somewhere, if it isn't then I'd guess these things:

I found that I could press the Start button, which revealed the taskbar, where I could click "Exit" on the tray icon on your script. Fixable with:

Opt("TrayMenuMode", 1) ; Don't use the default icons
Opt("TrayIconHide", 1) ; Hide the tray icon

Alternately, I could restart/sign out and the script would be ended. To fix this, you'd need to start your script on login, probably with the Task Scheduler.

All my code provided is Public Domain... but it may not work. ;) Use it, change it, break it, whatever you want.


My Humble Contributions:
Personal Function Documentation - A personal HelpFile for your functions
Acro.au3 UDF - Automating Acrobat Pro
ToDo Finder - Find #ToDo: lines in your scripts
UI-SimpleWrappers UDF - Use UI Automation more Simply-er
KeePass UDF - Automate KeePass, a password manager
InputBoxes - Simple Input boxes for various variable types

Link to comment
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...