#^Left

Ask gaming related questions (AHK v1.1 and older)
CivilizationAce
Posts: 4
Joined: 24 Feb 2022, 21:44

#^Left

Post by CivilizationAce » 14 Aug 2022, 07:51

I want to be able to switch windows while playing League of Legends, but #^Left doesn't work on its own. So I thought "okay, let's make a script". However, strange things happen when I use the included code below. I'm not sure what I want to do is even possible to be honest, because LoL won't have the focus for the latter part of the script, even if the !Tab would actually work, which it doesn't. The really strange thing is that this script actually loops, as if I hadn't included the $. Please help. I'm totally confused. Is it even possible to have a script that continues to run when the #ifwinactive stops being true?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.


#SingleInstance Force
SendMode Event
SetTitleMatchMode 2

#ifwinactive League of Legends (TM) Client
{
$#^Left::
Send !Tab
Sleep 1000
Send #^Left
Return

$#^Right::
Send !Tab
Sleep 1000
Send #^Right
Return

$#^Up::
Reload
Return
}

User avatar
mikeyww
Posts: 26595
Joined: 09 Sep 2014, 18:38

Re: #^Left

Post by mikeyww » 14 Aug 2022, 08:28

Could try:

Code: Select all

SetTitleMatchMode, 2
#IfWinActive League of Legends
#^Left::Send !{Tab}
#IfWinActive
See https://www.autohotkey.com/docs/Hotkeys.htm#prefixdollar

CivilizationAce
Posts: 4
Joined: 24 Feb 2022, 21:44

Re: #^Left

Post by CivilizationAce » 15 Aug 2022, 00:13

I've refined my objective, because !{Tab} results in a random app having the focus. So I've decided to always have U.GG's app open, so I can use the following script. While this doesn't always reach the right window (which is a bit of a mystery) it does always at least leave the LoL app. Sadly the U.GG app sometimes stops displaying my character's build, so I'm considering changing it to a Chrome window showing the browser version.

Code: Select all

$#^Left::
IfWinExist ahk_exe Overwolf.exe
	winactivate ahk_exe Overwolf.exe
Return

User avatar
mikeyww
Posts: 26595
Joined: 09 Sep 2014, 18:38

Re: #^Left

Post by mikeyww » 15 Aug 2022, 05:41

OK. Something like the following may work.

Code: Select all

winTitle = ahk_exe notepad.exe
#If WinExist(winTitle)
#^Left::WinActivate
#If
If you get some failures, it might mean that your program has multiple windows-- can sometimes be difficult to see that yourself just by looking at the screen-- so you can add or use a window class name (for example).

Post Reply

Return to “Gaming Help (v1)”