Jump to content

Whats the difference between WinSetOnTop and WinActivate?


Burgaud
 Share

Recommended Posts

I have this Multiple ToolTip routine (modified from GtaSpider) :

func CreateToolTip($name, $x, $y, $width=200, $height=15, $style=0x01, $bgcolor=0xC0C0C0, $fontsize=10, $fontface="Arial Narrow", $fontcolor=0x0)
    ;modified from GtaSpider

    local $handle[3]
    $handle[0] = GUICreate($name, $width, $height, $x, $y, 0x80000000, 128) ;$WS_POPUP = -2147483648, $WS_EX_TOOLWINDOW = 128
    GUISetBkColor($bgcolor)

    $handle[1] = GUICtrlCreateLabel($name, 5, 1, $width, $height, $style)   ;Create label with styled text
    GUICtrlSetFont ($handle[1], $fontsize, 300, 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
    return($handle)
endfunc

func PrintToolTip(ByRef $handle, $text, $timeout=5000)
    GUISwitch($handle[0])
    GUICtrlSetData($handle[1], $text)
    GUISetState(@SW_SHOW, $handle[0])       ;Show
    $handle[2] = SetTimeOut($timeout)
endfunc

I am currently using it as a periodic popup messenger on windows while I do programming, browsing and other tasks.

The problem is, whenever my script fires off a message, I lost focus on the active window. Is it because of the WinSetOnTop option?

Must I have these two lines to restore/preserve the active window?

func PrintToolTip(ByRef $handle, $text, $timeout=5000)
    local $h = WinGetHandle("[ACTIVE]") 
    GUISwitch($handle[0])
    GUICtrlSetData($handle[1], $text)
    GUISetState(@SW_SHOW, $handle[0])       ;Show
    $handle[2] = SetTimeOut($timeout)
    WinActivate($h)
endfunc

Or is there some better way of doing it?

What are the differences between WinActivate and WinSetOnTop ?
And how does GUISetState($SW_SHOW, handle)  and WinSetTrans affect them too.
These eludes me.

Thanks.
 

 

Link to comment
Share on other sites

WinSetOnTop in my experience doesn't steal focus, difference to the WinActivate is that WinActivate sets as active, and winsetontop may appear over other windows, but you can continue doing work wherever you are.

GUISetState($SW_SHOW, handle)  either that or hide, so it affects in a way that you either see them or you dont. LOL

Same for transparency

Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

Link to comment
Share on other sites

Are you saying that one of those functions is stealing focus? Maybe so, im not sure.

May i suggest, instead of hide/show, you make it show, and then winmove the window away from desktop view instead of hiding, and bring it to view again when you want it to show.

You can move the window to some "ridiculous" resolution like X=7000 and leave y as is, or change Y and leave X or change both, whatever you feel like.

As for what function is making it steal focus from other windows, just coment it, one at a time and check results, if i had to guess, i wouldn't.

PS: that bit shouldn't make the script slow, never seen it slow scripts down. was it the only change?

Edited by careca
Spoiler

Renamer - Rename files and folders, remove portions of text from the filename etc.

GPO Tool - Export/Import Group policy settings.

MirrorDir - Synchronize/Backup/Mirror Folders

BeatsPlayer - Music player.

Params Tool - Right click an exe to see it's parameters or execute them.

String Trigger - Triggers pasting text or applications or internet links on specific strings.

Inconspicuous - Hide files in plain sight, not fully encrypted.

Regedit Control - Registry browsing history, quickly jump into any saved key.

Time4Shutdown - Write the time for shutdown in minutes.

Power Profiles Tool - Set a profile as active, delete, duplicate, export and import.

Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes.

NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s.

IUIAutomation - Topic with framework and examples

Au3Record.exe

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
 Share

  • Recently Browsing   0 members

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