Hi Im trying to create a script that will among other things tick a section of the LoginWindow Manager (Mike Bombich - http://www.bombich.com/software/lwm.html)
The section I need ticking is the “Run this shell script on login” tick box
This is what I have for this section so far:
tell application "LoginWindow Manager"
activate
set contents of text field 1 of window 1 to "My Path To Script" --This works
set checkbox 11 of window 1 to true
-- 11 is a guess, this line doesnt work.
end tell
I dont know what the checkbox is named as so I guessed on 11.
This will check the check box on or off, you may want to set the script up to check to see if it’s already
checked, or unchecked, hope this helps
activate application “LoginWindow Manager”
tell application “System Events”
tell process “LoginWindow Manager”
–set contents of text field 1 of window 1 to “My Path To Script”
click checkbox “Run this shell script on logout” of window “LoginWindow Manager”
end tell
end tell
StefanK, Your solution gave me the following error:-
System Events got an error: Can’t make contents of button “runLoginHook” of window 1 of process “LoginWindow Manager” into type reference.
Not sure what was happening there? but thanks for giving it a try.
Question:
What is the value of the checkbox?
is it true/false or 0/1 or what?
Of course you get an error, you should address LWM directly like in your first code snippet
tell application "LoginWindow Manager"
activate
set contents of text field 1 of window 1 to "My Path To Script" --This works
set contents of button "runLoginHook" of window 1 to true -- or button 3
end tell
It’s not necessary to use UI scripting,
all AppleScript Studio applications are exceedingly scriptable
OK I give in! how do I get my script to click the Apply button under login/logout Hooks on LoginWindow Manager?
Ive tried:-
tell application "System Events"
if exists process "LoginWindow Manager" then
tell process "LoginWindow Manager"
click button "apply"
end tell
end if
end tell
Hmmm im still getting the usual error :NSReceiverEvaluationScriptError: 4
This is a large chunk of what I have:
(* Move the Folder LoginScript to the root users library *)
do shell script "mv /private/var/root/Desktop/RemovePrinterAppleScript/LoginScript/ /private/var/root/Library/"
(* Make the Script RemovePrinters.sh excecutable *)
do shell script "chmod a+x /private/var/root/Library/LoginScript/RemovePrinters.sh "
(* Format the LWM *)
tell application "LoginWindow Manager"
activate
-- Enter text into the text input boxs
set contents of text field 2 of window 1 to "/private/var/root/Library/LoginScript/RemovePrinters.sh"
set contents of text field 1 of window 1 to "/private/var/root/Library/LoginScript/RemovePrinters.sh"
-- Set the check boxs
set contents of button "runLoginHook" of window 1 to true
set contents of button "runLogoutHook" of window 1 to true
(* Apply the Settings *)
tell application "System Events"
tell process "LoginWindow Manager" to click button 4 of window 1
end tell
-------------------------------------------------------------------------
(* Quite LWM *)
delay 4
--quit application "LoginWindow Manager"
end tell
Ive got the script open in front of me and the “APPLY” button in Login/Logout Hooks
is being activated using your script supplied, then the app asks for my password, so
I guess that it works, not sure whats happening for you though
tell application “LoginWindow Manager”
activate
set contents of text field 2 of window 1 to “A”
set contents of text field 1 of window 1 to “B”
set contents of button “runLoginHook” of window 1 to true
set contents of button “runLogoutHook” of window 1 to true
tell application “System Events”
tell process “LoginWindow Manager” to click button 4 of window 1
end tell
delay 4
end tell
Hmmm thats strange? it wasnt working here, but since I last tryed it i have downloaded and ran apples UI Element Inspector.
Now after seeing your post, I ran it again, and yes it works???
Budgie, how did you get the names of the buttons? “runLoginHook” and “runLogoutHook”
As I mentioned i downloaded UI Element Inspector but its not that great for what i need,
any advice about how to find names and stuff out?
No joke,
almost everything is documented in the directory of each application.
More comfortable is Script Debugger by LateNight Software,
which has an explorer mode to browse thru all properties and elements