Saturday, October 1, 2022

#1 2011-09-20 11:12:10 am

htakeuchi
Member
Registered: 2011-08-09
Posts: 26

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!!

Offline

 

#2 2011-09-20 11:17:31 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11775
Website

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

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


regards

Stefan

Offline

 

#3 2022-08-01 09:48:11 am

KniazidisR
Member
From:: Greece
Registered: 2019-03-03
Posts: 2531

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

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:

Applescript:


-- 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.

Applescript:


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

Last edited by KniazidisR (2022-08-01 10:44:22 am)


Model: MacBook Pro
OS X: Catalina 10.15.7
Web Browser: Safari 14.1
Ram: 4 GB


Filed under: Fn key

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)