Help, i Do'nt know
-
- Posts: 1
- Joined: 20 Jan 2018, 13:35
Help, i Do'nt know
How to make a script to click a key 6 times?
Re: Help, i Do'nt know
Hello BrazilianHunter.
Welcome to the AutoHotkey Community forums.
You can use Loop command to repeat single-commands or blocks of code. Also, to send keystrokes, you can use the Send command.
See the example below on how to do it (the example will press the key j 6 times).
If you cannot see the effect in place here, it is because the key pressing happens as soon as you execute the script. If you wish the script to wait so that you open a a window or something like that, you can use Sleep command.
The example below waits 10 seconds before pressing the key j 6 times.
If you need further help, feel free to post again. Also, check out our portuguese subforums if you are brazilian and wish to talk about AutoHotkey in portuguese.
Best wishes
Welcome to the AutoHotkey Community forums.
You can use Loop command to repeat single-commands or blocks of code. Also, to send keystrokes, you can use the Send command.
See the example below on how to do it (the example will press the key j 6 times).
Code: Select all
Loop, 6
Send j
The example below waits 10 seconds before pressing the key j 6 times.
Code: Select all
Sleep, 10000
Loop, 6
Send j
Best wishes
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Archmage Gray - A fantasy shooter game fully coded in AutoHotkey
Re: Help, i Do'nt know
Isn't he/she hunting Brazilians??check out our portuguese subforums if you are brazilian and wish to talk about AutoHotkey in portuguese.
Re: Help, i Do'nt know
BoBo wrote:Isn't he/she hunting Brazilians??
- divanebaba
- Posts: 805
- Joined: 20 Dec 2016, 03:53
- Location: Diaspora
Re: Help, i Do'nt know
I think BrazilianHunter wants to realize the following:OrPressing one times triggers six times.
Code: Select all
$j::
sendinput jjjjjj
return
Code: Select all
$j::
loop 6
{
sendinput j
sleep 100
}
return
Einfach nur ein toller Typ.
Re: Help, i Do'nt know
found this , send also first ctrl / alt / win and then key
https://autohotkey.com/boards/viewtopic.php?f=5&t=41768
another example
https://autohotkey.com/boards/viewtopic.php?f=5&t=41768
Code: Select all
;- https://autohotkey.com/boards/viewtopic.php?f=5&t=41768
;-----------------------------------------------------------
;- test example for f1 , send ctrl+a twice
;- open notepad with text , then click F1 , mark all text blue , then remove with mouse click , and after 5 seconds mark it again
f1::
loop,2
{
sendKey("control", "a")
sleep,5000
}
return
f2:: sendKey("alt", "a")
f3:: sendKey("win", "r")
f4:: sendKey("shift", "s")
;--------------------------------------------------
sendKey(key1, key2){
vk1 := format("vk{:x}", getKeyVK(key1))
vk2 := format("vk{:x}", getKeyVK(key2))
sendinput, {%vk1% down}{%vk2%}{%vk1% up}
}
;=================================================
another example
Code: Select all
;https://autohotkey.com/boards/viewtopic.php?f=5&t=41768
;- user exaskryz
;- notepad test mark text and copy / paste
f1::
sendKey("^a")
sleep,1000
sendKey("^c")
;-- check before the right place of cursor
sleep,1000
sendKey("^v")
return
;------------------
sendKey(key){
RegExMatch(key,"{(.*)}",match) ; this is for finding if we used a key like {Enter} or {Backspace} or {Numpad7}
target_key:=match1
;MsgBox % target_key
If !target_key ; in this case, we did not use { } in the input as the output is blank.
{
target_key:=SubStr(key,0) ; so we know it's going to be a single character like "1" or "t"
vk := "{" format("vk{:x}", getKeyVK(target_key)) ; we are adding the { and } in the output because it initially didn't have it
sc := format("sc{:x}", getKeySC(target_key)) "}"
}
else
{
vk := format("vk{:x}", getKeyVK(target_key)) ; we do not add { and } because it is already there in KEY. target_key does not have { } because that is not what the getKeyVk/Sc functions expect.
sc := format("sc{:x}", getKeySC(target_key))
}
output:=StrReplace(key,target_key,vk . sc) ; we take the key which could be +{Enter} or !a, replace it with the target word
send, %output%
}
;=====================================================================
Who is online
Users browsing this forum: ReyAHK and 78 guests