Require for help to make a spam script when the key is pressed

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Require for help to make a spam script when the key is pressed

Post by healar4 » 13 Aug 2022, 11:55

Hello guys, can anyone tell me how to make this seript?
The thing I want to do is when u hold mouse4, it automatically starts to spam numpad4 and i can change the hotkey speed time
Hope u can help me :) )
Last edited by gregster on 13 Aug 2022, 11:56, edited 1 time in total.
Reason: Thank you for using a codebox, but those boxes should be put around code, if code is present, not around normal text.

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

Re: Require for help to make a spam script when the key is pressed

Post by mikeyww » 13 Aug 2022, 12:33

Welcome to this AutoHotkey forum!

Code: Select all

delay = 25

XButton1::
SetKeyDelay, delay
While GetKeyState("XButton1", "P")
 Send {Numpad4}
Return

healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 13 Aug 2022, 12:45

mikeyww wrote:
13 Aug 2022, 12:33
Welcome to this AutoHotkey forum!

Code: Select all

delay = 25

XButton1::
SetKeyDelay, delay
While GetKeyState("XButton1", "P")
 Send {Numpad4}
Return
thanks for your help! but how can i change numpad4 to my keyboard right number 4?


healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 13 Aug 2022, 13:05

mikeyww wrote:
13 Aug 2022, 13:00
It should be the same, but here are the key names. https://www.autohotkey.com/docs/commands/Send.htm#keynames
doesn't work for me :) do u have way to get keyboard right numpad 4 value?

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Require for help to make a spam script when the key is pressed

Post by boiler » 13 Aug 2022, 13:12

That is the right (correct) key name. Perhaps what you need is NumpadLeft.

healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 14 Aug 2022, 00:56

boiler wrote:
13 Aug 2022, 13:12
That is the right (correct) key name. Perhaps what you need is NumpadLeft.
i know that is correct keyname, if i do XButton1::Numpad4 it will press right numpad4

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Require for help to make a spam script when the key is pressed

Post by boiler » 14 Aug 2022, 03:12

What do you mean by “right numpad4”? Do you mean you want it to press the right arrow key followed by the Numpad4 key, like below?

Code: Select all

XButton1::Send, {Right}{Numpad4}

healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 14 Aug 2022, 04:21

boiler wrote:
14 Aug 2022, 03:12
What do you mean by “right numpad4”? Do you mean you want it to press the right arrow key followed by the Numpad4 key, like below?

Code: Select all

XButton1::Send, {Right}{Numpad4}
i mean when i press mouse4 it will spam numpad4 key (keyboard right number 4)

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

Re: Require for help to make a spam script when the key is pressed

Post by mikeyww » 14 Aug 2022, 04:44

When you tested my script in Notepad, what did it do? A description beyond "doesn't work for me" would be useful.

healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 14 Aug 2022, 04:48

mikeyww wrote:
14 Aug 2022, 04:44
When you tested my script in Notepad, what did it do? A description beyond "doesn't work for me" would be useful.
your script will spam Numpad4 key( the left one), what i want is spam Numpad4 key (the right one)

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

Re: Require for help to make a spam script when the key is pressed

Post by mikeyww » 14 Aug 2022, 05:08

You might want to check the scan code. You could then use it in your Send command. Some of the forum posts about multiple input devices may also help you.

healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 14 Aug 2022, 05:32

mikeyww wrote:
14 Aug 2022, 05:08
You might want to check the scan code. You could then use it in your Send command. Some of the forum posts about multiple input devices may also help you.
i have no idea how to do this :( can u give me an example?

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

Re: Require for help to make a spam script when the key is pressed

Post by mikeyww » 14 Aug 2022, 06:23

EDIT: More of the same....

Code: Select all

/* Scan code ----------------------------------------------------
This script gets a scan code from a key.
It copies the corresponding Send command to the clipboard.
By mikeyww on 14 August 2022 • For AutoHotkey 1.1.34.03
https://www.autohotkey.com/boards/viewtopic.php?p=477399#p477399
-----------------------------------------------------------------
*/
#InstallKeybdHook
Menu, main, Add, Exit, GuiEscape
Menu, main, Add, List
Menu, main, Add, KeyHistory, History
Menu, main, Add, About
Gui, +AlwaysOnTop
Gui, Font, s10
Gui, Menu, main
Gui, Add, Text  , w230   , Press a key.
Gui, Add, Hotkey, wp vhk   gGet
Gui, Add, Text  , wp y+20, Scan code:
Gui, Add, Edit  , wp vsc   ReadOnly
Gui, Add, Edit  , wp vsc2  ReadOnly
Gui, Add, Text  , wp y+20, Send command:
Gui, Add, Edit  , wp vcmd  ReadOnly
Gui, Show,, Scan code
Return

History:
KeyHistory
Return

Get:
Gui, Submit, NoHide
GuiControl,, sc , % sc        := Format("{:03X}", GetKeySC(hk))
GuiControl,, sc2, % sc2       := "SC" sc
GuiControl,, cmd, % Clipboard := "Send {" sc2 "}"
Return

List:
FileRecycle, % out := A_ScriptDir "\scanCodes.txt"
Loop, 0xFF {
 n    := 0x100 - A_Index
 vk   := Format("{:02X}", n)
 key  := "VK" vk
 sc   := GetKeySC(key)
 name := GetKeyName(key)
 (name != "") && list .= Format("{:03}  {}  {:03X}  {}", n, vk, sc, name) "`n"
}
Sort, list
FileAppend, % Trim("N    VK  SC   Key`n---  --  ---  ------------`n" list, "`n"), %out%
Run, %out%
Return

About:
MsgBox, 64, About,
(
This script gets a scan code from a key.
It copies the corresponding Send command to the clipboard.
By mikeyww on 14 August 2022 • For AutoHotkey 1.1.34.03
https://www.autohotkey.com/boards/viewtopic.php?p=477399#p477399

Press CTRL-C to copy this box's text to the Windows clipboard.
)
Return

GuiClose:
GuiEscape:
ExitApp
Last edited by mikeyww on 14 Aug 2022, 08:03, edited 9 times in total.

User avatar
MrDodel
Posts: 96
Joined: 28 Apr 2021, 09:03
Location: Event Horizon

Re: Require for help to make a spam script when the key is pressed

Post by MrDodel » 14 Aug 2022, 06:36

The last post in this thread may help:

viewtopic.php?f=76&t=107250
So much universe, and so little time. GNU Sir Terry.

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Require for help to make a spam script when the key is pressed

Post by boiler » 14 Aug 2022, 07:23

healar4 wrote: your script will spam Numpad4 key( the left one), what i want is spam Numpad4 key (the right one)
Your keyboard has two Numpad4 keys?

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

Re: Require for help to make a spam script when the key is pressed

Post by Rohwedder » 14 Aug 2022, 07:29

Hallo,
this script viewtopic.php?f=76&t=107250
is only the beginning of SKAN's old, but very interesting topic:
https://www.autohotkey.com/board/topic/21105-crazy-scripting-scriptlet-to-find-scancode-of-a-key/

healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 14 Aug 2022, 07:38

boiler wrote:
14 Aug 2022, 07:23
healar4 wrote: your script will spam Numpad4 key( the left one), what i want is spam Numpad4 key (the right one)
Your keyboard has two Numpad4 keys?
nvm, already got the keyname

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

Re: Require for help to make a spam script when the key is pressed

Post by mikeyww » 14 Aug 2022, 08:13

What was the key name?

healar4
Posts: 10
Joined: 13 Aug 2022, 11:44

Re: Require for help to make a spam script when the key is pressed

Post by healar4 » 14 Aug 2022, 08:42

mikeyww wrote:
14 Aug 2022, 08:13
What was the key name?
SC04B

Post Reply

Return to “Ask for Help (v1)”