A Noob trying to code Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Flashrabbit
Posts: 3
Joined: 17 Apr 2018, 10:21

A Noob trying to code

25 Apr 2018, 14:04

Hello, first sorry if my english is pretty basic. It's been a week that I'm trying to made a script by myself (tchecking around the web) but I'ts a first for me and it gets harder and harder and makes my minds blown right now ^^'

I'ts why I'm calling for your help. What I want is a "simple" script that allow me to repeat a Key when I just press it twice, and then stop when I press again or when any key is pressed.

In that part of code, it's processing when I press the key once, I did not suceed to make it with double tap.
(Im on azerty KeyBoard)

Code: Select all

$&::
RepeatKey:=! RepeatKey
If RepeatKey=1
SetTimer, SendTheKey, 2400
else
SetTimer, SendTheKey, Off

SendTheKey:
Sendinput &
Return
The second deal is about to make it's stop when any key is pressed (or just, z,q,s,d it's enought)

Solutions I got on the web does not work for me,or I surely missed something. So I tried this (make you laugh) :

Code: Select all

$z::
send z
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return

$q::
send q
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return

$s::
send s
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return

$d::
send d
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return
It's working for stopping the key from repeating, but as I had to remap Z,Q,S,D keys, now it's not working InGame. (But It does in chat, so it's not about game blocking) I guess why, but I'm far to know how to resolve it and I tried lot of things.

So, thanks in advance for your help guys !

PS : There is my full code, in case you find errors, others parts are weirds but it's seems to work as I want it to :

Code: Select all

#singleinstance

#MaxThreadsPerHotkey, 2

toggle=0
return

rbutton::
toggle:=!toggle
if toggle=1
click ,right ,down
if toggle=0
click, right, up
return

$&::
RepeatKey:=! RepeatKey
If RepeatKey=1
SetTimer, SendTheKey, 2400
else
SetTimer, SendTheKey, Off

SendTheKey:
Sendinput &
Return

$z::
send z
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return

$q::
send q
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return

$s::
send s
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return

$d::
send d
if repeatkey
repeatkey=0
SetTimer, SendTheKey, Off
return

#If, A_IsPaused
Numpad5::
suspend
pause
return
#If
Numpad5::
suspend
pause
return

A_AhkUser
Posts: 1147
Joined: 06 Mar 2017, 16:18
Location: France
Contact:

Re: A Noob trying to code  Topic is solved

26 Apr 2018, 15:25

Hi Flashrabbit,

Try this:

Code: Select all

$&::
if ((A_ThisHotkey = A_PriorHotkey) && (A_TimeSincePriorHotkey < 200)) ; https://www.autohotkey.com/docs/FAQ.htm#DoublePress
	SetTimer, sendTheKey, 2400
return

~z:: ; the use of the tilde (~) prevent the key's native function from being blocked
~q::
~s::
~d:: ; multiple hotkeys can be stacked vertically if they intended to perform the same action
SetTimer, sendTheKey, Off
return

sendTheKey:
SendInput, &
return
Hope this helps.
my scripts
Flashrabbit
Posts: 3
Joined: 17 Apr 2018, 10:21

Re: A Noob trying to code

27 Apr 2018, 03:31

Thank you it's working ! For the biggest part actually... the old script allowed me to stop the timer when I pushed & again. Sorry I did not specify this but it would be great if I could stop the timer by pressing & too (once and twice).
I will try by myself but I'm not sure to do it properly, thank you again.
Flashrabbit
Posts: 3
Joined: 17 Apr 2018, 10:21

Succeeded

27 Apr 2018, 04:56

Code: Select all

~$&::
if ((A_ThisHotkey = A_PriorHotkey) && (A_TimeSincePriorHotkey < 200))
	SetTimer, sendTheKey, 2300
else
SetTimer, sendTheKey, off
return

~z::
~q::
~s::
~d::
SetTimer, sendTheKey, Off
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Aqualest, mikeyww and 279 guests