Jump to content

Info Window Transparency


 Share

Recommended Posts

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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]
Link to comment
Share on other sites

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

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...