Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Script to make OneNote transparent


  • Please log in to reply
9 replies to this topic
breakaway
  • Members
  • 9 posts
  • Last active: Mar 16 2012 05:10 PM
  • Joined: 07 Jan 2007
Hi everyone,
Currently i am using the code below to make onenote transparent.

#IfWinActive, ahk_class Framework::CFrame,
LSHIFT & F1::
WinGet, active_id, ID, A
WinSet, Transparent, 150, ahk_id %active_id%,
Return
LSHIFT & F2::
WinGet, active_id, ID, A
WinSet, Transparent, OFF, ahk_id %active_id%,
Return

However, ideally, i would have hoped to use only one key as a toggle. i explored this idea using Winget, Transparent, Transparent as below.

#IfWinActive, ahk_class Framework::CFrame,
LSHIFT & F1::
WinGet, active_id, ID, A
WinGet, Transparent, Transparent, ahk_id %active_id%,
If %Transparent% = 150,
WinSet, Transparent, OFF, ahk_id %active_id%,
Else
WinSet, Transparent, 150, ahk_id %active_id%,
Return

However, no matter how i tweak it, i couldn't get it to work. Any ideas?

BoBo
  • Guests
  • Last active:
  • Joined: --

i would have hoped to use only one key as a toggle

Even what you've explored is using a key combo instead of one key.
How to toogle an event via a single key is descripped at the help. Good luck. :)

  • Guests
  • Last active:
  • Joined: --
try
If Transparent = 150


breakaway
  • Members
  • 9 posts
  • Last active: Mar 16 2012 05:10 PM
  • Joined: 07 Jan 2007
My bad, i meant a single combo instead of a single key.

I tried the

If transparent = 150,

doesn't work as well.. I'm kinda at my wits end.

YMP
  • Members
  • 424 posts
  • Last active: Apr 05 2012 01:18 AM
  • Joined: 23 Dec 2006

If transparent = 150,

What for is there that comma after 150? Where have you seen it?
#IfWinActive, ahk_class Framework::CFrame
LSHIFT & F1:: 
  WinGet, active_id, ID, A 
  WinGet, Transparent, Transparent, ahk_id %active_id% 
  If Transparent = 150 
    WinSet, Transparent, OFF, ahk_id %active_id% 
  Else 
    WinSet, Transparent, 150, ahk_id %active_id%
Return


breakaway
  • Members
  • 9 posts
  • Last active: Mar 16 2012 05:10 PM
  • Joined: 07 Jan 2007
it works now! Thanks everyone!

nick
  • Members
  • 549 posts
  • Last active: Jul 03 2010 09:31 PM
  • Joined: 24 Aug 2005
Some shorter variation, it's using "255" instead of "Off" to avoid flickering:

#IfWinActive, ahk_class Framework::CFrame
LSHIFT & F1::
   _T := (_T = "255" Or _T = "") ? "150" : "255"
   WinSet, Transparent, %_T%, A
Return

nick :wink:

breakaway
  • Members
  • 9 posts
  • Last active: Mar 16 2012 05:10 PM
  • Joined: 07 Jan 2007
wouldn't the use of 255 increase CPU load? I'm on a laptop so CPU load isof concern if i switch on and off often..

breakaway
  • Members
  • 9 posts
  • Last active: Mar 16 2012 05:10 PM
  • Joined: 07 Jan 2007

Some shorter variation, it's using "255" instead of "Off" to avoid flickering:

#IfWinActive, ahk_class Framework::CFrame
LSHIFT & F1::
   _T := (_T = "255" Or _T = "") ? "150" : "255"
   WinSet, Transparent, %_T%, A
Return


One more quirk about this version id that onenote can open up more than one window. So this version can only toggle one window before toggling another window. But thanks anyway, i didn't know the code could be written this way.

nick
  • Members
  • 549 posts
  • Last active: Jul 03 2010 09:31 PM
  • Joined: 24 Aug 2005
Okay, one more line:

#IfWinActive, ahk_class Framework::CFrame
LSHIFT & F1::
   WinGet, _T, Transparent, A 
   _T := _T = 150 ? 255 : 150
   WinSet, Transparent, %_T%, A
Return
I don't think, that 255 will increase CPU load!
nick :wink: