If WinActive Send script not working Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
scharyu
Posts: 9
Joined: 20 Oct 2021, 07:14

If WinActive Send script not working

Post by scharyu » 25 Nov 2022, 02:16

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?

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

Re: If WinActive Send script not working

Post by Rohwedder » 25 Nov 2022, 06:15

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

scharyu
Posts: 9
Joined: 20 Oct 2021, 07:14

Re: If WinActive Send script not working

Post by scharyu » 27 Nov 2022, 20:28

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

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

Re: If WinActive Send script not working  Topic is solved

Post by Rohwedder » 28 Nov 2022, 03:38

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

scharyu
Posts: 9
Joined: 20 Oct 2021, 07:14

Re: If WinActive Send script not working

Post by scharyu » 28 Nov 2022, 08:58

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.

Post Reply

Return to “Ask for Help (v1)”