Jump to content
Sign in to follow this  
Richard Robertson

Info Window Transparency

Recommended Posts

Richard Robertson

In response to a feature request, I have just written this. When the mouse is over the info window, it's fully visible, otherwise it's semitransparent.

The script runs the tool and when the tool closes, the script exits.

#cs
    Richard Robertson
    
    This script turns the info window semitransparent when the mouse is not over it.
#ce

Dim $pid = Run("au3info.exe")

WinWait("AutoIt v3 Active Window Info")

Dim $hwnd = WinGetHandle("AutoIt v3 Active Window Info")

Dim $timer, $wpos, $mpos, $istrans

$istrans = False

Dim $trans = 128 ; set this to whatever you want, this is the semitransparent value

While ProcessExists($pid) ; exits when you close the info window
    $timer = TimerInit()
    $wpos = WinGetPos($hwnd)
    While TimerDiff($timer) < 5000 And Processex($pid) ; only check the position of the window every 5 seconds
        $mpos = MouseGetPos()
        If ($mpos[0] >= $wpos[0]) And ($mpos[0] <= ($wpos[0] + $wpos[2])) And ($mpos[1] >= $wpos[1]) And ($mpos[1] <= ($wpos[1] + $wpos[3])) Then ; on window
            If $istrans Then
                WinSetTrans($hwnd, "", 255)
                $istrans = False
            EndIf
        Else
            If Not $istrans Then
                WinSetTrans($hwnd, "", $trans)
                $istrans = True
            EndIf
        EndIf
        Sleep(10)
    WEnd
WEnd

Let me know what you think.

Share this post


Link to post
Share on other sites
gseller

This is a very good idea, it does not work on my winxp box. It pulls up the info tool but never does the transparency or the exit on ProcessExists after 5 seconds.. Is it meant for vista only maybe?

Share this post


Link to post
Share on other sites
Nahuel

Doesn't work here either... but yeah, good idea..

-edit-

Check now gesller:

#cs
    Richard Robertson
    
    This script turns the info window semitransparent when the mouse is not over it.
#ce

$pid=Run("au3info.exe")

WinWait("AutoIt v3 Window Info")

$hwnd = WinGetHandle("AutoIt v3 Window Info")

Dim $timer, $wpos, $mpos, $istrans

$istrans = True

Dim $trans = 128 ; set this to whatever you want, this is the semitransparent value

While WinExists($hwnd) ; exits when you close the info window
    $timer = TimerInit()
    $wpos = WinGetPos($hwnd)
    While TimerDiff($timer) < 5000 And ProcessExists($pid) ; only check the position of the window every 5 seconds
        $mpos = MouseGetPos()
        If ($mpos[0] >= $wpos[0]) And ($mpos[0] <= ($wpos[0] + $wpos[2])) And ($mpos[1] >= $wpos[1]) And ($mpos[1] <= ($wpos[1] + $wpos[3])) Then ; on window
            If $istrans Then
                WinSetTrans($hwnd, "", 255)
                $istrans = False
            EndIf
        Else
            If Not $istrans Then
                WinSetTrans($hwnd, "", $trans)
                $istrans = True
            EndIf
        EndIf
        Sleep(10)
    WEnd
WEnd
Edited by Nahuel

Share this post


Link to post
Share on other sites
Achilles

It works good with the changes Nahuel made.

I don't understand something here though. You say it checks every five seconds but that does not seem to be the case. Since you are initiating the timer at the beginning of every loop the timer will always be less then 5000 and the process should always exist while the window exists. Consequently isn't the timer pointless?

Basically I'm saying that in this statement:

TimerDiff($timer) < 5000 And ProcessExists($pid)

Both conditions will always evaluate to true which makes it pointless. Please let me know if I'm not understanding something here...

EDIT: I have a suggestion that should be simple. Make an option so that it will fade through to the transparency you want instead of just setting it at the new transparency.

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
Richard Robertson

The timer does make sense if you look closely. The outer loop starts the timer and gets the window position. The inner loop will run for up to 5 seconds (5000 milliseconds) or terminate if the process closes. When the inner loop ends, the outer loop gets the window position and resets the timer.

I didn't write this for Vista, because Vista sucks still and I won't use it. I don't understand what isn't working about it though. I tested it on XP SP2 and it worked.

If anyone can provide me with any info as to why it's not working, I'd love to understand what's wrong. I got it working just fine.

Edited by Richard Robertson

Share this post


Link to post
Share on other sites
gseller

Cool Beans! Works now... Not sure I would ever use it but way cool just the same..

Share this post


Link to post
Share on other sites
Achilles

The timer does make sense if you look closely. The outer loop starts the timer and gets the window position. The inner loop will run for up to 5 seconds (5000 milliseconds) or terminate if the process closes. When the inner loop ends, the outer loop gets the window position and resets the timer.

I didn't write this for Vista, because Vista sucks still and I won't use it. I don't understand what isn't working about it though. I tested it on XP SP2 and it worked.

If anyone can provide me with any info as to why it's not working, I'd love to understand what's wrong. I got it working just fine.

The parts that didn't work for me was the name change. My AutoIt window name is "AutoIt v3 Window Info" and I don't have a function called "Processex".

EDIT: About the loop, I now understand why you have it now. However, doesn't that just make your code more likely to mess up? For example, I ran it with the loop and if I moved the window at the right time it would be solid (255 trans) even though the mouse was off of it and then it would update in a few seconds. However, without the loop it doesn't malfunction like that... Though it probably uses more CPU...

Edited by Piano_Man

My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites
DW1

Now it will not go transparent while you are draging the window. Also will not go transparent if you are highlighting text behind it or moving a windows behind it:

#cs
    Richard Robertson
    
    This script turns the info window semitransparent when the mouse is not over it.
#ce
#include<misc.au3>
$pid = Run("au3info.exe")

WinWait("AutoIt v3 Window Info")

$hwnd = WinGetHandle("AutoIt v3 Window Info")

Dim $timer, $wpos, $mpos, $istrans

$istrans = False

Dim $trans = 128 ; set this to whatever you want, this is the semitransparent value

While WinExists($hwnd) ; exits when you close the info window
    $timer = TimerInit()
    $wpos = WinGetPos($hwnd)
    While TimerDiff($timer) < 1000 And ProcessExists($pid) ; check the position of the window every second
        $mpos = MouseGetPos()
        If ($mpos[0] >= $wpos[0]) And ($mpos[0] <= ($wpos[0] + $wpos[2])) And ($mpos[1] >= $wpos[1]) And ($mpos[1] <= ($wpos[1] + $wpos[3])) Then ; on window
            If $istrans Then
                While _IsPressed(01)
                    Sleep(10)
                WEnd
                WinSetTrans($hwnd, "", 255)
                $istrans = False
            EndIf
        Else
            If Not $istrans Then
                If Not _IsPressed(01) Then
                    WinSetTrans($hwnd, "", $trans)
                    $istrans = True
                EndIf
            EndIf
        EndIf
        Sleep(10)
    WEnd
WEnd

Share this post


Link to post
Share on other sites
Nahuel

^It ramains solid when using the finder tool too. :)

Share this post


Link to post
Share on other sites
Richard Robertson

As I said in the first post, I designed this to provide a solution to a feature request.

Also, the inner loop is simply to relieve the processor. You can always remove it and check the window location every loop, but I figured it made more sense not to.

@danwilli: Nice improvement, I didn't think of that.

Share this post


Link to post
Share on other sites
Richard Robertson

Well, I only created it to help you. I don't really worry about the info window myself.

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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.