DonationCoder.com forum
 
Read-only archive. This is a static copy of the DonationCoder.com forum. Reading and searching work as before; logging in, posting and private messages do not.
Archive of 2026-10-21 · About this archive · Main site

Author Topic: Transparent windows with AHK what am I doing wrong?  (Read 11,349 times)

nite_monkey

  • Member
  • Joined in 2006
  • **
  • Posts: 753
Transparent windows with AHK what am I doing wrong?
« on: August 30, 2008, 08:01 PM »
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.

Quote
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
}

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.
[Insert really cool signature here]

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Transparent windows with AHK what am I doing wrong?
« Reply #1 on: August 31, 2008, 12:59 AM »
I think your problem is caused by this behaviour:
Quote from: ahk help file (winget section)
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;
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:
Code
if (tp = "")
  tp =255
That should solve your problem ;) (I hope! :P)

nite_monkey

  • Member
  • Joined in 2006
  • **
  • Posts: 753
Re: Transparent windows with AHK what am I doing wrong?
« Reply #2 on: August 31, 2008, 01:59 AM »
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:
[Insert really cool signature here]
« Last Edit: August 31, 2008, 04:32 AM by nite_monkey »

jgpaiva

  • Artificial Idiocy
  • Global Moderator
  • Joined in 2006
  • *****
  • Posts: 4,727
    • Cody Award
    • Participated in NANY Challenge Once
    • Coding Snacks
    • Portugal Inhabitant
    • Linux User
Re: Transparent windows with AHK what am I doing wrong?
« Reply #3 on: August 31, 2008, 10:15 AM »
Glad to know that! :D

Original address: https://www.donationcoder.com/forum/index.php?topic=14642.0