Trigger Siri on buttonless iOS devices from Type2Phone keyboard!

I’ve been looking for ways to trigger Siri on home buttonless devices from a bluetooth keyboard. Holding down a “home” key on a keyboard triggers Siri when the devices has a home button, but not for the new iPad Pros or iPhone X/XS models.

However, I’ve figured out that holding down a lock screen key does trigger Siri, since Siri is now mapped onto the sleep button. I don’t have a keyboard with a lock screen key, but using the excellent Type2Phone I’ve managed to make an applescript that will trigger Siri on my iOS device! The Applescript is below, which I map to a keystroke using Keyboard Maestro. Hope this helps someone!

tell application "Type2Phone"
	sendKeyCode 0 consumerKey 48 keyDown yes keyUp no
	delay 2
	sendKeyCode 0 consumerKey 48 keyDown no keyUp yes
end tell
1 Like

I’m not sure I want to invoke Siri. However I like the idea of Type2Phone - even though there is much I can type to on iOS that I can’t do on Mac. (Drafts actions is the one that comes to mind.)

Apologies for resurrecting an old thread, but I’m trying to work with sendKeyCode and it looks like you might have it figured out…

I’ve been playing with Type2Phone tonight and I think I just have one hurdle to jump over:

I want to use Command Tab to tab through applications on the iPad. Obviously, on the Mac this is invoking the application switcher there. I believe I can get around this with a Keyboard Maestro macro easily enough, but I just can’t work out the AppleScript command to sendKeyCode for Command + Tab.

Any ideas, @tedsvo (or anyone else)? How did you figure out the key code details to send? I’ve been looking at USB HID tables and trying various combinations but I’m afraid I don’t really know what I’m doing with this one!

Ahhh, actually, I think this might be a useful list here: https://apple.stackexchange.com/questions/36943/how-do-i-automate-a-key-press-in-applescript

This looks helpful too: https://eastmanreference.com/complete-list-of-applescript-key-codes

I haven’t got it working yet—based on the above links, key code 55 seems to be the one I want for Command and 48 for tab.

I tried this:

tell application "Type2Phone"
	sendKeyCode 55 keyDown yes keyUp no
	sendKeyCode 48 
	sendKeyCode 55 keyDown no keyUp yes
end tell

But right now I’m just getting an equals sign. :woman_shrugging:

Also found this, which I thought would help but isn’t shedding much light; maybe I don’t know how to read it properly: https://manytricks.com/keycodes/

Wondering whether it might be my Dvorak keyboard layout getting in the way. I will continue experimenting…

Hey @Kaitlin - I don’t have much to offer in Applescripting this, but you can use the “Special Keys” menu (I think that’s what it’s called?) and do a “Select Menu Item” action in Keyboard Maestro to trigger this, instead of manually scripting it.

Does that help?

2 Likes

Hmmm, I can’t seem to find an option that quite does what I want in that menu.

There is a Switch Applications (iPad) menu item (and also a Switch Applications Backward) option which switches to the next app, but I don’t think there is a way to invoke the list of open apps and cycle through them (though I may be missing something).

The Show or Hide The Multitasking Pane option in the VoiceOver menu sounds like it should do what I want but doesn’t actually seem to do anything unless I turn on VoiceOver (which obviously I don’t want to do) and even then it just shows the dock for a brief second. The Mac store seems to suggest that the last update was in Oct 2018, so I guess it seems likely it hasn’t been updated to play nicely with iOS 13 yet. I might shoot their support an email.

For the time being, I can stick to using Spotlight, I guess.

Thanks for your help!

Just playing with this today, the following successfully invokes Drafts:

tell application "Type2Phone"
	-- SPOTLIGHT is not supposed to work
	sendConsumerKey "SPOTLIGHT"
	delay 1
	send "Drafts
"
end tell

The AppleScript dictionary doesn’t list SPOTLIGHT as a legitimate value. But it works.

Now to read the above - especially about modifiers.

Question: Has anyone figured out how to run a Shortcut? I assume from Spotlight but can’t quite figure out the keys. “Kitchen shortcut” is one I use, for example.

And I get nothing at all. I suspect it’s not the AppleScript key codes you want but rather bluetooth ones.

Does that make sense?

I’m right. Here’s Command+Spacebar:

tell application "Type2Phone"
	activate
	delay 0.5
	sendKeyCode 44 modifier 8
end tell

I got it from here.

Modifier 8 is the bluetooth HID code for “Left GUI” according to the above link. 80 would be for “Right GUI”. And “GUI” means “Cmd” for Mac/iOS.

I think this advances things a little. I’m still figuring out how to run an arbitrary shortcut. It probably involves finding the code for Down Arrow.