Change existing menubar item from another script?

I have a Menubar app and would like to change it temporarily while another script runs.

Is this possible?

I’ve tried calling the property value assigned in the app (aStatusItem) without success.

I resolved this triggering a subroutine through the simple method of calling it. Duh…:

tell application "SomeApp.app"
   myRunTest("SomeString")
end tell

In my subroutine I had to make sure any call to the menubar was on the main thread. Here is an example:

on myRunTest(testDisplay)
	my performSelectorOnMainThread:"changeMenu" withObject:"()" waitUntilDone:true
	tell application "Finder"
		activate
		with timeout of 30 seconds
			display dialog testDisplay
		end timeout
	end tell
	my performSelectorOnMainThread:"changemenuback" withObject:"()" waitUntilDone:true
end myRunTest

Hope this helps someone in the future!

1 Like