Hi All!
As i am very new to this, I am asking for help. Trying to create a very simple keypress script (hold down key spams key until released). I have gotten the following to work, but i would like to also use keys such as F,E and so on.
"#ifWinActive World of Warcraft
{
$1::
Loop
{
if not GetKeyState("1", "P")
break
Send 1
sleep 1
}
return
$2::
Loop
{
if not GetKeyState("2", "P")
break
Send 2
sleep 1
}
return
$3::
Loop
{
if not GetKeyState("3", "P")
break
Send 3
sleep 1
}
return
$4::
Loop
{
if not GetKeyState("4", "P")
break
Send 4
sleep 1
}
return
$5::
Loop
{
if not GetKeyState("5", "P")
break
Send 5
sleep 1
}
return
$6::
Loop
{
if not GetKeyState("6", "P")
break
Send 6
sleep 1
}
return
$7::
Loop
{
if not GetKeyState("7", "P")
break
Send 7
sleep 1
}
return
}"
I have tried the following, as an example (looping the key F), with no success:
$F::
Loop
{
if not GetKeyState("F", "P")
break
Send F
sleep 1
}
return
Hope somewhat can help! Thanks!
Simple loop script (keypress)
Re: Simple loop script (keypress)
Hi,
don't use F, E etc.
Use f, e etc.
AHK converts F automatically to Shift+f.
And please use the code-tag when adding codes.
You can try this one:
I think this one will work as well:
P.S: Sleep times like 1 ms make no sense in my opinion.
Regards
don't use F, E etc.
Use f, e etc.
AHK converts F automatically to Shift+f.
And please use the code-tag when adding codes.
You can try this one:
Code: Select all
$f::
Loop
{
if not GetKeyState("F", "P")
{
break
}
Send f
Sleep 50
}
return
Code: Select all
$f::
while GetKeyState("F", "P")
{
Send f
Sleep, 50
}
return
Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Re: Simple loop script (keypress)
Thank you so much, Scr1pter, for your prompt and helpful reply.
Another quick question. Would it be possible to add a "pause" command to the script, and if so, can i bind it to mousekey 5? I believe the key is named XButton2 in AHK. I have tried the following with no success:
""XButton 2::
Suspend
Pause,,1
return""
Another quick question. Would it be possible to add a "pause" command to the script, and if so, can i bind it to mousekey 5? I believe the key is named XButton2 in AHK. I have tried the following with no success:
""XButton 2::
Suspend
Pause,,1
return""
Re: Simple loop script (keypress)
This should work for you:
Code: Select all
XButton2:: Pause
Re: Simple loop script (keypress)
Hi,
These two scripts work for me.
However, I don't know if they are "best practice".
Anyway, I suggest you not to work with XButton.
I, for example, always remap my mouse buttons within my Logitech Gaming Software.
If you have 8 extra mouse buttons for example, you can map them to Numpad keys.
Then, instead of working with XButton, you can work with Numpad keys.
I tried it with rbutton by the way, not with xbutton2.
P.S. And remember to use the code-tags
Regards
These two scripts work for me.
However, I don't know if they are "best practice".
Anyway, I suggest you not to work with XButton.
I, for example, always remap my mouse buttons within my Logitech Gaming Software.
If you have 8 extra mouse buttons for example, you can map them to Numpad keys.
Then, instead of working with XButton, you can work with Numpad keys.
Code: Select all
$f::
if pause = false
{
while GetKeyState("F", "P")
{
Send f
Sleep, 50
}
}
return
XButton2::
while GetKeyState("XButton2", "P")
{
pause = true
}
pause = false
return
P.S. And remember to use the code-tags
Regards
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Who is online
Users browsing this forum: OrangeCat and 156 guests