Clicking a check box on LoginWindow Manager

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.

Any help would be great.

Hi santos

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

Budgie

Hi Santos,

checkboxes in AppleScript Studio applications are of class button.
The button you mean is named “runLoginHook”

set contents of button "runLoginHook" of window 1 to true -- or button 3

enables the checkbox

sorry santos, got logout instead of log in, simple change though.

change
click checkbox “Run this shell script on logout” of window “LoginWindow Manager”

to
click checkbox “Run this shell script on login” of window “LoginWindow Manager”

Budgie

Thanks Guys, I’ll try your suggestions in the morning.

Thanks again :smiley:

Damit, I couldnt wait until morning to try it :stuck_out_tongue:

Budgie, Thanks mate that worked a treat.

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?

glad that helped

get value of checkbox “Run this shell script on login” of window “LoginWindow Manager”

will yield values 0 & 1

Budgie

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

Thanks again guys :wink:
job done

Stafan thanks that did work.

One last thing though, How do you find out the name of a button or checkbox?

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

and other things, with no luck.

Can anyone help?

Hi santos,

try this:

activate "LoginWindow Manager"
tell application "System Events"
	tell process "LoginWindow Manager" to click button 4 of window 1
end tel

there are 3 Apply buttons, so it’s better to use the number

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



Can you spot what im doing wrong?

the (* Format the LWM *) part of the script has no errors when run here.

Budgie

Sorry yes, I should of been clearer. Its the (* Apply the Settings *) part im having trouble with now, I just cant seam to get any thing to work.:frowning:

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

Budgie

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?

this returns a list of the names of all buttons

tell window 1 of application "LoginWindow Manager"
	get name of buttons
end tell

Your Jocking!!!:o

Thanks for everything guys.

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

pleasure santos

“Script Debugger by LateNight Software”, ill look into that, thanks for the heads up StefanK

Budgie