Help needed to make a Toggle able See Through Always On Top and Click Through code working

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
1672019
Posts: 4
Joined: 14 Oct 2021, 22:49

Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by 1672019 » 18 Oct 2021, 20:03

Allo I'm trying to make this toggle-able to function
I want the window that I click when I press the hotkey
became transparent(seethrough), clickthrough, and always on top

the goal is for removing my hassle when streaming on obs because I only have 1 monitor.
the obs has a pop-out able window (dock), that can be used for seen chat, etc because I only have 1 monitor I always find it hard to play and keep alt-tabbing for a few minutes.
even though this can be solved by playing on windowed to see other apps I found this rather annoying.

so I'm thinking that to make a script that can make the obs pop up chat window became transparent(seethrough), clickthrough, and always on top
so by doing that I can play on "fullscreen windowed" and having the obs pop up able (dock) have mentioned properties so I can keep track of my chat, stream activities on 1 screen.

the code was working but
I can't seem able to toggle them back to a normal state (Disabling transparent (seethrough), not click through [so I can type on the window again (replying to the chat, doing moderator command, etc)], and always on top)
every time I toggle the button again the window under the clickthrough one also became invisible which makes me terminate the program and start over.
that's the explanation of what am I trying to achieve.

any help was appreciated
and if this can be working it can also help many people that try to stream with 1 monitor only.

Code: Select all

#SingleInstance, Force
DetectHiddenWindows, on
~!T::
transparentmode:=!transparentmode
if transparentmode
	Hotkey, ~!T , ClickThroughOn
else
	Hotkey, ~!T , ClickThroughOFF
Return

ClickThroughOn:
MouseGetPos, x, y, A
WinSet, AlwaysOnTop, , A
WinSet, Transparent, 100, A
WinSet, ExStyle, +0x00000020, A
Return


ClickThroughOff:
MouseGetPos, x, y, A
WinSet, AlwaysOnTop, OFF , A
WinSet, Transparent, OFF, A
WinSet, ExStyle, OFF, A
Return

Rohwedder
Posts: 7509
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by Rohwedder » 19 Oct 2021, 01:58

Hallo,
try:

Code: Select all

#SingleInstance, Force
!t::
transparentmode:=!transparentmode
if transparentmode
	Gosub, ClickThroughOn
else
	Gosub, ClickThroughOFF
Return

ClickThroughOn:
MouseGetPos,,, Id
WinSet, AlwaysOnTop, , ahk_id %Id%
WinSet, Transparent, 100, ahk_id %Id%
WinSet, ExStyle, +0x00000020, ahk_id %Id%
Return

ClickThroughOff:
WinSet, AlwaysOnTop, OFF , ahk_id %Id%
WinSet, Transparent, OFF, ahk_id %Id%
WinSet, ExStyle, OFF, ahk_id %Id%
Return

1672019
Posts: 4
Joined: 14 Oct 2021, 22:49

Re: Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by 1672019 » 20 Oct 2021, 09:25

Rohwedder wrote:
19 Oct 2021, 01:58
Hallo,
try:

Code: Select all

#SingleInstance, Force
!t::
transparentmode:=!transparentmode
if transparentmode
	Gosub, ClickThroughOn
else
	Gosub, ClickThroughOFF
Return

ClickThroughOn:
MouseGetPos,,, Id
WinSet, AlwaysOnTop, , ahk_id %Id%
WinSet, Transparent, 100, ahk_id %Id%
WinSet, ExStyle, +0x00000020, ahk_id %Id%
Return

ClickThroughOff:
WinSet, AlwaysOnTop, OFF , ahk_id %Id%
WinSet, Transparent, OFF, ahk_id %Id%
WinSet, ExStyle, OFF, ahk_id %Id%
Return
i Already try the code above and it working !
And i notice that this only works for single window.
How to make it works with multiple window ?
Make array to store data ? Or something ?

also can you explain the change that you made?
instead "Hotkey, ~!T" why use gosub ? whats the difference ?

and why does mousegetpos isnt require anymore on the
off labels ?
thankyou ~

Rohwedder
Posts: 7509
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by Rohwedder » 20 Oct 2021, 15:03

A window with the ClickThrough property is invisible for MouseGetPos!
If several windows are ClickThrough, how will you tell the script which one you want to take away this property?

instead "Hotkey, ~!T" why use gosub ? whats the difference ?
One works, the other does not. You had redirected your hotkey and blocked its way back.

1672019
Posts: 4
Joined: 14 Oct 2021, 22:49

Re: Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by 1672019 » 20 Oct 2021, 18:49

Rohwedder wrote:
20 Oct 2021, 15:03
A window with the ClickThrough property is invisible for MouseGetPos!
If several windows are ClickThrough, how will you tell the script which one you want to take away this property?
How about store ahk_id %Id% into an array?
im thinking of when a certain button on keyboard
were pressed and hold (Ex ctrl being hold) combined with left mouse click on the window
user can make many window that user click having all of the modifier, meanwhile the script will store ahk_id %Id% to some kind of array
so that the script can track what window that the user make the modifier enabled.

Meanwhile to deactivate the function of the window
im thinking that user will press a designated hotkeys (Ex alt + t)
and the script will disable the window based on FIFO (first in first out) %id% that were stored on the array

i don't know any other way to make the script not became over complex

User avatar
Hellbent
Posts: 2102
Joined: 23 Sep 2017, 13:34

Re: Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by Hellbent » 20 Oct 2021, 21:41

You can also create a small gui to list the windows you have applied the change to and select your window from the list.

Code: Select all


AutoGui := {} 

AutoGui.Gui1:= {}
AutoGui.Gui1.Controls := {} 
AutoGui.Gui1.Handles := [] 

Gui, Gui1:New, +AlwaysOnTop +hwndHwnd 
AutoGui.Gui1.Hwnd := hwnd 

;ListBox
Gui, Gui1:Add, ListBox , hwndhwnd , 
AutoGui.Gui1.ControlName := { Hwnd: hwnd , Value: "" }
AutoGui.Gui1.Handles[hwnd] := "ControlName"

;Button
Gui, Gui1:Add, Button , hwndhwnd , Remove
AutoGui.Gui1.ControlName := { Hwnd: hwnd , Value: "Remove" }
AutoGui.Gui1.Handles[hwnd] := "ControlName"
return


numpad1::
	Gui, Gui1:Show, AutoSize NA,  
	return


****The code above is auto generated and is used only as a demo.

Rohwedder
Posts: 7509
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by Rohwedder » 21 Oct 2021, 03:07

Now the ClickThrough is taken away from all windows so that MouseGetPos can recognize them:

Code: Select all

#SingleInstance, Force
!t::
Loop, Parse, TransIds, CSV
	WinSet, ExStyle, -0x00000020, ahk_id %A_LoopField%
MouseGetPos,,, Id
IF !InStr(TransIds, Id ",")
{
	WinSet, AlwaysOnTop, , ahk_id %Id%
	WinSet, Transparent, 100, ahk_id %Id%
	TransIds .= Id ","
}
Else
{
	WinSet, AlwaysOnTop, OFF , ahk_id %Id%
	WinSet, Transparent, OFF, ahk_id %Id%
	TransIds := StrReplace(TransIds, Id ",")
}
Loop, Parse, TransIds, CSV
	WinSet, ExStyle, +0x00000020, ahk_id %A_LoopField%
Return

1672019
Posts: 4
Joined: 14 Oct 2021, 22:49

Re: Help needed to make a Toggle able See Through Always On Top and Click Through code working

Post by 1672019 » 22 Oct 2021, 19:59

Oh thank you for the 2 code above , im gonna try and tinkering with it some more maybe.
Ill ask more if i got confused or stuff.
thanks !~

Post Reply

Return to “Ask for Help (v1)”