From 632cfe721ca823b28f0c0be53300d5719dbd82e0 Mon Sep 17 00:00:00 2001 From: Sethu Narayan Senthil Date: Sun, 28 Jan 2024 20:22:59 -0500 Subject: [PATCH] fix spaces not working on MacOS Sonoma --- .DS_Store | Bin 0 -> 6148 bytes main.scpt | 25 +++++++++++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b294702aee19683848a2ff5e614a8a3042148ebd GIT binary patch literal 6148 zcmeHKO-sW-5PchqG;xfuA`f8oS3DF`iIiF)e!0I`JD7 zkY^X-0U1hcu=D)NSyq%8SLM~Xq{pAu*pt^GWAqXQaz61IkJF+R|K5o|#ufK}!3=Yp z;fDEY=9-iH%3Z29J6Mo?v6C%i%#8dMc$YbKMamW>#aa5wC8h^zwj?VeW$0Z&chmH>8FCWHdHvWcUYIS| zp|+}kD$rKozzs)I|0mzy|Jx)TsRF9Nzf!;q(z|rbBl+6eJDk+oh<;BOleos=mcouL g#f+6wd_uRz`A9m%#AD--Gc^4Xurg?)3jC-7UlE#KXaE2J literal 0 HcmV?d00001 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