Cycling Through Open Windows With the RShift + Home Combination

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Cycling Through Open Windows With the RShift + Home Combination

Post by Alexander2 » 04 Oct 2022, 11:38

When I use the following script to cycle through existing open windows by pressing RShift + Home, the script also changes the keyboard language by sending Alt + Shift (which is the standard key combination for changing the keyboard language). This happens in about half of the times when I press RShift + Home to run the script. Does anyone know how to use the RShift + Home combination without changing the keyboard language?

Code: Select all

>+home:: ; RShift + Home
send {lalt down}{Tab}
KeyWait rshift
send {lalt Up}
return

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

Re: Cycling Through Open Windows With the RShift + Home Combination

Post by mikeyww » 04 Oct 2022, 18:39

Perhaps:

Code: Select all

*>+Home::Send {Alt down}{Tab}
!RShift Up::Send {Alt up}

Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: Cycling Through Open Windows With the RShift + Home Combination

Post by Alexander2 » 05 Oct 2022, 03:30

mikeyww wrote:
04 Oct 2022, 18:39
Perhaps:

Code: Select all

*>+Home::Send {Alt down}{Tab}
!RShift Up::Send {Alt up}
I have tested this script on my computer with Windows 11. The keyboard languages (English and Russian) still switch when the script is run. When you test the script on your computer, does the same happen (if you have more than one keyboard language)?
Untitled.png
Untitled.png (5.92 KiB) Viewed 459 times

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

Re: Cycling Through Open Windows With the RShift + Home Combination

Post by mikeyww » 05 Oct 2022, 05:59

I'm on Win 10. I was surprised to find that RAlt+LShift switched keyboards. I wonder if this is a Windows bug.

The following seemed to work.

Code: Select all

If !Instr(A_AhkPath, "UIA") && !(DllCall("GetCommandLine", "str") ~= " /restart(?!\S)") {
 SplitPath, A_AhkPath, fn ; https://www.autohotkey.com/docs/Program.htm#Installer_uiAccess
 If FileExist(ahk := StrReplace(A_AhkPath, fn, "AutoHotkeyU64_UIA.exe")) {
  Try Run "%ahk%" /restart "%A_ScriptFullPath%"
  ExitApp
 } Else MsgBox, 48, Failure, File not found.`n`n%ahk%
}
*>+Home::Send {Blind}{Shift up}{Alt down}{Tab}
!RShift Up::Send {Alt up}
Explained: Blind mode
Modifier keys are restored differently to allow a Send to turn off a hotkey's modifiers even if the user is still physically holding them down.

Alexander2
Posts: 348
Joined: 27 Apr 2019, 17:38

Re: Cycling Through Open Windows With the RShift + Home Combination

Post by Alexander2 » 05 Oct 2022, 12:09

I was surprised to find that RAlt+LShift switched keyboards. I wonder if this is a Windows bug.
When I press RAlt + LShift, the keyboard languages are not switched. However, when I press RShift + Home to run the following script, the languages are switched:

Code: Select all

*>+Home::Send {Alt down}{Tab}
!RShift Up::Send {Alt up}
The reason for this may be that although RAlt + LShift (LEFT Shift) does not switch languages, LAlt + RShift (RIGHT Shift) does this.
The above script inadvertently triggers the LAlt + RShift key combination.
When I run your other script below, the languages are not switched. Thank you for the solution.

Code: Select all

*>+Home::Send {Blind}{Shift up}{Alt down}{Tab}
!RShift Up::Send {Alt up}
I have run the above script without the following code which you had put before it. Is this code necessary, and what is its purpose?

Code: Select all

If !Instr(A_AhkPath, "UIA") && !(DllCall("GetCommandLine", "str") ~= " /restart(?!\S)") {
 SplitPath, A_AhkPath, fn ; https://www.autohotkey.com/docs/Program.htm#Installer_uiAccess
 If FileExist(ahk := StrReplace(A_AhkPath, fn, "AutoHotkeyU64_UIA.exe")) {
  Try Run "%ahk%" /restart "%A_ScriptFullPath%"
  ExitApp
 } Else MsgBox, 48, Failure, File not found.`n`n%ahk%
}

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

Re: Cycling Through Open Windows With the RShift + Home Combination

Post by mikeyww » 05 Oct 2022, 12:15

If you are not switching to "elevated" programs such as Windows Task Manager, you can omit that code.

Explained: https://www.autohotkey.com/docs/FAQ.htm#uac

Post Reply

Return to “Ask for Help (v1)”