Glassix wrote:
Hey thanks for pointing out that reply button. I actually didn't see it there, instead going up to the top to reply. It was annoying too because I wasn't able to reference the last post when I was typing my response. Still learning...
No problem. here is my modified version of that apple applet. It's a bit quicker and it works regardless of whether you are using short or long login names in it. Either one will work.
Paste it into Script Editor and save as main.scpt. Then right-click on the apple applet, select "show package contents" and navigate to Contents/Resources/Scripts.
Replace the existing file main.scpt with mine.
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 335px;
color: #000000;
background-color: #ADD8E6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
property target_username : ""
property target_userpassword : ""
on open these_items
display_main()
end open
on run
try
if target_username is "" or target_userpassword is "" then
display_main()
else
set the current_user to short user name of (get system info)
tell application "System Events"
if UI elements enabled is false then
set UI elements enabled to true
end if
if UI elements enabled is true then
set us_id to do shell script "id -u " & quoted form of target_username
do shell script "/System/Library/CoreServices/Menu\\ Extras/User.menu/Contents/Resources/CGSession -switchToUserID " & us_id
delay 0.1
keystroke target_userpassword
delay 0.1
keystroke return
end if
end tell
end if
on error error_message number error_number
if the error_number is not -128 then
display dialog error_message with icon 2 buttons {"Cancel"} default button 1
end if
end try
end run
on display_main()
set version_string to (the short version of (info for (path to me))) as string
set this_iconfile to (path to resource "AccountSwitcher.icns")
set the title_string to ("Account Switcher" & space & "v" & version_string)
repeat
activate
display dialog "This application will automate switching between user accounts on this computer." & return & return & "To use, make sure Fast User Switching is enabled in the Accounts System Preference pane under Login Options." & return & return & "After setting the Fast User Switching options, click the “Set Login Info” button below to enter the name and password for the account you wish to use this application to switch to." & return & return & "To access this dialog again, drag any disk item onto this application’s icon." with icon this_iconfile with title title_string buttons {"Open Accounts", "Set Login Info", "OK"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Open Accounts" then
tell application "System Preferences"
set the current pane to pane id "com.apple.preferences.users"
activate
end tell
exit repeat
else if the button_pressed is "Set Login Info" then
display dialog "Enter the name of the targeted accounts as it appears in the Accounts menu:" default answer target_username with icon this_iconfile with title title_string
set the target_username to the text returned of the result
repeat
display dialog "Enter the password for the targeted account:" default answer "" with icon this_iconfile with title title_string with hidden answer
set the password_01 to the text returned of the result
display dialog "Enter the password for the targeted account again:" default answer "" with icon this_iconfile with title title_string with hidden answer
set the password_02 to the text returned of the result
if password_01 is not password_02 then
display dialog "The two passwords do not match. Try again." with icon this_iconfile with title title_string
else
set target_userpassword to password_01
exit repeat
end if
end repeat
display dialog "The account information has been stored in this application." & return & return & "Click the OK button in the following dialog to complete the process. The next time this application is launched, it will use the stored information to switch to the target account." buttons {"OK"} default button 1 with icon this_iconfile with title title_string
else
exit repeat
end if
end repeat
end display_main
</pre>