Page 1 of 1

If WinActive Send script not working

Posted: 25 Nov 2022, 02:16
by scharyu
I tried to make a very simple script that triggers a hotkey (Alt+Shift+0) for changing the keyboard layout to the specific language when a particular app is active.

According to WinActive and Send I did this:

Code: Select all

if WinActive("ahk_exe steam.exe")
	Send !+0
That's it. But it doesn't work. It simple doesn't even launch (I'm not seeing the script in the System Tray). Am I so stupid, what is wrong then?

Re: If WinActive Send script not working

Posted: 25 Nov 2022, 06:15
by Rohwedder
Hallo,
your script checks exactly once if a window of steam.exe is active, sends if so (Alt+Shift+0) , and then exits.
Perhaps:

Code: Select all

WinWaitActive, ahk_exe steam.exe
	Send !+0

Re: If WinActive Send script not working

Posted: 27 Nov 2022, 20:28
by scharyu
Rohwedder wrote: Hallo,
your script checks exactly once if a window of steam.exe is active, sends if so (Alt+Shift+0) , and then exits.
Perhaps:

Code: Select all

WinWaitActive, ahk_exe steam.exe
	Send !+0
Vielen Dank, it works.

By the way I have a little additional question. I have two another scripts (with one of them you've helped me btw), so it is three scripts in total that are always active. Can I combine them in one so there won't be a mess in a system tray?

First:
Spoiler
Second:
Spoiler
Third:
Spoiler

Re: If WinActive Send script not working  Topic is solved

Posted: 28 Nov 2022, 03:38
by Rohwedder
Then (untested):

Code: Select all

XV := (A_ScreenWidth/2560)**1.1
YV := (A_ScreenHeight/1600)**1.1
GroupAdd, ResizedWin, ahk_exe telegram.EXE
GroupAdd, ResizedWin, ahk_exe Discord.EXE
GroupAdd, ResizedWin, ahk_exe WhatsApp.EXE
GroupAdd, ResizedWin, ahk_exe Notepad.EXE
GroupAdd, GameActive, ahk_exe DetroitBecomeHuman.EXE
GroupAdd, GameActive, ahk_exe ModernWarfare.EXE
GroupAdd, GameActive, ahk_exe TheAscent-Win64-Shipping.EXE
GroupAdd, GameActive, ahk_exe TheAscent.EXE
GroupAdd, GameActive, ahk_exe witcher3.EXE
GroupAdd, GameActive, ahk_exe r5apex.EXE
GroupAdd, GameActive, ahk_exe bf4.EXE
GroupAdd, GameActive, ahk_exe bf2042.EXE
GroupAdd, GameActive, ahk_exe Everspace2.EXE
GroupAdd, GameActive, ahk_exe ES2-Win64-Shipping.EXE
GroupAdd, GameActive, ahk_exe csgo.EXE
GroupAdd, GameActive, ahk_exe Human.EXE
GroupAdd, GameActive, ahk_exe cod.EXE
Steam := Resized := False
SetTimer, Windows, 250
Windows:
IF (!Steam And WinActive("ahk_exe steam.exe"))
{
	Steam := True
	Send !+0
}
Else IF (Steam And !WinActive("ahk_exe steam.exe"))
	Steam := False
IF (!Resized And WinExist("ahk_group ResizedWin"))
{
	Resized := True
	WinMove, , , , , 1417*XV, 915*YV
}
Else IF (Resized And !WinExist("ahk_group ResizedWin"))
	Resized := False
Return

#IfWinActive, ahk_group GameActive
*LWin::Return
<^Shift::return
^Esc::return
#If

Re: If WinActive Send script not working

Posted: 28 Nov 2022, 08:58
by scharyu
Rohwedder wrote: Then (untested):
It works perfectly. Don't know how to thank you. And didn't thought that combinig these scripts would be so complicated...

Thank you so much.