Script question!

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
johnxasa
Posts: 4
Joined: 10 Jan 2020, 12:23

Script question!

10 Jan 2020, 13:13

how can i make a script that when i press right ctrl it start pressing f1,f2,f3,f4,f5,f6,f7,f8 endlessly until i press right ctrl again?
User avatar
Hellbent
Posts: 2109
Joined: 23 Sep 2017, 13:34

Re: Script question!

10 Jan 2020, 14:38

Give this a try.

Code: Select all

#SingleInstance,Force
#MaxThreadsPerHotkey,10
SetKeyDelay,30,30
return

*Esc::ExitApp

*ctrl::
    Tog:=!Tog
    While(Tog){
        While(Tog&&A_Index<=8){
            Send,{F%A_Index%}
            Sleep,100
        }
    }
    return
Last edited by Hellbent on 10 Jan 2020, 14:47, edited 1 time in total.
User avatar
TheDewd
Posts: 1513
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Script question!

10 Jan 2020, 14:40

Try this:

Code: Select all

#SingleInstance, Force
#Persistent

KeyToggle := 0
KeyIndex := 1

~RCtrl::
	KeyToggle := !KeyToggle
	SetTimer, Timer1, % (KeyToggle ? "1000" : "Off")
	KeyIndex := (!KeyToggle ? 1 : KeyIndex)	
return

Timer1:
	Send, % "{F" KeyIndex "}"
	KeyIndex++
	
	If (KeyIndex > 8) {
		KeyIndex := 1
	}	
return
johnxasa
Posts: 4
Joined: 10 Jan 2020, 12:23

Re: Script question!

10 Jan 2020, 16:04

i'll try it out thx!
johnxasa
Posts: 4
Joined: 10 Jan 2020, 12:23

Re: Script question!

13 Jan 2020, 08:34

well i try them both. None of them work for me, am i missing smth or is smth wrong with the script?
johnxasa
Posts: 4
Joined: 10 Jan 2020, 12:23

Re: Script question!

13 Jan 2020, 08:40

I paste it in a text file that i make it a .ahk file. Then i open the compiler browse the script, make the .exe file, open the the .exe file and press right ctrl and nothing happent. Can someone help me?
User avatar
telanx
Posts: 68
Joined: 10 Jan 2020, 14:31

Re: Script question!

13 Jan 2020, 09:20

Modified from @Hellbent's code

Code: Select all

; This is required, otherwise the loop cannot be stopped.
#MaxThreadsPerHotkey 2

RCtrl::
    toggle := !toggle
    while toggle {
        while (A_Index <= 8) {
            if not Toggle
                break
            send {F%A_Index%}
            sleep 1000  ;send delay
        }
    }
    return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: ht55cd3 and 262 guests