2

I want to make an application that it capture all touch events and display x,y value in toolbar。

  1. If it's possible to capture all events although event not happened in this app ?
  2. How to show this app in the Toolbar like the Battery icon (when app run in background) ?
kran
  • 259
  • 4
  • 14
  • You can't and you can't. Maybe on an unlocked device but I doubt that also. – Perception Sep 27 '11 at 04:54
  • @Perception: may as well post that as an answer, since it _is_ the answer. – jscs Sep 27 '11 at 06:14
  • see this posting for an answer to your question: http://stackoverflow.com/questions/8444184/listen-to-all-touch-events-in-an-ios-app – pmko Feb 26 '12 at 05:15

2 Answers2

4

1) You can capture touch events when your own app is running is pretty easy. One way would be to a single root view controller, implement

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;

If you really are interested in displaying their coordinates, you will also have to think about questions like what happens in cases of multitouch.

However,

This is not possible for other apps. 2) is not possible at all. You don't have access to the status bar and you will not be able to do anything like capturing touch events when the application is in the background anyway. You can only capture events when your application is in the foreground.

Matthew Gillingham
  • 3,429
  • 1
  • 22
  • 26
  • He wants to capture touch events that occur in *other* apps, not his own. This is not possible. – Perception Sep 27 '11 at 05:01
  • Yes I understand that. He wants to capture events in other applications and that is not possible. But he does talk about having his own app (since it must going into the background) and he can capture events while that app is in the foreground. I edited my post to clarify that point a little bit more clearly. – Matthew Gillingham Sep 27 '11 at 05:27
  • @Perception perhaps he's referring to this: http://www.fireeye.com/blog/technical/2014/02/background-monitoring-on-non-jailbroken-ios-7-devices-and-a-mitigation.html or this: http://arstechnica.com/security/2014/02/new-ios-flaw-makes-devices-susceptible-to-covert-keylogging-researchers-say/ – joseph.hainline Feb 28 '14 at 05:09
2

Neither of your goals can be accomplished on a non-jailbroken device (and probably not even on a rooted one), because it violates the spirit of the Application Sandbox.

Perception
  • 79,279
  • 19
  • 185
  • 195