ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Removed Areas > AutoHotkey

Transparent windows with AHK what am I doing wrong?

(1/1)

nite_monkey:
I'm trying to make an AHK script that will let me change how transparent a window is.
This script works, but it randomly decides to mess up.

CapsLock & WheelDown::
{
WinGetActiveTitle, cwindow
WinGet, tp, Transparent, %cwindow%
tp := tp-10
WinSet, Transparent, %tp%, %cwindow%
Return
}

CapsLock & WheelUp::
{
WinGetActiveTitle, cwindow
WinGet, tp, Transparent, %cwindow%
tp := tp+10
WinSet, Transparent, %tp%, %cwindow%
Return
}

Rwin & LWin::
{
WinGetActiveTitle, cwindow
WinSet, Transparent, Off, %cwindow%
Return
}

--- End quote ---

That is my script.
The problem is sometimes when ever I change active windows and then push the capslock and scroll down, it makes the active window completely transparent.
I just want it to drop the transparency by 10.
Is there a different way I can do this to make it work better?

What I am wanting to achieve is:
When I hold down the capslock and scroll down, decrease the transparency of the active window by 10.
When I hold down the capslock and scroll up, increase the transparency of the active window by 10.

jgpaiva:
I think your problem is caused by this behaviour:
outputvar is made blank if: 1) the OS is older than Windows XP; 2) there are no matching windows; 3) the window has no transparency level;
-ahk help file (winget section)
--- End quote ---
In windows with no transparency, the output variable is set to blank, and when you take 10 out of that, you get blank again, which then works as a 0 on the WinSet, setting the window to invisible.
Just add the following to the line after the WinGet:

--- ---if (tp = "")
  tp =255
That should solve your problem ;) (I hope! :P)

nite_monkey:
You know, that might be the problem. I will have to do that. Your explanation would make sense as to why it is doing that.

Edit: I do believe that fixed the problem. I can't get it to mess up on me anymore. Thanks  :Thmbsup:

jgpaiva:
Glad to know that! :D

Navigation

[0] Message Index

Go to full version