Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #MaxThreadsperHotKey, 2
- sleepTime := 1500
- keyDelay := 50
- pressDuration := 10
- toggle := 0
- SetKeyDelay, % keyDelay, % pressDuration
- F1::
- toggle ^= 1
- while (toggle)
- {
- SendInput, % "/" Format("{:U}", Number2Name(A_Index)) "{Enter}{Space}"
- Sleep, % sleepTime
- }
- return
- F2::sleepTime += 100
- +F2::sleepTime -= 100
- F3::SetKeyDelay, % keyDelay += 10, % pressDuration
- +F3::SetKeyDelay, % keyDelay -= 10, % pressDuration
- F4::SetKeyDelay, % keyDelay, % pressDuration += 10
- +F4::SetKeyDelay, % keyDelay, % pressDuration -= 10
- F5::MsgBox,
- (LTrim
- sleepTime := %sleepTime%
- keyDelay := %keyDelay%
- pressDuration := %pressDuration%
- )
- Number2Name(Number)
- ;
- ; AutoHotkey: v1.1.11+
- ; Language: English
- ; Platform: Win7
- ; Author: iPhilip
- ;
- ; Converts a number into the name of the number
- ;
- ; The function Number2Name(Number) converts an integer from 1 to 999,999,999,999 into the name of the number.
- ; For example, the number 264358 converts to "two hundred sixty-four thousand three hundred and fifty eight".
- ; See http://en.wikipedia.org/wiki/List_of_numbers#Cardinal_numbers for reference. Comma separators in the
- ; number are allowed, e.g. 264,358.
- ;
- ; The function sets ErrorLevel to one of the following values:
- ;
- ; 0 - If the conversion was successful
- ; 1 - If the number contains any non-digit characters other than commas ("123.4")
- ; 2 - If the number is larger than the maximum (10**12-1)
- ;
- ; ------------------------------------------------------------------------------------------
- Number2Name(Number)
- {
- static OnesArray := ["one","two","three","four","five","six","seven","eight","nine"]
- static TeensArray := ["ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"]
- static TensArray := ["twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"]
- static ThousandsArray := ["thousand","million","billion"]
- StringReplace, Number, Number, `,, , All ; Remove any comma separators from the input string
- ErrorLevel := 0 ; Initialize the error code to the default value
- if Number is not digit ; If the string contains anything other than digits
- ErrorLevel := 1 ; Set the corresponding error code
- else if (Number > 10**12-1) ; Otherwise, if the number is larger than the maximum ...
- ErrorLevel := 2 ; Set the corresponding error code
- if ErrorLevel ; If the error code is non-zero
- Return ; Return
- String = ; Initialize the output string
- NumPeriods := Ceil(StrLen(Number)/3) ; Calculate the number of periods in the number
- Loop %NumPeriods% ; Loop through for each period
- { ; A period is a grouping of three digits, e.g. 46,322 has two periods
- Multiplier := 10**(3*(NumPeriods-A_Index)) ; Calculate the multiplier corresponding to the current period
- Period := Floor(Number/Multiplier) ; Extract the current period
- Hundreds := Floor(Period/100) ; Calculate the hundreds digit for the period
- Tens := Floor((Period-Hundreds*100)/10) ; Calculate the tens digit for the period
- Ones := Period-Hundreds*100-Tens*10 ; Calculate the ones digit for the period
- if Hundreds ; If the period has a non-zero hundreds digit ...
- 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"
- if (Tens > 1) ; If the tens digit is greater than one, e.g. twenty-two
- {
- if (NumPeriods = 1 AND Hundreds OR NumPeriods > 1 AND A_Index > 1)
- ; If there are fewer than 3 digits and the number is > 99 or there are multiple periods and it's not the first period ...
- String .= "and" A_Space ; Append an "and " to the string
- String .= TensArray[Tens-1] ; Append the name for the tens digit to the string
- if Ones ; If the period has a non-zero ones digit, e.g. 37
- String .= "-" OnesArray[Ones] A_Space ; Append a dash and the name of the ones digit to the string
- }
- else if Tens ; Otherwise, if the tens digit is one, e.g. 214
- {
- if (NumPeriods = 1 AND Hundreds OR NumPeriods > 1 AND A_Index > 1)
- ; If there are fewer than 3 digits and the number is > 99 or there are multiple periods and it's not the first period ...
- String .= "and" A_Space ; Append an "and " to the string
- String .= TeensArray[Period-Hundreds*100-9] A_Space ; Append the name of the of the "teens" digit to the string
- }
- else if Ones ; Otherwise, if the tens digit is zero and the ones digit is non-zero ...
- {
- if (NumPeriods = 1 AND Hundreds OR NumPeriods > 1 AND A_Index > 1)
- ; If there are fewer than 3 digits and the number is > 99 or there are multiple periods and it's not the first period ...
- String .= "and" A_Space ; Append an "and " to the string
- String .= OnesArray[Ones] A_Space ; Append the name of the ones digit to the string
- }
- if (Period AND A_Index < NumPeriods) ; If the period is non-zero and it's not the last period
- String .= ThousandsArray[NumPeriods-A_Index] A_Space ; Append the name of the "thousands" digit to the string
- Number -= Period*Multiplier ; Reduce the number by the current period
- }
- String = %String% ; Trim the space at the end of the string
- Return String ; Return the value of the string
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement