'is running' property of every application

Hi,

I can get ‘is running’ to work here in Yosemite.

Edited: nevermind. Got it to work with:

application "Script Editor" is running

I did have another question though. I think that most developers open the window before the app is running. So, if ‘is running’ is true, then the window should be finished opening right? I’m uielement scripting “iSentry”.

Edited: it works with one second delay and got it to work one time with ‘is running’, but it hasn’t worked since then. Here’s the script to start the iSight detection:

tell application "iSentry"
	launch
	activate
	--set c to 0
	repeat
		--set c to c + 1
		if application "iSentry" is running then exit repeat
	end repeat
end tell
--delay 1
tell application "System Events"
	keystroke "r" using command down
end tell
--c

Can’t figure out why it worked the first time with the ‘is running’ property and not after that.

Edited: think I might know why. Need to test it.

Edited: moved the repeat loop out of the iSentry tell block:

tell application "iSentry"
	launch
	activate
end tell
	--set c to 0
repeat
	--set c to c + 1
	if application "iSentry" is running then exit repeat
end repeat
--delay 1
tell application "System Events"
	keystroke "r" using command down
end tell
--c

It still doesn’t work. Darn.

Edited: Think I need to check is the window is opened.

Edited: one other thing needs to be checked. Maybe running it in Script Editor might be doing something.

Edited: found out that the window exists and there is still a keystroke error. Maybe need to check for the button or something.

Thanks,
kel

Hi,

a window instance in Xcode has a property “visible at launch” which is true by default.
With this setting the window is instantiated and displayed before the method applicationWill/DidFinishLaunching is called.

As you are UI scripting the application anyway you could wait for the window this way

tell application "System Events"
	repeat until exists window 1 of process "iSentry"
		delay 0.2
	end repeat
end tell

Hi Stefan,

I’ll try that next.

What I’ve found is that a half second delay does the job also:

tell application "iSentry"
	launch
	activate
end tell
--set c to 0
(*
repeat 10 times
	--set c to c + 1
	--if application "iSentry" is running then exit repeat
	delay 1
end repeat
*)
--set e to exists window 1
delay 0.5
tell application "System Events"
	keystroke "r" using command down
end tell
--c

Edited: I see, so the window exists before the app finishes launching. Thanks again.

Edited: and also it may exists, but is not fully operational.

Thanks for the reply,
kel

Unlike a repeat loop waiting for the existence of an UI element delays are not 100% reliable

Yeah, I see that now thanks. It exists but you still can’t send keystrokes to it.

Thanks a lot,
kel

usually keystrokes are not process sensitive, they are sent to the frontmost application/process, but try this


tell application "System Events"
	tell process "iSentry"
		keystroke "r" using command down
	end tell
end tell

i.e. System Events will only detect the window when it is operational.

And btw, that is why it is good to wrap the keystrokes in the process. I remember Yvan stating this long ago in an answer to a question.

Thanks a lot,
kel

Darn it’s still not working after the first run!

I hate to hack a developer’s app in public, but all I want to do is run the app through AppleScript. I’m thinking there is more to this than meets the eye. I can see ways around this, but I think I’ll leave it up to a persons imagination.

This is a great app. I tested the cpu usage and it is very good. If you have extra money unlike me, then please send it in and buy the pro version. It is very quick and you can upload it to your telephones or whatever.

Thnk I have a solution now for us poor people.:slight_smile:

gl and may God bless,
kel

If you can afford Apple products, you can’t be poor :wink:

Hi Stefan,

I had to buy Apple because of AppleScript (and unix). Save lots of money when you roll your own apps. :smiley: You know what I mean and not to mention Xcode.

Edited: i.e. you don’t want Microsoft!!!

Edited: did you see how those leaches using the name cloud. They’ve been leeching on Apple research ever since the beginning.

Have a good day,
kel

Hi,

And btw, when you make your own apps you can modify and you don’t need to wait for updates. It’s a very good thing to not have to wait for updates. Roll your own man! :smiley:

Edited: one thing I forgot and it’s not the last and not the least, is the Apple community is a commune. Anywhere you go on the internet you are in it if you own a Apple computer. Any question you can just ask and there would be no question about making dollars or whatever. That is what is great about Apple computers. Or at least that it what it used to be.

gl,
kel

Hi,

btw, If anybody is interested, only adding a delay worked. I used .5 secs and it seemed to work for some reason. Maybe maligning it 1 second might be better. Still testing:

tell application "iSentry"
	launch
	activate
end tell
delay 0.5
tell application "System Events"
	tell process "iSentry"
		keystroke "r" using command down
	end tell
end tell

Also, in the preferences, do not check Pre-motion recording under the Recording tab otherwise you’re going to get hundreds of pictures or movies I think.

Edited: also, the cpu usage was only like about 10 percent on the average all night. So, I think that’s not too bad for one app running.

gl,
kel

ps. If you want, now you can monitor the download folder and do what ever. The sensitivity is pretty good I think. Ran it all night and with the change in lighting, it still didn’t trigger.

Now for the other side. :smiley: Great toy.

gl,
kel