Help, i Do'nt know

Ask gaming related questions
Posts: 1
Joined: 20 Jan 2018, 13:35

Help, i Do'nt know

20 Jan 2018, 13:42

How to make a script to click a key 6 times?
User avatar
Posts: 485
Joined: 30 Sep 2013, 10:54
Location: Brazil

Re: Help, i Do'nt know

20 Jan 2018, 14:30

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).

Code: Select all

Loop, 6
Send j
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.

Code: Select all

Sleep, 10000
Loop, 6
Send j
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 :thumbup:
"What is suitable automation? Whatever saves your day for the greater matters."
Barcoder - Create QR Codes and other Barcodes using only Autohotkey !!
Posts: 2515
Joined: 13 May 2014, 17:15

Re: Help, i Do'nt know

20 Jan 2018, 16:29

check out our portuguese subforums if you are brazilian and wish to talk about AutoHotkey in portuguese.
Isn't he/she hunting Brazilians?? :o :shifty: :silent:
Posts: 2164
Joined: 08 Feb 2015, 20:55

Re: Help, i Do'nt know

20 Jan 2018, 18:14

Isn't he/she hunting Brazilians?? :o :shifty: :silent:
:lol: :D :bravo: :beer:
User avatar
Posts: 744
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Help, i Do'nt know

20 Jan 2018, 19:08

I think BrazilianHunter wants to realize the following:

Code: Select all

sendinput jjjjjj

Code: Select all

loop 6
	sendinput j
	sleep 100
Pressing one times triggers six times.
[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.

ADVERTISING: Patent pending strip accumulator - süper advanced technology - priceless inexpensive, space-saving, energy efficient - Patent priority for sale.
Posts: 1509
Joined: 22 Dec 2013, 12:50

Re: Help, i Do'nt know

21 Jan 2018, 05:29

found this , send also first ctrl / alt / win and then key

Code: Select all

;- 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

sendKey("control", "a")

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

;- user exaskryz
;- notepad test mark text and copy / paste

;-- check before the right place of cursor
	RegExMatch(key,"{(.*)}",match) ; this is for finding if we used a key like {Enter} or {Backspace} or {Numpad7}
	;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)) "}"
        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%

Return to “Gaming”

Who is online

Users browsing this forum: No registered users and 29 guests