send key combination via local network to other mac

1

1

after a other mac or macbook is connected with a mini display port to a new generation imac you can switch between the imac and the other connected mac pressing cmd+F2(brightness up) using the keyboard of the imac.

i connect my macbook to my imac, switch to the macbook and connect the bluetooth keyboard and mouse of my imac to my macbook.

after that i'm not able to switch back to my imac, because the keyboard is used on my macbook. i have a second mouse connected to my imac, so i'd would be cool to switch views and control my imac with my second mouse.

is it possible to send the shortcut cmd+F2 to my imac from my macbook? via command line or something? using apple script?

all ideas are welcome, thanks!

choise

Posted 2010-12-29T13:01:00.847

Reputation: 197

Could you check e.g. System Preferences » Keyboard » Keyboard Shortcuts to see if you can change the Cmd-F2 shortcut? Not that it's important, but I'd love to see if Apple implemented that or how that shortcut is presented to a user. – Daniel Beck – 2010-12-29T14:31:51.613

Answers

1

You could invoke the following AppleScript:

tell application "System Events"
    key code 122 using command down # Cmd-F2
end tell

for example, by SSH-ing into your iMac.

Execute a local script performing e.g. the SSH call on your Macbook using Butler, LaunchBar, Alfred, Quicksilver, Keyboard Maestro, or any of the other, similar tools, or simply the Services menu/Automator.

(Key code from here)

Daniel Beck

Posted 2010-12-29T13:01:00.847

Reputation: 98 421

@DanielBeck the link has died. – Reydi Sutandang – 2015-04-03T18:30:06.080

@ReydiSutandang In case it's temporary, I won't remove it for now. That said, there should be numerous guides on how to set up and use SSH with OS X online, just Google for them. It's not specific to this topic. – Daniel Beck – 2015-04-03T19:24:49.733

broken link @DanielBeck – Mick – 2015-11-06T12:35:22.830

@Mick Looks like it was permanent. Alright, just pointed it somewhere else that should apply as well. – Daniel Beck – 2015-11-07T12:36:33.950

okay, you mean i should store this code in a .scpt. how do i run this script? i know how to ssh into my imac, but how tu run it? – choise – 2010-12-29T14:44:12.667

@choise Click the link "SSH-ing" and read that web page. – Daniel Beck – 2010-12-29T14:46:10.857

seems working. but i need "brightness up", not f2... seems not the same. can't figure out the right keycode. google isnt helping me =/ – choise – 2010-12-29T16:28:33.807

@choise You mean Fn-F2, not Cmd-F2? – Daniel Beck – 2010-12-29T16:38:30.163

if i press f2(brightness) my brightness increases. and i want "cmd"+"increase brightness" . fn+f2 is real f2 on my mac – choise – 2010-12-29T17:11:23.270

@choise Now I understand. I doubt there is a way to press one of these "special" keys programmatically. If there's no API to access this functionality programmatically, there might not be a solution. – Daniel Beck – 2010-12-29T17:31:48.983

oh :( probably i can say using apple script "change input mode" or whatever happens when i press this, after a macbook is plugged in. – choise – 2010-12-29T17:49:54.110

@choise Haven't found an API for it -- and I don't think there is, to be honest. You also really should consider your question answered, or heavily edit it. It's now either about programmatic access to this functionality, or how to press a "special" key on a Mac keyboard. – Daniel Beck – 2010-12-29T22:17:32.343