Keyboard Spamming and Discord

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cattywampus
Posts: 6
Joined: 10 Oct 2017, 11:55

Keyboard Spamming and Discord

25 May 2018, 12:45

Hi there

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.
I think if I could find out a way to make AutoHotKey register keys pressed down for as long as they are physically held down, the script below might actually work without me needing to release CONTROL and SHIFT each time.

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.
Rohwedder
Posts: 7643
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Keyboard Spamming and Discord

26 May 2018, 01:33

Hallo,
keep CTRL and SHIFT held down and just release and press Q:

Code: Select all

^+q::
	No++
	ToolTip, % No
	KeyWait q
Return
cattywampus
Posts: 6
Joined: 10 Oct 2017, 11:55

Re: Keyboard Spamming and Discord

27 May 2018, 12:07

Doesn't make any difference.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], ReyAHK and 279 guests