Last active
April 21, 2022 15:47
-
-
Save stringsn88keys/c8de9ce36f3b376d34e4505cbc7c2758 to your computer and use it in GitHub Desktop.
"Type" old and new passwords into Windows Server 2016 change password screen when WorkSpaces doesn't allow pasting from your Mac.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/osascript | |
# Usage: | |
# export OLDPASS="oldpasswordhere!" | |
# export NEWPASS="newpasswordgoeshere." | |
# get to change password screen in WorkSpace prior to running this script and make sure you're on the "old password" field. | |
# run script without args | |
on sysKeyCode(kc) | |
tell application "System Events" to key code {kc} using {command down} | |
end sysKeyCode | |
on sysKeyStroke(ks) | |
tell application "System Events" to keystroke ks | |
end | |
on sendString(thePass) | |
set AppleScript's text item delimiters to "" | |
repeat with letter in thePass | |
if (letter = "0") then | |
sysKeyCode(29) | |
else if (letter = "1") then | |
sysKeyCode(18) | |
else if (letter = "2") then | |
sysKeyCode(19) | |
else if (letter = "3") then | |
sysKeyCode(20) | |
else if (letter = "4") then | |
sysKeyCode(21) | |
else if (letter = "5") then | |
sysKeyCode(23) | |
else if (letter = "6") then | |
sysKeyCode(24) | |
else if (letter = "7") then | |
sysKeyCode(26) | |
else if (letter = "8") then | |
sysKeyCode(28) | |
else if (letter = "9") then | |
sysKeyCode(25) | |
else if (letter = ".") then | |
sysKeycode(47) | |
else | |
sysKeyStroke(letter) | |
end if | |
delay 0.1 | |
end repeat | |
end sendString | |
set oldPassword to system attribute "OLDPASS" | |
set newPassword to system attribute "NEWPASS" | |
activate application "WorkSpaces" | |
sendString(oldPassword) | |
sysKeyStroke (ASCII character 9) | |
sendString(newPassword) | |
sysKeyStroke(ASCII character 9) | |
sendString(newPassWord) | |
end activate |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment