evilC wrote:What is
thisHotkey? It is undefined. Do you maybe mean
A_ThisHotkey?
I presume you still define the hotkey as before with the hotkey command also
But anyway, we probably do not need to correct that code?
Are you saying you need to do like that, but do it with SetTimer?
OK, so as you are probably aware, SetTimer does not go that fast, only loops do, but you cannot do two loops at once, so you have two options:
1) Do one loop, and fire off the actions from multiple hotkeys from it.
For example, build an array, with the key as the time that the key must be sent, and the value as the key to send.
Something like: (Untested)
Code: Select all
keysToSend := {}
...
keysToSend[A_TickCount] := "{a down}" ; schedule a key down for immediately
keysToSend[A_TickCount + 5] := "{a up}" ; schedule a key up for 5ms time
...
Loop {
for t, k in keysToSend {
nextTime := t
nextKey := k
break
}
if (A_TickCount >= nextTime){
Send % nextKey
keysToSend.Remove(nextKey)
}
Delay(0.001)
}
2) I have a SetTimer replacement that goes down to sub-10ms tickrates
https://autohotkey.com/boards/viewtopic.php?t=29957
However, in order to use it, you need to move to functions
Hello, seems like it was not a good day for me haha.
Sorry for those errors.
About your microtimer i will try it later when i arrive home, thank you for sharing.
The problem is that i still have this error:
When using fast key+click spam it sometimes doesn't detect the release of the key and gets stuck until i press the key again and it detects that i released it.
It doesn't matter how many hotkeys i have, with only 1 it happens.
How to reproduce it:
1_ Using 1 of these codes:
a_ Normal one
Code: Select all
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#InstallKeybdHook
SetStoreCapslockMode, Off
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SetWinDelay, -1
SetControlDelay, -1
key:="q"
Hotkey, $%key%, Fkey
return
#MaxThreadsPerHotkey 1
FKey:
StringTrimLeft thishotkey, a_thisHotkey, 1
while GetKeyState(ThisHotkey, "P")
{
Sendinput {%thisHotkey%}
Delay(0.005)
if Readmemory(skill_address)
{
sendinput {Click}
Delay(0.005)
}
}
return
b. Removing the memory read:
Code: Select all
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#InstallKeybdHook
SetStoreCapslockMode, Off
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SetWinDelay, -1
SetControlDelay, -1
key:="q"
Hotkey, $%key%, Fkey
return
#MaxThreadsPerHotkey 1
FKey:
StringTrimLeft thishotkey, a_thisHotkey, 1
while GetKeyState(ThisHotkey, "P")
{
Sendinput {%thisHotkey%}
Delay(0.005)
sendinput {Click}
Delay(0.005)
}
return
c. Using normal sleeps:
Code: Select all
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#InstallKeybdHook
SetStoreCapslockMode, Off
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SetWinDelay, -1
SetControlDelay, -1
key:="q"
Hotkey, $%key%, Fkey
return
#MaxThreadsPerHotkey 1
FKey:
StringTrimLeft thishotkey, a_thisHotkey, 1
while GetKeyState(ThisHotkey, "P")
{
Sendinput {%thisHotkey%}
sleep, 10
sendinput {Click}
sleep, 10
}
return
d. Using Settimer:
Code: Select all
#NoEnv
#MaxHotkeysPerInterval 99000000
#HotkeyInterval 99000000
#KeyHistory 0
#InstallKeybdHook
SetStoreCapslockMode, Off
ListLines Off
Process, Priority, , A
SetBatchLines, -1
SetKeyDelay, -1, -1
SetDefaultMouseSpeed, 0
SetMouseDelay, -1
SetWinDelay, -1
SetControlDelay, -1
x:=0
key:="q"
Hotkey, $%key%, Fkey
Hotkey, $%key% up, Fup
return
#MaxThreadsPerHotkey 1
FKey:
if x=0
{
settimer, spamkey, 10
x:=1
}
return
spamkey:
Sendinput {%key%}
sleep, 10
sendinput {Click}
sleep, 10
return
Fup:
settimer, spamkey, delete
x:=0
return
2_ Hold q and release, repeat a lot of times. Sometimes it doesn't detect the release of the key and gets stuck spaming q+click
3_ try it wherever you want as it happens on all games/apps and computers that i tried.
I wrote them again here because right now i'm not at home there might be errors. I tried those options and more, but all had the same problem. (tested on 3 pcs and 1 notebook and different games, applications, etc.)