7

I'm trying to simulate the "home button pressed" on iOS 7 but the previous method used on iOS 6 doesn't work. I speak of course of a jailbroken device.

#include "GSEvent.h"

    - (void)simulateHomeButton
    {
       struct GSEventRecord record;
       memset(&record, 0, sizeof(record));
       record.type = kGSEventMenuButtonDown;
       record.timestamp = GSCurrentEventTimestamp();
       GSSendSystemEvent(&record);
       record.type = kGSEventMenuButtonUp;
       GSSendSystemEvent(&record);
    }

*UPDATE What I really need is a generic method like the old one that let me to simulate the pressure of all physical buttons

trumpetlicks
  • 7,033
  • 2
  • 19
  • 33
Usi Usi
  • 2,967
  • 5
  • 38
  • 69

2 Answers2

6

Try this.

[[%c(SBUIController) sharedInstance]clickedMenuButton];

guoc
  • 414
  • 4
  • 6
  • Thanks It works. But I can't simulate the double tap to call the BackGround app Switcher for example... What a really need is a generic method like the old one that let me to simulate the pressure of all physical buttons – Usi Usi Jan 13 '14 at 15:31
  • 2
    I think this method only work on UI level, can not simulate hardware level's action. For double tap, you can try this, `[[SBUIController sharedInstance] handleMenuDoubleTap];` – guoc Jan 14 '14 at 11:23
  • Yes it works ... I already found that yesterday night.. :) what I miss now is only a method to lock the device ;) have you got some hints ? Thanks – Usi Usi Jan 14 '14 at 12:58
  • 1
    `[[%c(SBUserAgent) sharedUserAgent] lockAndDimDevice]` – guoc Jan 16 '14 at 12:05
  • 1
    @guoc, thank you, but how can I simulate volume button click events? – Suge Mar 07 '14 at 05:34
  • Hey @Suge, did you find a way to simulate volume button clicks ? I know it's old but we never know – AnthoPak Apr 29 '19 at 20:14
0

I found some references to homeButtonPress in the header dumps of BiometricKit https://github.com/MP0w/iOS-Headers/blob/6e220684809a8e581357c1622efcc002a1df5014/iOS7/PrivateFrameworks/BiometricKit/BiometricKit.h#L68

Sneakyness
  • 5,305
  • 4
  • 33
  • 39
  • Yes, but What I need is a generic method like the old one that let me to simulate the pressure of all physical buttons ;) – Usi Usi Jan 11 '14 at 10:24
  • 1
    Based on *which* framework this is in, and the name of the method, I would say that this is a **callback** that gets invoked when the home button is pressed. Not a button that creates a home button press event. – Nate Mar 06 '14 at 20:16