Toggle any window clickthrough on/off

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
OrangeCat
Posts: 65
Joined: 14 Jun 2022, 00:47

Toggle any window clickthrough on/off

28 Mar 2024, 07:01

I've been searching for hours but yet can't find a solution to my problem...

I found bits & pieces online for transparency and successfully integrated it into my script...
...but I can't figure out how to properly set a clickthrough toggle...
I can set a window as clickthrough, but then when doing so it then it gets stuck in that state (as I am unable to toggle clickthrough off...)

TRANSPARENCY:

Code: Select all

~RButton & WheelUp::Gosub, _WinTransparentUp
~RButton & WheelDown::Gosub, _WinTransparentDown

_WinTransparentUp:
    DetectHiddenWindows, on
    WinGet, curtrans, Transparent, A
      if ! curtrans
          curtrans = 255
      newtrans := curtrans + 8
      if newtrans > 0
      {
          WinSet, Transparent, %newtrans%, A
      }
      else
      {
          WinSet, Transparent, OFF, A
          WinSet, Transparent, 255, A
      }
      return
RETURN

_WinTransparentDown:
    DetectHiddenWindows, on
    WinGet, curtrans, Transparent, A
      if ! curtrans
          curtrans = 255
      newtrans := curtrans - 8
      if newtrans > 0
      {
          WinSet, Transparent, %newtrans%, A
      }
      return
RETURN
CLICKTHROUGH

Code: Select all

  ~RButton & LButton::Gosub, _WinClickThrough

  ClickThrough := !ClickThrough
    If Clickthrough
      WinSet, ExStyle, +0x20, A
    Else
      WinSet, ExStyle, -0x20, A
    Return

ALWAYS ON TOP

Code: Select all

~RButton & XButton1::WINSET, AlwaysOnTop, , A ;
User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Toggle any window clickthrough on/off

28 Mar 2024, 07:10

I did not test this, you might want to try a specific WinTitle instead of A.
User avatar
OrangeCat
Posts: 65
Joined: 14 Jun 2022, 00:47

Re: Toggle any window clickthrough on/off

28 Mar 2024, 17:08

Was wondering, If I were to change the class of an .exe, would this affect anything?
Wondering if I should change the class via a clickthrough toggle, as-well as setting a %count% for each .exe applied hotkey, so that way I can disable clickthrough via class call?

Unless if you or anyone else would have a suggestion on how to universally apply this?

Also... I changed the transparency code as follows:

Code: Select all

; ######################################################################
; USED FOR A WHILE LOOP, WHERE RELEASING "RBUTTON" EXITS SAID WHILE LOOP
; ######################################################################
_WinTransparentHotkey := 0

~RButton Up::
	_WinTransparentHotkey = 0
RETURN



; ################################################
; HOTKEY USED TO ACTIVATE "WHEEL AS TRANSPARENCY"
; ################################################
	~RButton & MButton::
		_WinTransparentHotkey = 1
		While WinTransparentHotkey = 1
			Gosub, _WinTransparentWheels
		Return
	RETURN

	_WinTransparentWheels:
		~RButton & WheelUp::Gosub, _WinTransparentUp
		~RButton & WheelDown::Gosub, _WinTransparentDown
		  WinSet, Transparent %WinT%, % A
	RETURN



; ##############################
; WHEEL AS TRANSPARENCY GOSUBS
; ##############################
	_WinTransparentUp:
		DetectHiddenWindows, on
		WinGet, curtrans, Transparent, A
		If ! curtrans
			curtrans = 255
			newtrans := curtrans + 8
			If newtrans > 0
      			{
				WinSet, Transparent, %newtrans%, A
			}
			Else
			{
				WinSet, Transparent, OFF, A
				WinSet, Transparent, 255, A
			}
		Return
	RETURN
  
	_WinTransparentDown:
		DetectHiddenWindows, on
		WinGet, curtrans, Transparent, A
			If ! curtrans
				curtrans = 255
				newtrans := curtrans - 8
				If newtrans > 0
				{
					WinSet, Transparent, %newtrans%, A
				}
			Return
	RETURN
User avatar
mikeyww
Posts: 28871
Joined: 09 Sep 2014, 18:38

Re: Toggle any window clickthrough on/off

28 Mar 2024, 17:16

I don't know, but I would solve one problem at a time, and I cannot tell whether the problem that you originally posted has been resolved. Regarding "would this affect anything?", you may be able to determine that by running your script.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: AlFlo, Google [Bot] and 150 guests