Sign in to follow this  
Followers 0
mazrit

Help altering script

2 posts in this topic

#1 ·  Posted (edited)

How do I make this script autofire the "J" key instead of the left mouse button?

#include <Misc.au3>
HotKeySet("{ESC}", "Quit")
$Path = @ScriptDir&"/AutoClickConfig.ini"
If Not FileExists($Path) Then
    $File = FileOpen($Path, 10)
    $Contents = _
    "/////////////////////////////////////////////////////////////////////////////////////////////"&@CRLF& _
    "// ONLY change values in settings"&@CRLF& _
    "// Below is the hotkey value list"&@CRLF& _
    "// Duration is the pause between each click in milliseconds(ms) -- (1000ms = 1sec)"&@CRLF& _
    "// Showtip = 1 To show conformation tooltip on running, else = 0"&@CRLF& _
    "/////////////////////////////////////////////////////////////////////////////////////////////"&@CRLF&@CRLF& _
    "[Settings]"&@CRLF& _
    "StartKey = 11"&@CRLF& _
    "Stopkey = 12"&@CRLF& _
    "Duration = 100"&@CRLF& _
    "Button = Left"&@CRLF& _
    "ShowTip = 1"&@CRLF&@CRLF& _
    "[Hotkeys]"&@CRLF& _
    "01 = Left mouse button"&@CRLF& _
    "02 = Right mouse button"&@CRLF& _
    "04 = Middle mouse button"&@CRLF& _
    "05 = X1 mouse button"&@CRLF& _
    "06 = X2 mouse button"&@CRLF& _
    "08 = BACKSPACE key"&@CRLF& _
    "09 = TAB key"&@CRLF& _
    "0C = CLEAR key"&@CRLF& _
    "0D = ENTER key"&@CRLF& _
    "10 = SHIFT key"&@CRLF& _
    "11 = CTRL key"&@CRLF& _
    "12 = ALT key"&@CRLF& _
    "13 = PAUSE key"&@CRLF& _
    "14 = CAPS LOCK key"&@CRLF& _
    "1B = ESC key"&@CRLF& _
    "20 = SPACEBAR"&@CRLF& _
    "21 = PAGE UP key"&@CRLF& _
    "22 = PAGE DOWN key"&@CRLF& _
    "23 = END key"&@CRLF& _
    "24 = HOME key"&@CRLF& _
    "25 = LEFT ARROW key"&@CRLF& _
    "26 = UP ARROW key"&@CRLF& _
    "27 = RIGHT ARROW key"&@CRLF& _
    "28 = DOWN ARROW key"&@CRLF& _
    "29 = SELECT key"&@CRLF& _
    "2A = PRINT key"&@CRLF& _
    "2B = EXECUTE key"&@CRLF& _
    "2C = PRINT SCREEN key"&@CRLF& _
    "2D = INS key"&@CRLF& _
    "2E = DEL key"&@CRLF& _
    "30 = 0 key"&@CRLF& _
    "31 = 1 key"&@CRLF& _
    "32 = 2 key"&@CRLF& _
    "33 = 3 key"&@CRLF& _
    "34 = 4 key"&@CRLF& _
    "35 = 5 key"&@CRLF& _
    "36 = 6 key"&@CRLF& _
    "37 = 7 key"&@CRLF& _
    "38 = 8 key"&@CRLF& _
    "39 = 9 key"&@CRLF& _
    "41 = A key"&@CRLF& _
    "42 = B key"&@CRLF& _
    "43 = C key"&@CRLF& _
    "44 = D key"&@CRLF& _
    "45 = E key"&@CRLF& _
    "46 = F key"&@CRLF& _
    "47 = G key"&@CRLF& _
    "48 = H key"&@CRLF& _
    "49 = I key"&@CRLF& _
    "4A = J key"&@CRLF& _
    "4B = K key"&@CRLF& _
    "4C = L key"&@CRLF& _
    "4D = M key"&@CRLF& _
    "4E = N key"&@CRLF& _
    "4F = O key"&@CRLF& _
    "50 = P key"&@CRLF& _
    "51 = Q key"&@CRLF& _
    "52 = R key"&@CRLF& _
    "53 = S key"&@CRLF& _
    "54 = T key"&@CRLF& _
    "55 = U key"&@CRLF& _
    "56 = V key"&@CRLF& _
    "57 = W key"&@CRLF& _
    "58 = X key"&@CRLF& _
    "59 = Y key"&@CRLF& _
    "5A = Z key"&@CRLF
    $Contents2 = _
    "5B = Left Windows key"&@CRLF& _
    "5C = Right Windows key"&@CRLF& _
    "60 = Numeric keypad 0 key"&@CRLF& _
    "61 = Numeric keypad 1 key"&@CRLF& _
    "62 = Numeric keypad 2 key"&@CRLF& _
    "63 = Numeric keypad 3 key"&@CRLF& _
    "64 = Numeric keypad 4 key"&@CRLF& _
    "65 = Numeric keypad 5 key"&@CRLF& _
    "66 = Numeric keypad 6 key"&@CRLF& _
    "67 = Numeric keypad 7 key"&@CRLF& _
    "68 = Numeric keypad 8 key"&@CRLF& _
    "69 = Numeric keypad 9 key"&@CRLF& _
    "6A = Multiply key"&@CRLF& _
    "6B = Add key"&@CRLF& _
    "6C = Separator key"&@CRLF& _
    "6D = Subtract key"&@CRLF& _
    "6E = Decimal key"&@CRLF& _
    "6F = Divide key"&@CRLF& _
    "70 = F1 key"&@CRLF& _
    "71 = F2 key"&@CRLF& _
    "72 = F3 key"&@CRLF& _
    "73 = F4 key"&@CRLF& _
    "74 = F5 key"&@CRLF& _
    "75 = F6 key"&@CRLF& _
    "76 = F7 key"&@CRLF& _
    "77 = F8 key"&@CRLF& _
    "78 = F9 key"&@CRLF& _
    "79 = F10 key"&@CRLF& _
    "7A = F11 key"&@CRLF& _
    "7B = F12 key"&@CRLF& _
    "90 = NUM LOCK key"&@CRLF& _
    "91 = SCROLL LOCK key"&@CRLF& _
    "A0 = Left SHIFT key"&@CRLF& _
    "A1 = Right SHIFT key"&@CRLF& _
    "A2 = Left CONTROL key"&@CRLF& _
    "A3 = Right CONTROL key"&@CRLF& _
    "A5 = MENU key"&@CRLF& _
    "BA =;"&@CRLF& _
    "BB = ="&@CRLF& _
    "BC = ,"&@CRLF& _
    "BD = -"&@CRLF& _
    "BE = ."&@CRLF& _
    "BF = /"&@CRLF& _
    "C0 = `"&@CRLF& _
    "DB = ["&@CRLF& _
    "DC = \"&@CRLF& _
    "DD = ]"
    FileWrite($File,$Contents&$Contents2)
    FileClose($File)
EndIf

$Settings = IniReadSection($Path, "Settings")
$Er = @error
If $Er or NOT IsArray($Settings) Then
    MsgBox(0,"Error","Could not read AutoClickConfig.ini"&@CRLF&"Error Code: "&$er)
    Exit
EndIf
$Start = String($Settings[1][1])
$Stop = String($Settings[2][1])
$Dur = Number($Settings[3][1])
$Button = String($Settings[4][1])
If $Settings[5][1] then
    $Keys = IniReadSection($Path,"Hotkeys")
    For $i = 1 to $keys[0][0]
        If $Keys[$i][0] = $Settings[1][1] then $Startkey = $Keys[$i][1]
    Next
    For $i = 1 to $keys[0][0]
        If $Keys[$i][0] = $Settings[2][1] then $Stopkey = $Keys[$i][1]
    Next
    For $i = 5 to 1 step -1
        ToolTip("StartKey: "&$Startkey&"("&$Start&")"&@CRLF&"StopKey: "&$Stopkey&"("&$Stop&")"&@CRLF&"Duration: "&$Dur&@CRLF&$i&"...",0,0)
        Sleep(1000)
    Next
    ToolTip("")
EndIf
While 1
    If _IsPressed($Start) Then
        Do
            Sleep(100)
        Until NOT _IsPressed($Start)
        Do
            MouseClick($Button) 
            $Interupt = Check4stop($Dur)
        Until _IsPressed($Stop) or $interupt = 1
        Do
            Sleep(100)
        Until NOT _IsPressed($Stop)
    EndIf
WEnd

Func Check4stop($Duration)
    $Timer = TimerInit()
    Do
        If _IsPressed($Stop) then Return 1
    Until TimerDiff($Timer) >= $Duration
EndFunc
   

Func Quit()
    Exit
Endfunc
Edited by mazrit

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