 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
numEric Guest
|
Posted: Thu Aug 26, 2004 3:36 pm Post subject: Transparent windows |
|
|
For those looking for an easy way to make windows transparent and control the transparency from the mouse.
Usage :
Hold down the Ctrl and Shift keys while turning the mouse wheel to change the transparency of the window the cursor is on. (The window doesn't have to be active.)
A tooltip shows the current opacity while you change it.
The script remembers the transparency level for each window as long as it is loaded.
To see the opacity level of a window, click the wheel while holding the two keys down.
Please note that the script doesn't let you set the opacity to 0% to avoid loosing windows ;o)
| Code: | #SingleInstance Force
#MaxThreadsPerHotkey 10
SetBatchLines, -1
AutoTrim, Off
AlphaIncrement = 8.5
Ctrl & MButton::
GetKeyState, ShiftState, Shift
If ShiftState = U
{
Return
}
Gosub, WinGetTransparency
Gosub, WinSetTransparency
Gosub, ShowTransparencyToolTip
Return
Ctrl & WheelDown::
GetKeyState, ShiftState, Shift
If ShiftState = U
{
Return
}
Gosub, WinGetTransparency
Trans0 -= 10
Gosub, WinSetTransparency
Gosub, ShowTransparencyToolTip
Return
Ctrl & WheelUp::
GetKeyState, ShiftState, Shift
If ShiftState = U
{
Return
}
Gosub, WinGetTransparency
Trans0 += 10
Gosub, WinSetTransparency
Gosub, ShowTransparencyToolTip
Return
WinGetTransparency:
MouseGetPos, , , WindowID
If Trans_%WindowID% =
{
Trans_%WindowID% = 100
}
StringTrimRight, Trans, Trans_%WindowID%, 0
Trans0 = %Trans%
Return
WinSetTransparency:
WinGetClass, WindowClass, ahk_id %WindowID%
If WindowClass = Progman
{
Trans0 = 100
}
Else If Trans0 < 10
{
Trans0 = 10
}
Else If Trans0 > 100
{
Trans0 = 100
}
a = %Trans%
b = %Trans0%
Trans = %Trans0%
Trans_%WindowID% = %Trans%
If WindowClass = Progman
{
Return
}
a *= 2.55
Alpha0 = %a% ; Starting Alpha
b *= 2.55
Alpha = %b%
Transform, Alpha, Round, %Alpha% ; Ending Alpha
c = %Alpha0% ; Init iteration var.
d = %Alpha%
d -= %Alpha0% ; Range to iterate
Transform, e, Abs, %d%
If e > 0
{
f = %d%
f /= %e% ; Unity increment (+/- 1)
}
Else
{
f = 0
}
g = %f%
g *= %AlphaIncrement% ; Increment
Loop
{
Transform, c, Round, %c%
WinSet, Trans, %c%, ahk_id %WindowID%
If c = %Alpha%
{
Break
}
Else If e >= %AlphaIncrement%
{
c += %g%
e -= %AlphaIncrement%
}
Else
{
c = %Alpha%
}
}
Return
ShowTransparencyToolTip:
h = %Trans%
h /= 4
i = 25
i -= %h%
ToolTipText = Opacity :%A_Space%
Loop, %h%
{
ToolTipText = %ToolTipText%|
}
If h > 0
{
ToolTipText = %ToolTipText%%A_Space%
}
ToolTipText = %ToolTipText%%Trans%`%
If i > 0
{
ToolTipText = %ToolTipText%%A_Space%
}
Loop, %i%
{
ToolTipText = %ToolTipText%|
}
ToolTip, %TooltipText%
MouseGetPos, MouseX0, MouseY0
SetTimer, RemoveToolTip
Return
RemoveToolTip:
If A_TimeIdle < 1000
{
MouseGetPos, MouseX, MouseY
If MouseX = %MouseX0%
{
If MouseY = %MouseY0%
{
Return
}
}
}
SetTimer, RemoveToolTip, Off
ToolTip
Return
|
|
|
| Back to top |
|
 |
Wingfat
Joined: 23 Aug 2004 Posts: 193 Location: East Bay, California USA
|
Posted: Thu Aug 26, 2004 4:46 pm Post subject: |
|
|
| Thanks this a great tool! Keep up the good work! |
|
| Back to top |
|
 |
Rajat
Joined: 28 Mar 2004 Posts: 1718
|
Posted: Thu Aug 26, 2004 7:33 pm Post subject: |
|
|
very nice work!
i specially like the tooltip bar. _________________
 |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Thu Aug 26, 2004 9:14 pm Post subject: |
|
|
I tried it too; it's great. I think a tiny improvement is possible. For your mouse button hotkeys, you could define them this way instead (to avoid the need for GetKeyState):
^+MButton::
^+WheelDown::
^+WheelUp::
If you would like me to post this in the script showcase I'll make a note to do so. |
|
| Back to top |
|
 |
Wingfat
Joined: 23 Aug 2004 Posts: 193 Location: East Bay, California USA
|
Posted: Thu Aug 26, 2004 9:36 pm Post subject: |
|
|
Wait!!
This script locks up Terminal Services client in Windows 2000 Pro.
It works fine untill you try to make the Terminal Session transparent!!!
Be warned!  |
|
| Back to top |
|
 |
Candle
Joined: 19 Aug 2004 Posts: 334
|
Posted: Thu Aug 26, 2004 10:06 pm Post subject: |
|
|
| first time I ran it , it lock my system .had to do a hard boot . |
|
| Back to top |
|
 |
Wingfat
Joined: 23 Aug 2004 Posts: 193 Location: East Bay, California USA
|
Posted: Thu Aug 26, 2004 10:22 pm Post subject: |
|
|
| I have tried taking out the Tool Tip pop up with it and still get it to lock up my Treminal sessions. I tried compliing it to Exe and running it on other machines in my office and all have the same issue. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Aug 27, 2004 1:10 am Post subject: |
|
|
Hmm. Could you try a simple script that uses only WinSet and see if that locks it up too? If it does, I'll put a warning in the help file about transparency.
By the way, the only thing "WinSet Transparent" does is:
SetWindowLong(target_window, GWL_EXSTYLE, GetWindowLong(target_window, GWL_EXSTYLE) | WS_EX_LAYERED);
MySetLayeredWindowAttributes(target_window, 0, value, LWA_ALPHA);
Both of the above are functions built into Windows 2000/XP+. |
|
| Back to top |
|
 |
numEric Guest
|
Posted: Fri Aug 27, 2004 8:48 pm Post subject: |
|
|
| Chris wrote: | I tried it too; it's great. I think a tiny improvement is possible. For your mouse button hotkeys, you could define them this way instead (to avoid the need for GetKeyState):
^+MButton::
^+WheelDown::
^+WheelUp:: |
Thanks, Chris ! I always specify modifiers this way when combined with keys, but for some reason I didn't think of it when working with mouse buttons...
Regarding application lockups, I think they occur on executing "WinSet Transparent", but I was unable to reproduce them.
I have tested the script with TS Client and Citrix in XP and it worked fine with both, but maybe things are different in Win2k ? Does anyone encounter a problem similar to Wingfat's ?
Also, I noted that cmd.exe ignores transparency ; it seems this is by design.
Here is an updated version with some simplifications in the fading code :
| Code: | #SingleInstance Force
#MaxThreadsPerHotkey 10
SetBatchLines, -1
AutoTrim, Off
AlphaIncrement = 8.5
^+MButton::
Gosub, WinGetTransparency
Gosub, WinSetTransparency
Gosub, ShowTransparencyToolTip
Return
^+WheelDown::
Gosub, WinGetTransparency
Trans0 -= 10
Gosub, WinSetTransparency
Gosub, ShowTransparencyToolTip
Return
^+WheelUp::
Gosub, WinGetTransparency
Trans0 += 10
Gosub, WinSetTransparency
Gosub, ShowTransparencyToolTip
Return
WinGetTransparency:
MouseGetPos, , , WindowID
If Trans_%WindowID% =
{
Trans_%WindowID% = 100
}
StringTrimRight, Trans, Trans_%WindowID%, 0
Trans0 = %Trans%
Return
WinSetTransparency:
WinGetClass, WindowClass, ahk_id %WindowID%
If WindowClass = Progman
{
Trans0 = 100
}
Else If Trans0 < 10
{
Trans0 = 10
}
Else If Trans0 > 100
{
Trans0 = 100
}
a = %Trans%
b = %Trans0%
Trans = %Trans0%
Trans_%WindowID% = %Trans%
If WindowClass = Progman
{
Return
}
a *= 2.55
Alpha0 = %a% ; Init. Alpha
b *= 2.55
Alpha = %b%
Transform, Alpha, Round, %Alpha% ; Final Alpha
c = %Alpha%
c -= %Alpha0%
d = %AlphaIncrement%
If c < 0
{
d *= -1
} ; Signed increment
Transform, c, Abs, %c% ; Abs. iteration range
Loop
{
Transform, Alpha0, Round, %Alpha0%
WinSet, Trans, %Alpha0%, ahk_id %WindowID%
If Alpha0 = %Alpha%
{
Break
}
Else If c >= %AlphaIncrement%
{
Alpha0 += %d%
c -= %AlphaIncrement%
}
Else
{
Alpha0 = %Alpha%
}
}
Return
ShowTransparencyToolTip:
e = %Trans%
e /= 4
f = 25
f -= %e%
ToolTipText = Opacity :%A_Space%
Loop, %e%
{
ToolTipText = %ToolTipText%|
}
If e > 0
{
ToolTipText = %ToolTipText%%A_Space%
}
ToolTipText = %ToolTipText%%Trans%`%
If f > 0
{
ToolTipText = %ToolTipText%%A_Space%
}
Loop, %f%
{
ToolTipText = %ToolTipText%|
}
ToolTip, %ToolTipText%
MouseGetPos, MouseX0, MouseY0
SetTimer, RemoveToolTip
Return
RemoveToolTip:
If A_TimeIdle < 1000
{
MouseGetPos, MouseX, MouseY
If MouseX = %MouseX0%
{
If MouseY = %MouseY0%
{
Return
}
}
}
SetTimer, RemoveToolTip, Off
ToolTip
Return
|
| Chris wrote: | | If you would like me to post this in the script showcase I'll make a note to do so. |
Sure, I'd be honored  |
|
| Back to top |
|
 |
Jon
Joined: 28 Apr 2004 Posts: 373
|
Posted: Fri Aug 27, 2004 9:29 pm Post subject: |
|
|
| Yes, nice scipt, well done |
|
| Back to top |
|
 |
Wingfat
Joined: 23 Aug 2004 Posts: 193 Location: East Bay, California USA
|
Posted: Fri Aug 27, 2004 9:37 pm Post subject: |
|
|
Apon further testing with the new script and the old.
It doesn't really lock the treminal session up. More like suspends all key strokes to the TS Client, untill the next time you kit the Ctrl-Shif-MouseWheel. Then it sends what ever key string you have typed.
ex: I opened up Note Pad in TS, ran the transpara script then made the TS go down to 10% and then back to 100% I then typed: This is a test
-Nothing happned, then i once more used the Ctrl-Shit-MouseWheel, and it sent the: This is a test to the note pad.
So TS is NOT really locked. but it just doesn't like to be transparent. |
|
| Back to top |
|
 |
savage
Joined: 02 Jul 2004 Posts: 206
|
Posted: Thu Sep 09, 2004 5:08 pm Post subject: |
|
|
| Quote: | | Also, I noted that cmd.exe ignores transparency ; it seems this is by design. |
Yeah, console windows are special in windows. Kinda sucks. If you want to have fancy console windows check out Console. |
|
| Back to top |
|
 |
Guest
|
Posted: Fri May 20, 2005 8:33 pm Post subject: |
|
|
very nice thx  |
|
| Back to top |
|
 |
Transparent Windows Guest
|
Posted: Thu Aug 04, 2005 7:59 pm Post subject: |
|
|
Thanks for wonderful script.  |
|
| Back to top |
|
 |
st Guest
|
Posted: Tue Apr 18, 2006 3:20 am Post subject: tried |
|
|
| not working, neither. 1.0.42.03 |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|