How to shut down SS using the Power button?
Moderators: Cat_7, Ronald P. Regensburg, ClockWise
How to shut down SS using the Power button?
I am using an old Macally USB keyboard which still has a startup button on the upper right corner. Of course, running a Hackintosh, I can't use it to start the machine. However, It is a quick way to enter the shut down menu followed by 'return' in order to shut down the machine.
Unfortunately this does not work with SheepShaver. Is it possible to map this key in the key codes file in order to make it work?
I recall a thread on emaculation regarding that button, but I can't find it.
Anyone who can help?
Unfortunately this does not work with SheepShaver. Is it possible to map this key in the key codes file in order to make it work?
I recall a thread on emaculation regarding that button, but I can't find it.
Anyone who can help?
- adespoton
- Forum All-Star
- Posts: 4227
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: Basilisk II keycodes file for entire keyboard.
Does this help?
http://download.microsoft.com/download/ ... ancode.doc
The power button was the equivalent of the current control-eject sequence; I can't recall the actual code sent however.
http://download.microsoft.com/download/ ... ancode.doc
The power button was the equivalent of the current control-eject sequence; I can't recall the actual code sent however.
Re: Basilisk II keycodes file for entire keyboard.
Since you provided the correct term "power button" I could find the post I was looking for: viewtopic.php?p=45828#p45828 . It was actually you who wrote it.
Thank you!
I have added a line to the Quartz key mapping in the keycodes file "mapping" 127 to 127. Now, when I press the power button, I get the shut down menu in both, SheepShaver and OS X. Is there a way to not have that menu pop up in OS X while SheepShaver is the active application?
Thank you!
I have added a line to the Quartz key mapping in the keycodes file "mapping" 127 to 127. Now, when I press the power button, I get the shut down menu in both, SheepShaver and OS X. Is there a way to not have that menu pop up in OS X while SheepShaver is the active application?
- adespoton
- Forum All-Star
- Posts: 4227
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: Basilisk II keycodes file for entire keyboard.
Hmm... that was only last year too
As for OS X: you could always remap the key in OS X to something benign This would likely mess with your keycodes file though (it'd need to be tweaked again).
As for OS X: you could always remap the key in OS X to something benign This would likely mess with your keycodes file though (it'd need to be tweaked again).
Re: Basilisk II keycodes file for entire keyboard.
Well, the shut down dialog (not menu, sorry for that) on OS X is more important to me than on SheepShaver.
Would there be a way to have e. g. an AppleScript startet when pressing the power button that, in case SheepShaver is the active application, closes the shut down dialog in OS X?
Or to have the script actually only make appear the shut down dialog in OS X if SheepShaver is not the active application?
Would there be a way to have e. g. an AppleScript startet when pressing the power button that, in case SheepShaver is the active application, closes the shut down dialog in OS X?
Or to have the script actually only make appear the shut down dialog in OS X if SheepShaver is not the active application?
- adespoton
- Forum All-Star
- Posts: 4227
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: Basilisk II keycodes file for entire keyboard.
In OS X, you can re-bind the key to run an applescript instead of triggering the apple event. Then you can have the applescript check the frontmost application, and call the event itself if SS or BII aren't frontmost.
Or, you can remap to make the power key present as an eject key, which means you'll be doing control-power for on/off, and can use regular eject as the key for shutdown in the emulators.
Or, you can remap to make the power key present as an eject key, which means you'll be doing control-power for on/off, and can use regular eject as the key for shutdown in the emulators.
Re: Basilisk II keycodes file for entire keyboard.
Is it possible to re-bind the power key to run an AppleScript without having to install additional software?
And, how to call the Apple event with AppleScript (except from using UI scripting)?
I couldn't find an answer to these questions on the web. Maybe I'm again lacking the proper search terms.
And, how to call the Apple event with AppleScript (except from using UI scripting)?
I couldn't find an answer to these questions on the web. Maybe I'm again lacking the proper search terms.
- adespoton
- Forum All-Star
- Posts: 4227
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: Basilisk II keycodes file for entire keyboard.
System Preferences -> Keyboard -> Keyboard Shortcuts is a starting point, but it appears the power key is hard-wired. So you may need to do some file hacking to release it
To do that, you'll find http://scripts.sil.org/cms/scripts/page ... id=ukelele useful. Basically, you need to create your own .keylayout file in ~/Library/Keyboard Layouts/ with the key remapped. It's all XML, so you could do it by hand (just like with the keycodes file).
And yes, you'll need to do UI scripting most likely to do the rest.
To do that, you'll find http://scripts.sil.org/cms/scripts/page ... id=ukelele useful. Basically, you need to create your own .keylayout file in ~/Library/Keyboard Layouts/ with the key remapped. It's all XML, so you could do it by hand (just like with the keycodes file).
And yes, you'll need to do UI scripting most likely to do the rest.
Re: Basilisk II keycodes file for entire keyboard.
I don't want to do UI scripting for this as it would be too slow. What I've found is an AppleScript for shutting down after showing a confirmation dialog:
As this is not the apple event I'm looking for, the last four letters (rsdn) of the script need to be amended.
This is all new to me, so I might be completely wrong here. Does anyone know where to find the related AERegistry.h?
I've looked into the other things you wrote in your last post, but they're not quite clear to me. The predefined options at System Preferences -> Keyboard -> Keyboard Shortcuts don't seem to meet my needs. 'Program Shortcuts', which is the last option in the list, lets me define custom shortcuts. But how to define what is supposed to happen when I press the shortcut?
Once I have the scancode mapped to a different keycode using Ukelele, how do I define that upon pressing the related button (power button) my app created by AppleScript Editor should be started?
Code: Select all
tell application "loginwindow" to «event aevtrsdn»
But where to find AERegistry.h? It should be related to the loginwindow.app located at /System/Library/CoreServices. And according to Google it seems to be part of some framework. I got the impression there is a separate AERegistry.h for each app that can trigger apple events. But I could not find a single one. Where to find the one I need? Neither is it contained in loginwindow.app, nor could I find it somewhere in /System/Library/Frameworks/CoreServices.framework/.The four letter codes for the Apple events are listed in 'AERegistry.h'
This is all new to me, so I might be completely wrong here. Does anyone know where to find the related AERegistry.h?
I've looked into the other things you wrote in your last post, but they're not quite clear to me. The predefined options at System Preferences -> Keyboard -> Keyboard Shortcuts don't seem to meet my needs. 'Program Shortcuts', which is the last option in the list, lets me define custom shortcuts. But how to define what is supposed to happen when I press the shortcut?
Once I have the scancode mapped to a different keycode using Ukelele, how do I define that upon pressing the related button (power button) my app created by AppleScript Editor should be started?
- adespoton
- Forum All-Star
- Posts: 4227
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: Basilisk II keycodes file for entire keyboard.
The easiest way to do it would be to create an AppleScript service in the Services folder; you can assign keyboard shortcuts to these.
I don't have an answer for the other, but I was just thinking... it would probably be easier to just set up a "shutdown now" service that uses the terminal command, and possibly adds an applescript dialog if you want it.
We appear to be getting a bit off topic, and a bit past the simple keycode issue now
I don't have an answer for the other, but I was just thinking... it would probably be easier to just set up a "shutdown now" service that uses the terminal command, and possibly adds an applescript dialog if you want it.
We appear to be getting a bit off topic, and a bit past the simple keycode issue now
Re: Basilisk II keycodes file for entire keyboard.
I've found AERegistry.h in some subfolder of CoreServices.framework. Only not within my Mountain Lion installation, but by searching for it within the Xcode.mpkg on my Snow Leopard Install DVD using Pacifist.
Unfortunately it does not provide the four letter code I was looking for (in order to get the shut down dialog which offers the buttons 'Restart', 'Sleep', 'Cancel', and 'Shut Down'). I could use the code from my last post for the other dialog (the one that is also reachable via the Apple menu, only offering 'Cancel' and 'Shut Down').
I'm stubborn enough for wanting the imitation to be as close to the original as possible, but there seems to be no way to trigger the 'original' dialog box.
Admittedly, this is getting just slightly off topic now.
But past the simple issue? – Hey, when it works (if it ever will …) it will look very simple on the screen (hopefully) …
If I find a solution for what I intended to do I'll post it here – in a new thread.
Adespoton, many thanks for your help!
Unfortunately it does not provide the four letter code I was looking for (in order to get the shut down dialog which offers the buttons 'Restart', 'Sleep', 'Cancel', and 'Shut Down'). I could use the code from my last post for the other dialog (the one that is also reachable via the Apple menu, only offering 'Cancel' and 'Shut Down').
I'm stubborn enough for wanting the imitation to be as close to the original as possible, but there seems to be no way to trigger the 'original' dialog box.
Admittedly, this is getting just slightly off topic now.
But past the simple issue? – Hey, when it works (if it ever will …) it will look very simple on the screen (hopefully) …
If I find a solution for what I intended to do I'll post it here – in a new thread.
Adespoton, many thanks for your help!
- Ronald P. Regensburg
- Expert User
- Posts: 7821
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
Re: Basilisk II keycodes file for entire keyboard.
I want to split this topic in two, starting from the first post by mabam and put that last part in a new topic in SheepShaver forum. Anyone who can suggest a good title for that new topic?
Re: Basilisk II keycodes file for entire keyboard.
Maybe "How to shut down SS using the Power button?".
Good idea to split it.
Good idea to split it.
- Ronald P. Regensburg
- Expert User
- Posts: 7821
- Joined: Thu Feb 09, 2006 10:24 pm
- Location: Amsterdam, Netherlands
- adespoton
- Forum All-Star
- Posts: 4227
- Joined: Fri Nov 27, 2009 5:11 am
- Location: Emaculation.com
- Contact:
Re: How to shut down SS using the Power button?
Thanks
And for those tuning in late, this can be used to repurpose your eject key too
And for those tuning in late, this can be used to repurpose your eject key too