Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ducky2python.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@

# Process each line from the Ducky Script:
for line in duckyScript:

# Skip whitespace (empty) lines
if line.strip() == "":
continue

# Check if the statement is a comment
if line[0:3] == "REM" :
Expand All @@ -68,7 +72,8 @@

# Check if the statement is a string
elif line[0:6] == "STRING" :
previousStatement = "pyautogui.typewrite(\"" + line[7:] + "\", interval=0.02)"
escapeDoubleQuotes = line[7:].replace('"', '\\"')
previousStatement = "pyautogui.typewrite(\"" + escapeDoubleQuotes + "\", interval=0.02)"

# Check if the statement is a repeat command - in which case write the previous command times-1 since
# we write it once more at the end of the for loop anyways
Expand Down Expand Up @@ -98,4 +103,4 @@

# Close output file before exiting
pythonScript.close()
input("\nConversion complete!\n\nPress any key to close.")
input("\nConversion complete!\n\nPress the enter/return key to close.")
14 changes: 10 additions & 4 deletions javascript/ducky2python.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ function convert(){
"HOME":"home", "INSERT":"insert", "NUMLOCK":"numlock", "PAGEUP":"pageup", "PAGEDOWN":"pagedown",
"PRINTSCREEN":"printscreen", "SCROLLLOCK":"scrolllock", "SPACE":"space", "TAB":"tab", "ENTER":"enter",
"F1":"f1", "F2":"f2", "F3":"f3", "F4":"f4", "F5":"f5", "F6":"f6", "F7":"f7", "F8":"f8", "F9":"f9",
"F10":"f10", "F11":"f11", "F12":"f12", "a":"A", "b":"B", "c":"C", "d":"D", "e":"E", "f":"F", "g":"G",
"h":"H", "i":"I", "j":"J", "k":"K", "l":"L", "m":"M", "n":"N", "o":"O", "p":"P", "q":"Q", "r":"R",
"s":"S", "t":"T", "u":"U", "v":"V", "w":"W", "x":"X", "y":"Y", "z":"Z", "A":"A", "B":"B", "C":"C", "D":"D",
"F10":"f10", "F11":"f11", "F12":"f12", "a":"a", "b":"b", "c":"c", "d":"d", "e":"e", "f":"f", "g":"g",
"h":"h", "i":"i", "j":"j", "k":"k", "l":"l", "m":"m", "n":"n", "o":"o", "p":"p", "q":"q", "r":"r",
"s":"s", "t":"t", "u":"u", "v":"v", "w":"w", "x":"x", "y":"y", "z":"z", "A":"A", "B":"B", "C":"C", "D":"D",
"E":"E", "F":"F", "G":"G", "H":"H", "I":"I", "J":"J", "K":"K", "L":"L", "M":"M", "N":"N", "O":"O", "P":"P",
"Q":"Q", "R":"R", "S":"S", "T":"T", "U":"U", "V":"V", "W":"W", "X":"X", "Y":"Y", "Z":"Z", "1":"1", "2":"2",
"3":"3", "4":"4", "5":"5", "6":"6", "7":"7", "8":"8", "9":"9", "0":"0", "!":"!", "\"":"\"", "#":"#", "$":"$",
Expand All @@ -67,13 +67,19 @@ function convert(){
// Process each line from the Ducky Script:
for (line = 0; line < duckyScript.length; line++){

// Skip over empty lines
if (duckyScript[line].trim() === "") {
continue;
}

// Check if the statement is a comment
if(duckyScript[line].slice(0,3) == "REM"){
previousStatement = duckyScript[line].replace("REM","#");
}else if (duckyScript[line].slice(0,5) == "DELAY"){
previousStatement = "time.sleep(" + (parseFloat(duckyScript[line].slice(6)) / 1000) + ")";
}else if (duckyScript[line].slice(0,6) == "STRING") {
previousStatement = "pyautogui.typewrite(\"" + duckyScript[line].slice(7) + "\", interval=0.02)";
escapeDoubleQuotes = duckyScript[line].slice(7).replace(/"/g, '\\"');
previousStatement = "pyautogui.typewrite(\"" + escapeDoubleQuotes + "\", interval=0.02)";
}else if (duckyScript[line].slice(0,6) == "REPEAT"){
var repetitions = parseInt(duckyScript[line].slice(7)) - 1;
for (i = 0; i < repetitions; i++){
Expand Down