[Pythonmac-SIG] Das Keyboard

Josh Marshall josh.p.marshall at gmail.com
Thu Oct 12 23:52:10 CEST 2006


On 13/10/2006, at 4:02 AM, Perry Smith < wrote:
>
> I bought a keyboard called Das Keyboard.  When I plug it in, the  
> Mac needs me to hit two keys so it can identify the keyboard.
>
> Does Python on the Mac have any way to catch this "event" (it may  
> not be an event actually)?
I don't know, sorry.

>
> The other question is for this keyboard, the command and option  
> keys are flipped.  There is a control panel that can be used to  
> flip them but I would like two applications to flip them or to set  
> them back to normal (I use this keyboard on a laptop so I am  
> frequently plugging it in and out).
This is a bit off-topic, but I'll answer it anyway, since I had the  
same problem and it is quite frustrating.

I found this script somewhere on the net a few months back, but  
googling now doesn't find it.

Add the following to a script in Script Editor:

"""
tell application "System Preferences"
	activate
	set current pane to pane "com.apple.preference.keyboard"
end tell

tell application "System Events"
	get properties
	tell application process "System Preferences"
		click button "Modifier Keys…" of tab group 1 of window "Keyboard &  
Mouse"
		
		set commandKey to value of pop up button 3 of sheet 1 of window  
"Keyboard & Mouse"
		
		-- DEBUG
		-- display dialog commandKey
		
		--  Default, lets flip
		if commandKey ends with "Option" then
			-- click the pop up button menu "Option", this menu does not exist  
until it is clicked in the GUI
			click pop up button 3 of sheet 1 of window "Keyboard & Mouse"
			-- click "Command" of the pop up menu
			click menu item 4 of menu 1 of pop up button 3 of sheet 1 of  
window "Keyboard & Mouse"
			
			-- delay briefly
			delay 1
			
			-- click the pop up button menu "Command", this menu does not  
exist until it is clicked in the GUI
			click pop up button 4 of sheet 1 of window "Keyboard & Mouse"
			-- click "Option" of the pop up menu
			click menu item 3 of menu 1 of pop up button 4 of sheet 1 of  
window "Keyboard & Mouse"
			
			-- Not Default, lets flip it back
		else
			click button "Restore Defaults" of sheet 1 of window "Keyboard &  
Mouse"
		end if
		
		-- click "OK" to dismiss the sheet
		click button "OK" of sheet 1 of window "Keyboard & Mouse"
		
	end tell
end tell

tell application "System Preferences" to quit
"""
Enable user interface scripting in System Prefs:Accessibility, put  
the script in your Library/Scripts folder, and enable the system  
scripting menu. You can then run this script from the menu, and it'l  
swap your Command and Option keys.

Cheers,
Josh

>
> Thanks,
> Perry Smith
> Ease Software, Inc.
> pedz at easesoftware.com
> http://www.easesoftware.com
>
> SATA Products for IBMs RS/6000, pSeries, and AIX systems



More information about the Pythonmac-SIG mailing list