2

I'm building an utility app for myself that can take screenshots of whatever is running in the foreground while this utility is running in the background. The utility will be running on a jailbroken device so it can access private APIs and not confined to the sandbox. Since the utility app is running in the background (either as a daemon or using backgrounder), how can I access the screen being displayed to generate a screenshot?

The reason I want this is because I want to take screenshots programmatically/remotely. The utility will take the screenshot and upload to my local server. I'm using this as part of internal test tools.

Help much appreciated!

ssong
  • 43
  • 6
  • 1
    Why not take a screen shot the "normal" way? Press and hold the sleep/lock button, press and release the Home button, release the sleep/lock button. No need for an app. Or are you looking for more? – rmaddy Nov 12 '12 at 04:42
  • I want to take screenshots programmatically/remotely. The utility will take the screenshot and upload to my local server. I'm using this as part of internal test tools. – ssong Nov 12 '12 at 04:45
  • That makes sense. Your question wasn't clear on the reason. That information will help someone give you a better answer. Good luck. – rmaddy Nov 12 '12 at 04:47

1 Answers1

2

You should be able to grab a screenshot of the whole screen with UICreateScreenImage(). This will give you a CGImageRef, which you can turn into a UIImage with [UIImage imageWithCGImage:screenshot]. You can then upload this to your server and release the image with CGImageRelease(screenshot).

kirb
  • 2,033
  • 1
  • 18
  • 28
  • UICreateScreenImage does exactly what I want. Thanks! – ssong Nov 12 '12 at 08:08
  • UICreateScreenImage has been working great on iOS 5 when my app is running with backgrounder. Since iOS 6 doesn't support backgrounder, I tried running it as a background task using built in multitasking. This, however, gives "Cannot call UICreateScreenImage() while app is in the background" error. Any ideas? – ssong Nov 14 '12 at 04:45
  • 1
    You could try using a LaunchDaemon instead - the system is all the same as it is on OS X, except you'll need to use the _Insomnia_ Cydia package to keep the Internet connection active. – kirb Nov 14 '12 at 08:25
  • @ssong were you able to solve your problem? I'm trying to do something similar on a jailbroken iphone – blueether Sep 10 '15 at 21:36