make window on second screen transparent

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
its_senna
Posts: 4
Joined: 23 Jun 2022, 07:33

make window on second screen transparent

Post by its_senna » 23 Jun 2022, 07:43

I have searched the internet for an answer but could not vind it.
al I want is when I pusk button Joy2 that the top window on my second screen becomes transparent, even when it is not active and i am doing somthing on my first screen,
I already have it that when i push Joy2 that the transparency turns of and on
(If you want to see the whole code, just ask)

Code: Select all

Joy2::
if GetKeyState("F13")
	run, cmd.exe, C:\Users\Ryzen
else if GetKeyState("F14")
	run C:\Program Files (x86)\Battle.net\Battle.net Launcher.exe
else if GetKeyState("F15")
	run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -incognito
else
	WinGet, currentTransparency, Transparent, A
	if (currentTransparency = OFF)
		WinSet, Transparent, 200, A
	else
		WinSet, Transparent, OFF, A
return

[Mod edit: Added [code][/code] tags. Please use them yourself when posting code.]
Last edited by its_senna on 23 Jun 2022, 12:25, edited 1 time in total.

its_senna
Posts: 4
Joined: 23 Jun 2022, 07:33

Re: make window on second screen transparent

Post by its_senna » 23 Jun 2022, 11:41

Code: Select all


#Persistent  ; Keep this script running until the user explicitly exits it.
SetTimer, WatchAxis, 10
return

WatchAxis:
xas := GetKeyState("JoyX")
yas := GetKeyState("JoyY")


if (yas = 0)					; UP
	SetTimer, WaitForUp, 10
else if (yas = 100)				; DOWN
	SetTimer, WaitForDown, 10
else if (xas = 100)				; RIGHT
	SetTimer, WaitForRight, 10
else if (xas = 0)				; LEFT
	SetTimer, WaitForLeft, 10
return


WaitForUp:							;Up clean
if (GetKeyState("JoyY") = 0)
	return
send, {F13 up}{F14 up}{F15 up}
SetTimer, WaitForUp, Off
Progress, B X2460 Y1365 H35 W100 zh0 fs16 CTWhite CW8A2Be2, Folders,, Profile
WinSet, Transparent, 150, Profile
SetTimer, Off, 2000
return

WaitForDown:						;Down F13
if (GetKeyState("JoyY") = 100)
	return
send, {F14 up}{F15 up}
send {F13 down}
SetTimer, WaitForDown, Off
Progress, B X2460 Y1365 H35 W100 zh0 fs16 CTWhite CW8A2Be2, Server,, Profile
WinSet, Transparent, 150, Profile
SetTimer, Off, 2000
return

WaitForRight:						;Right F14
if (GetKeyState("JoyX") = 100)
	return
send, {F13 up}{F15 up}
send {F14 down}
SetTimer, WaitForRight, Off
Progress, B X2460 Y1365 H35 W100 zh0 fs16 CTWhite CW8A2Be2, Games,, Profile
WinSet, Transparent, 150, Profile
SetTimer, Off, 2000
return

WaitForLeft:						;Left F15
if (GetKeyState("JoyX") = 0)
	return
send, {F13 up}{F14 up}
send {F15 down}
SetTimer, WaitForLeft, Off
Progress, B X2460 Y1365 H35 W100 zh0 fs16 CTWhite CW8A2Be2, Google,, Profile
WinSet, Transparent, 150, Profile
SetTimer, Off, 2000
return


Off:
Progress, Off
SetTImer, Off, Off
Return



Joy1::
if GetKeyState("F13")
	run D:\Program Files\FileZilla FTP Client\filezilla.exe
else if GetKeyState("F14")
	run D:\Program Files (x86)\Epic Games\Launcher\Portal\Binaries\Win32\EpicGamesLauncher.exe
else if GetKeyState("F15")
	run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -incognito
else
	run shell:::{645FF040-5081-101B-9F08-00AA002F954E}			;bin folder
return

Joy2::
if GetKeyState("F13")
	run, cmd.exe, C:\Users\Ryzen
else if GetKeyState("F14")
	run C:\Program Files (x86)\Battle.net\Battle.net Launcher.exe
else if GetKeyState("F15")
	run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -incognito
else
	WinGet, currentTransparency, Transparent, A
	if (currentTransparency = OFF)
		WinSet, Transparent, 200, A
	else
		WinSet, Transparent, OFF, A
return

Joy9::
if GetKeyState("F13")
	run D:\Program Files\PuTTY\putty.exe -load raspi-media-server
else if GetKeyState("F14")
	run C:\Program Files (x86)\Steam\steam.exe
else if GetKeyState("F15")
	run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -incognito
else
	run shell:::{20d04fe0-3aea-1069-a2d8-08002b30309d}			;this pc folder
return

Joy10::
if GetKeyState("F13")
	run https://www.sennaveldhuizen.nl
else if GetKeyState("F14")
	run C:\Program Files (x86)\Ubisoft\Ubisoft Game Launcher\UbisoftConnect.exe
else if GetKeyState("F15")
	run C:\Program Files (x86)\Google\Chrome\Application\chrome.exe -incognito
else
	run shell:::{374DE290-123F-4565-9164-39C4925E467B}		;downloads folder
return

User avatar
littlegandhi1199
Posts: 195
Joined: 29 Aug 2016, 23:58

Re: make window on second screen transparent

Post by littlegandhi1199 » 26 Jun 2022, 01:18

So what you are looking for is the window Z Order.

Code: Select all

hwnd := WinActive("A")
DisplayVar =
loop
{
hwnd := DllCall("GetWindow",uint,hwnd,int,2) ; 2 = GW_HWNDNEXT
; GetWindow() returns a decimal value, so we have to convert it to hex
SetFormat,integer,hex
hwnd += 0
SetFormat,integer,d
; GetWindow() processes even hidden windows, so we move down the z order until the next visible window is found
if (DllCall("IsWindowVisible",uint,hwnd) = 1)
	Found = 1
Else
	Found = 0
	
IfWinExist, ahk_id %hwnd%
{
Truevar = 1
WinGetTitle, Title, ahk_id %hwnd%

If (Title != "")
{
DisplayVar = %DisplayVar%%Title%%A_Tab%Exists=%Truevar%%A_Tab%Visible=%Found%%A_Tab%`n
msgbox, %DisplayVar%
}
}
}
Here is a crappy example that I can't figure out entirely how to call and finish cleanly after every request. If you hit Win+D all the windows would be minimized so this would show nothing and it's also a little flaky...(as far as I can tell :crazy: ) but once it works it should show a matching list of windows in same order as when you hold down ALT + TAB.

And then WinGetPos, X, Y whose position is > Greater than the dimensions of your first screen's resolution (If working from left to right).
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285

its_senna
Posts: 4
Joined: 23 Jun 2022, 07:33

Re: make window on second screen transparent

Post by its_senna » 26 Jun 2022, 15:09

littlegandhi1199 wrote:
26 Jun 2022, 01:18
So what you are looking for is the window Z Order.

Code: Select all

hwnd := WinActive("A")
DisplayVar =
loop
{
hwnd := DllCall("GetWindow",uint,hwnd,int,2) ; 2 = GW_HWNDNEXT
; GetWindow() returns a decimal value, so we have to convert it to hex
SetFormat,integer,hex
hwnd += 0
SetFormat,integer,d
; GetWindow() processes even hidden windows, so we move down the z order until the next visible window is found
if (DllCall("IsWindowVisible",uint,hwnd) = 1)
	Found = 1
Else
	Found = 0
	
IfWinExist, ahk_id %hwnd%
{
Truevar = 1
WinGetTitle, Title, ahk_id %hwnd%

If (Title != "")
{
DisplayVar = %DisplayVar%%Title%%A_Tab%Exists=%Truevar%%A_Tab%Visible=%Found%%A_Tab%`n
msgbox, %DisplayVar%
}
}
}
Here is a crappy example that I can't figure out entirely how to call and finish cleanly after every request. If you hit Win+D all the windows would be minimized so this would show nothing and it's also a little flaky...(as far as I can tell :crazy: ) but once it works it should show a matching list of windows in same order as when you hold down ALT + TAB.

And then WinGetPos, X, Y whose position is > Greater than the dimensions of your first screen's resolution (If working from left to right).
thank you this is helping a lot.
but is there also a way to add a variable so it only pick the windows with x > 2560
(I have 2, 2560x1440 monitors and the right one is my second)
I was testing this code and trying to set it in my code but it also grabs windows on my first monitor that are visible but not active

User avatar
littlegandhi1199
Posts: 195
Joined: 29 Aug 2016, 23:58

Re: make window on second screen transparent

Post by littlegandhi1199 » 26 Jun 2022, 19:22

WinGetPos, WinX, WinY, , , ahk_id %hwnd%
If (WinX >= 2560)


I figured you would find a better "Z-Order" function but yeah this will work too placed at the msgbox line
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285

its_senna
Posts: 4
Joined: 23 Jun 2022, 07:33

Re: make window on second screen transparent

Post by its_senna » 30 Jun 2022, 04:33

littlegandhi1199 wrote:
26 Jun 2022, 19:22
WinGetPos, WinX, WinY, , , ahk_id %hwnd%
If (WinX >= 2560)


I figured you would find a better "Z-Order" function but yeah this will work too placed at the msgbox line

Code: Select all

F12::
hwnd := WinActive("A")
DisplayVar =
loop
{
hwnd := DllCall("GetWindow",uint,hwnd,int,2) ; 2 = GW_HWNDNEXT
; GetWindow() returns a decimal value, so we have to convert it to hex
SetFormat,integer,hex
hwnd += 0
SetFormat,integer,d
; GetWindow() processes even hidden windows, so we move down the z order until the next visible window is found
if (DllCall("IsWindowVisible",uint,hwnd) = 1)
{
WinGetPos, WinX, WinY, , , ahk_id %hwnd%
If (WinX >= 2550)
{
IfWinExist, ahk_id %hwnd%
{
Truevar = 1
WinGetTitle, Title, ahk_id %hwnd%

If (Title != "")
{
WinGet, currentTransparency, Transparent, ahk_id %hwnd%
if (currentTransparency = OFF)
	WinSet, Transparent, 200, ahk_id %hwnd%
else
	WinSet, Transparent, OFF, ahk_id %hwnd%
break
}
}
}
}
}
return
It took me some time but now I got it to work, sort of
when I load the script it works but when I change a tab or place an other window on the screen it stops working,
and I can't figure out why it stops working.

User avatar
littlegandhi1199
Posts: 195
Joined: 29 Aug 2016, 23:58

Re: make window on second screen transparent

Post by littlegandhi1199 » 04 Oct 2022, 11:45

A simple fix may just having a hotkey that issues the "Reload" command to restart the script if it does infact work everytime on boot.


F9::reload
Script Backups on every Execution :mrgreen:
https://www.autohotkey.com/boards/viewtopic.php?f=6&t=75767&p=328155#p328155

Scrabble Solver 4-15 letter word outputs ( :crazy: # of inputs)
https://www.autohotkey.com/boards/viewtopic.php?f=19&t=34285

Post Reply

Return to “Ask for Help (v1)”