Advertisement
anonymous1184

Jumping Jack

Jan 31st, 2021
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #MaxThreadsperHotKey, 2
  2.  
  3. sleepTime := 1500
  4. keyDelay := 50
  5. pressDuration := 10
  6.  
  7. toggle := 0
  8. SetKeyDelay, % keyDelay, % pressDuration
  9. F1::
  10.     toggle ^= 1
  11.     while (toggle)
  12.     {
  13.         SendInput, % "/" Format("{:U}", Number2Name(A_Index)) "{Enter}{Space}"
  14.         Sleep, % sleepTime
  15.     }
  16. return
  17. F2::sleepTime += 100
  18. +F2::sleepTime -= 100
  19. F3::SetKeyDelay, % keyDelay += 10, % pressDuration
  20. +F3::SetKeyDelay, % keyDelay -= 10, % pressDuration
  21. F4::SetKeyDelay, % keyDelay, % pressDuration += 10
  22. +F4::SetKeyDelay, % keyDelay, % pressDuration -= 10
  23. F5::MsgBox,
  24. (LTrim
  25.     sleepTime := %sleepTime%
  26.     keyDelay := %keyDelay%
  27.     pressDuration := %pressDuration%
  28. )
  29.  
  30. Number2Name(Number)
  31. ;
  32. ; AutoHotkey: v1.1.11+
  33. ; Language:   English
  34. ; Platform:   Win7
  35. ; Author:     iPhilip
  36. ;
  37. ; Converts a number into the name of the number
  38. ;
  39. ; The function Number2Name(Number) converts an integer from 1 to 999,999,999,999 into the name of the number.
  40. ; For example, the number 264358 converts to "two hundred sixty-four thousand three hundred and fifty eight".
  41. ; See http://en.wikipedia.org/wiki/List_of_numbers#Cardinal_numbers for reference. Comma separators in the
  42. ; number are allowed, e.g. 264,358.
  43. ;
  44. ; The function sets ErrorLevel to one of the following values:
  45. ;
  46. ;    0 - If the conversion was successful
  47. ;    1 - If the number contains any non-digit characters other than commas ("123.4")
  48. ;    2 - If the number is larger than the maximum (10**12-1)
  49. ;
  50. ; ------------------------------------------------------------------------------------------
  51.  
  52. Number2Name(Number)
  53. {
  54.    static OnesArray := ["one","two","three","four","five","six","seven","eight","nine"]
  55.    static TeensArray := ["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"]
  56.    static TensArray  := ["twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"]
  57.    static ThousandsArray := ["thousand","million","billion"]
  58.  
  59.    StringReplace, Number, Number, `,, , All          ; Remove any comma separators from the input string
  60.    ErrorLevel := 0                                   ; Initialize the error code to the default value
  61.    if Number is not digit                            ; If the string contains anything other than digits
  62.       ErrorLevel := 1                                ; Set the corresponding error code
  63.    else if (Number > 10**12-1)                       ; Otherwise, if the number is larger than the maximum ...
  64.       ErrorLevel := 2                                ; Set the corresponding error code
  65.    if ErrorLevel                                     ; If the error code is non-zero
  66.       Return                                         ; Return
  67.    String =                                          ; Initialize the output string
  68.    NumPeriods := Ceil(StrLen(Number)/3)              ; Calculate the number of periods in the number
  69.    Loop %NumPeriods%                                 ; Loop through for each period
  70.    {                                                 ; A period is a grouping of three digits, e.g. 46,322 has two periods
  71.       Multiplier := 10**(3*(NumPeriods-A_Index))     ; Calculate the multiplier corresponding to the current period
  72.       Period := Floor(Number/Multiplier)             ; Extract the current period
  73.       Hundreds := Floor(Period/100)                  ; Calculate the hundreds digit for the period
  74.       Tens := Floor((Period-Hundreds*100)/10)        ; Calculate the tens digit for the period
  75.       Ones := Period-Hundreds*100-Tens*10            ; Calculate the ones digit for the period
  76.       if Hundreds                                    ; If the period has a non-zero hundreds digit ...
  77.          String .= OnesArray[Hundreds] A_Space "hundred" A_Space   ; Append the name for the ones digit and the word "hundred" to the string, e.g. "two hundred"
  78.       if (Tens > 1)                                  ; If the tens digit is greater than one, e.g. twenty-two
  79.       {
  80.          if (NumPeriods = 1 AND Hundreds OR NumPeriods > 1 AND A_Index > 1)
  81.          ; If there are fewer than 3 digits and the number is > 99 or there are multiple periods and it's not the first period ...
  82.             String .= "and" A_Space                  ; Append an "and " to the string
  83.          String .= TensArray[Tens-1]                 ; Append the name for the tens digit to the string
  84.          if Ones                                     ; If the period has a non-zero ones digit, e.g. 37
  85.             String .=  "-" OnesArray[Ones] A_Space   ; Append a dash and the name of the ones digit to the string
  86.       }
  87.       else if Tens                                   ; Otherwise, if the tens digit is one, e.g. 214
  88.       {
  89.          if (NumPeriods = 1 AND Hundreds OR NumPeriods > 1 AND A_Index > 1)
  90.          ; If there are fewer than 3 digits and the number is > 99 or there are multiple periods and it's not the first period ...
  91.             String .= "and" A_Space                  ; Append an "and " to the string
  92.          String .= TeensArray[Period-Hundreds*100-9] A_Space   ; Append the name of the of the "teens" digit to the string
  93.       }
  94.       else if Ones                                   ; Otherwise, if the tens digit is zero and the ones digit is non-zero ...
  95.       {
  96.          if (NumPeriods = 1 AND Hundreds OR NumPeriods > 1 AND A_Index > 1)
  97.          ; If there are fewer than 3 digits and the number is > 99 or there are multiple periods and it's not the first period ...
  98.             String .= "and" A_Space                  ; Append an "and " to the string
  99.          String .= OnesArray[Ones] A_Space           ; Append the name of the ones digit to the string
  100.       }
  101.       if (Period AND A_Index < NumPeriods)           ; If the period is non-zero and it's not the last period
  102.          String .= ThousandsArray[NumPeriods-A_Index] A_Space   ; Append the name of the "thousands" digit to the string
  103.       Number -= Period*Multiplier                    ; Reduce the number by the current period
  104.    }
  105.    String = %String%                                 ; Trim the space at the end of the string
  106.    Return String                                     ; Return the value of the string
  107. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement