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.
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
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.
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.
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!
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.
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.