I am trying to create a simple script so that I can bind CTRL + SHIFT + ANOTHER_KEY to cycle through my connected servers/channels on Discord, without breaking focus from the active window.
I have managed to find something that works, but I have to release all keys everytime for it work. I would rather be able to keep CTRL and SHIFT held down and just press the third keys to cycle back and forth between channels.
Now, I think I have found where the issue is. For some reason, when I hold down any key, it spams the key rather than holding it for whatever duration I physically hold the key down:
You can see here that it spams every few milliseconds. I had the CONTROL key held down. I am sure at one point AutoHotKey would simply register the key pressed down for as long as it was physically pressed down?
Code: Select all
VK SC Type Up/Dn Elapsed Key Window
-------------------------------------------------------------------------------------------------------------
A2 01D d 0.03 LControl
A2 01D d 0.05 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.05 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.05 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.05 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.03 LControl
A2 01D d 0.05 LControl
A2 01D u 0.00 LControl
74 03F d 0.31 F5
Press [F5] to refresh.
Here is the Discord test script:
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.
SetTitleMatchMode, 2
DetectHiddenWindows, On
controlID := 0
#Persistent
#SingleInstance, Force
; Discord Forward
#If GetKeyState("Shift","p")
Ctrl & =::DiscordNext_Test()
return
#If GetKeyState("Control","p ")
Shift & =::DiscordNext_Test()
return
; Discord Previous
#If GetKeyState("Shift","p")
Ctrl & -::DiscordPrev_Test()
return
#If GetKeyState("Control","p ")
Shift & -::DiscordPrev_Test()
return
; Functions
DiscordNext_Test() {
; Gets the control ID of google chrome
ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Discord
; Focuses on chrome without breaking focus on what you're doing
ControlFocus,,ahk_id %controlID%
SendInput, {Blind}{CTRL UP}
ControlSend, Chrome_RenderWidgetHostHWND1, {CTRL DOWN}{ALT DOWN}{DOWN DOWN}{DOWN UP}{ALT UP}{CTRL UP}, Discord
}
DiscordPrev_Test() {
;MsgBox DiscordPrev-Function
; Gets the control ID of google chrome
ControlGet, controlID, Hwnd,,Chrome_RenderWidgetHostHWND1, Discord
; Focuses on chrome without breaking focus on what you're doing
ControlFocus,,ahk_id %controlID%
SendInput, {Blind}{CTRL UP}
ControlSend, Chrome_RenderWidgetHostHWND1, {CTRL DOWN}{ALT DOWN}{UP DOWN}{UP UP}{ALT UP}{CTRL UP}, Discord
}
Any help appreciated. Thanks.