Sign in to follow this  
Followers 0
lucky

Cycle Through F Keys while key is held down

2 posts in this topic

What I am trying to accomplish is have the script cycle through F1-F5 as long as the y button is held down. For example, when I hold down the y button, I want the computer to Push F1, wait one second, push F2, wait one second, push F3, etc. I realize it's rather basic, but I was hoping someone could offer some sort of advice or help. Thanks in advance!

HotKeySet('y', 'action'); start of script

While 1
    Sleep(100)
WEnd

Func action()
    Send('{F1}');Push F1
    Sleep(1000)
    Send('{F2}');Push F2
    Sleep(1000)
    Send('{F3}');Push F3
    Sleep(1000)
    Send('{F4}');Push F4
    Sleep(1000)
    Send('{F5}');Push F5
    Sleep(1000)
EndFunc; end of script

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I wouldn't use this as there are some bugs.. Sometimes "y" calls the wrong function(edit: when debugging). I would recommend changing the y key to something else so when you send messages to other ppl you can type the letter "y". For instance, middle mouse. Also if you want to hide that your using a 3rd party program more, you could Random() the Sleep() and some of the key press times than can be defined in Opt(). I think keys are held down for 1/100th of a sec. I'm almost sure keys are usually held down more than that when you are normally typing (I'm guessing 40ish(milli-seconds)).

#include <misc.au3>
HotKeySet("y", "Action")
Global $a = -1, $user32 = DllOpen("user32.dll")
Dim $keys[5] = ["{F1}", _
                "{F2}", _
                "{F3}", _
                "{F4}", _
                "{F5}"]

;~ Debug()
; Helpfile: "59 Y key"
While 1
    If _IsPressed("59", $user32) Then Action()
    Sleep(1000)
WEnd

Func Action($fdskljfalnkverioth = "")
    If IsDeclared("fdskljfalnkverioth") Then
        $a = Mod($a+1, UBound($keys))
        Send($keys[$a])
    EndIf
EndFunc

Func Debug($fdskljfalnkverioth = "")
    If IsDeclared("fdskljfalnkverioth") Then
        For $j = 0 To UBound($keys) - 1
            HotKeySet($keys[$j], "Debug")
        Next
    Else
        ToolTip(@HotKeyPressed, 10, 10)
    EndIf
EndFunc

Edited by gamerman2360

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0