Clicking "fn" and "enter" together -- Code 63 Not working

Hello everyone again…

I am trying to press the “fn” & “Enter” buttons together,

I tried key code 63

“System Events” to key code 36 using {function down}

but not working…

Now…

If someone can tell me the previous or… I have a window that has a “Send” button but I have not been able to invoke the window and get the “Send button” to be pressed…

Thanks!!

Hi,

the fn key as well as the eject key is not scriptable via key codes.

Check the window with Apple’s UIElementInspector or PreFab’s UI Browser to get the proper reference to the button

I think the following information should be useful to users.

In fact, the Fn key is quite programmable. It is only necessary that the current foreground application has an (Fn + some Function Key) shortcut to which some application action is attached.

For example, if you look in the Shortcuts tab of Keyboard pane of System Preferences for Mission Control.app, it says the default shortcut Fn+F11 causes the Mission Control.app to close its interface (window) opened before. Because closing its interface is equivalent to Show Desktop (of current workspace) action.

Here is a visual demonstration from me:


-- open "Mission Control" interface
tell application "Mission Control" to launch

delay 5 -- to see all process visually

-- close "Mission Control" interface
tell application "System Events"
	key down 63 -- press "Fn" key
	key code 103 -- key "F11" (one of functional keys)
	key up 63 -- release "Fn" key
end tell

.
Important NOTE: to test my script works, in the KeyBoard tab of KeyBoard pane of System Preferences setting Use F1,F2, etc as standard function keys should be checked.

.
.
Here is another (slightly more useful example).
It changes desktop picrures to 3 workspaces created earlier by the user.


set desktopPicturesFolder to alias (((path to library folder from system domain) as text) & "Desktop Pictures")
set picturePath to POSIX path of (choose file default location desktopPicturesFolder)
-- or,
-- set picturePath to "/Users/xyz/Documents/Screenshots/wallpaper.png"

tell application "Mission Control" to launch

tell application "System Events"
	-- set picture for workspace 1 
	tell desktops to set picture to picturePath
	-- set picture for 2 other workspaces
	repeat 2 times
		key code 124 using control down -- activates the  next workspace
		delay 1
		tell desktops to set picture to picturePath
	end repeat
	-- return to workspace 1
	key code 18 using control down
	delay 1
	-- exit "Mission Control" interface
	key down 63
	key code 103
	key up 63
end tell