diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..b294702 Binary files /dev/null and b/.DS_Store differ diff --git a/main.scpt b/main.scpt index f10d3bf..c1fb83e 100644 --- a/main.scpt +++ b/main.scpt @@ -1,15 +1,20 @@ -set numbers_key_codes to {82, 83, 84, 85, 86, 87, 88, 89, 91, 92} +set numbers_key_codes to {49, 50, 51, 52, 53, 54, 55, 56, 57, 48} set input to do shell script "pbpaste" if (input is not missing value and length of input is less than 250) then - tell application "System Events" - repeat with char in the characters of input - try - key code numbers_key_codes's item (char + 1) - on error - keystroke char - end try - end repeat - end tell + tell application "System Events" + repeat with char in the characters of input + set charIndex to offset of char in "0123456789 " -- Get index within number string + if charIndex is not 0 then -- Check if it's a number or space + try + key code numbers_key_codes's item charIndex -- Use correct index for key code + on error + keystroke char -- Fallback to keystroke for non-numbers + end try + else + keystroke space -- Handle space explicitly + end if + end repeat + end tell end if