Kill screensaver and unlock a mac using appleScript - iphone

I'm trying to unlock my mac using my iPhone via bluetooth proximity, the code I'm using:
tell application "System Events"
tell security preferences
set require password to wake to false
end tell
end tell
tell application "ScreenSaverEngine" to quit
It kills the screensaver, doesn't show the password box but all I get is a black screen. All applications still running but I'm hovering the mouse on this black screen.
I'm running two monitors on a 10.6.7 build.
What's wrong? Thanks.
lifehacker article http://lifehacker.com/5816791/use-a-bluetooth-phone-or-device-to-lock-and-unlock-your-mac-when-youre-near

You could try an alternative way to kill the screen saver, such as a shell script with
#!/bin/sh
killall ScreenSaverEngine
And calling it directly, or writing an applescript to call it if you'd like that for some reason to do with the lifehacker article.

Related

iOS app to run script

I would appreciate help in creating an iOS app to run a specified script at /var/mobile/script.sh. The script I have written opens a number of specified apps "all at once" on my jailbroken 6.1.2 iphone. Currently I run the script by starting MobileTerminal and manually running the script.sh file from the command line. I would like to be able to create an app that I could start via the Springboard which would run /var/mobile/script.sh directly.
I do not have a Mac and so I am unable to compile an app myself. I also do not have much experience of programming so I would appreciate any help on offer. I have seen an answer which is similar: iOS execute shell script from Activator
The answer provided above is VERY close to what I am looking for. However I have two problems with the Script.app as it stands:
1) As the script I have written opens a number of other apps which takes around two minutes to complete, the Script.app is automatically killed by iOS after about 20 seconds. I'm not sure if a flag "didFinishLaunchingWithOptions" needs to be set to allow Script.app to continue running so it can finish running my script? I have installed a package via Cydia called "Background Manager" - [which as I understand it makes all apps effectively think they are running in the foreground].
2) I have previously tested Script.app listed above on iOS 5 and the Script.app did run for around 20 seconds bringing the apps to the foreground as listed in my script.sh. On iOS 6.1.2 the Script.app runs certain commands in script.sh [e.g. killall commands] but when it comes to opening a specified app via the script it won't open any app [there is a blank black screen for 20 seconds and then the Script app closes without having opened any apps via the script.sh file]. However in iOS 6.1.2 if Script.app is started and immediately the home button is pressed to return you to the Springboard the Script.app will open apps via my script.sh for the first 20 seconds, so there appears to be a difference between the way the Script.app runs on iOS5 vs iOS6. I would like if Script.app could open apps via the script.sh without me having to immediately press the home button after Script.app starts on iOS 6
In my script file I use a command line package called "open" to specific which app to open via its CFBundleIdentifier: http://moreinfo.thebigboss.org/moreinfo/depiction.php?file=openData
Thanks for your help
Here's a technique that should work for you. It's not necessarily the way I'd solve it, but the solution is designed to work around you not having a Mac / Xcode.
One problem is that iOS expects normal "apps" to startup quickly, and begin responding to normal UI application events. If you use my original script launcher, it does not actually create a UIApplication, but simply calls system() from the main program. Assuming the call to system() completes quickly, there's no problem. But, if your script takes 20 seconds to run, that's too long, and iOS will kill the app.
You could build a normal UI application, calling UIApplicationMain(), and starting your long-running script after the app finishes startup. But really, you're not building an app. You simply want to use a SpringBoard icon to kick off a script. So, I don't think that solution makes a lot of sense.
What you probably want is a non-graphical daemon to run your long script for you. For this, you could build a Launch Daemon, and that might be how I solved the problem. But, without Xcode, that's tough. Another option is to take advantage of the privileged daemon that SBSettings has. You can use it to run your script. Then, your "app" need only fire off a notification to tell SBSettings to run that script. It can then exit, almost immediately.
Here is a pre-built binary that invokes a script named com.mycompany.script (get version 1.1). Install this app on your iPhone (it can be installed normally, in the sandbox area).
Then, you'll need to put your script at (this exact path and filename):
/var/mobile/Library/SBSettings/Commands/com.mycompany.script
For example, its contents might be:
#!/bin/sh
/usr/bin/open com.mycompany.AppOne
/usr/bin/open com.mycompany.AppTwo
/usr/bin/open com.mycompany.AppThree
exit 0;
where you're passing app bundle IDs to open. You can put whatever you want inside it. Make sure to login to your iPhone and set the right permissions on your script:
cd /var/mobile/Library/SBSettings/Commands/
chmod 755 com.mycompany.script
chown mobile.mobile com.mycompany.script
and then reboot (re-springing might be enough to get SBSettings to recognize your new script).
Note: for those who are coders, the main program of this app basically just contains this code:
#include <notify.h>
int main(int argc, char *argv[])
{
notify_post("com.mycompany.script");
return 0;
}

Usage of Ti.UI.Tray

Can Someone explain me what Ti.UI.Tray is for? I want to create a system tray application that displays notifications on update and when the user closes the window it goes into system tray instead of exiting and the user closes the application by explicitly choosing to exit. Can Ti.UI.Tray be used for this? If not, is there any other way to make a tidesdk system tray application for each of the windows,osx and linux platforms

make the program automatically go to background

I want to click on a button to make my program into the background. How would I do this?
If it used to jailbreak the phone,
If you mean programmatically "minimize" the app (closing it while leaving it open in multitasking), I don't believe there's a way to do so using a public API.
Please have a look at the following anwsers
Send App to Background process
Suspend the application
Don’t Quit Programmatically
Never quit an iOS application programmatically because people tend to interpret this as a crash. However, if external circumstances prevent your application from functioning as intended, you need to tell your users about the situation and explain what they can do about it. Depending on how severe the application malfunction is, you have two choices.

Is it possible to run an application automatically on boot up as background service in J2me?

I wanted to develop Location Based Service in J2me which has to start automatically on Boot up & run as background service ,which will send periodic location to the server? How can i implement it on J2me ?
Any Suggestions,tips or examples will be really helpful.
Thanks
Yes, Srizan,
It is possible using the Application Settings. You need to set the Auto Start setting to true in Application Settings.
Yes I am also trying same, I went to some extent.
Yes is possible to do ,with help of Push reg which is with MIDP 2.0 Mobile app can be called after every 10 sec or so (I didn't Coded this yet)
and. to hide app use this line Display.getDisplay (this).setCurrent (null);
it will run be shown with your tab or run app again.
I am still getting some problems like, Internet will Go Off when Mobile screen goes Off.

iPhone app crashing being killed in background

I'm making this app with which the user can record and play sound and send it to the server. However when it goes to the background and i kill the app (double tap on the home screen and remove it from there) it will crash when i try to open it back up with only this in the console:
sharedlibrary apply-load-rules all
Current language: auto; currently objective-c
Does anyone know why it is doing this and how i can solve this? If you need any more information just ask for it and I will provide it asap!
Thanks in advance!
As I understand you're running your app in debug mode (connected to Xcode). When you close the app via the home button the OS sends SIGKILL to the process and that is why the debug session is also terminated.
So your application doesn't crash.