Index  | Recent Threads  | List Attachments  | Search
 Welcome Guest  |  Register  |  Login
Login Name  Password
 

Sweet Home 3D Forum



No member browsing this thread
Thread Status: Active
Total posts in this thread: 2
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 15312 times and has 1 reply Next Thread
gcalavaro
Newbie



Italy
Joined: Nov 18, 2018
Post Count: 8
Status: Offline
Reply to this Post  Reply with Quote 
customize function keys in windows to make keyboard shortcuts

Hi,
I have been looking to set up function keys in Windows to speed up some commands I use more frequently.
For example Modify Walls has CTRL-SHIFT-E Keyboard shortcut, but I would prefer to put on F2, while I would like to put on F3 modify rooms and on F4 modify furniture.
Is there a way to make such setting?
Thank you very much for your attention
and keep up with this great work. This tool is really outstanding.
Ciao
Giuseppe
[Nov 18, 2018, 11:53:58 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
klaus0
Newbie



Austria
Joined: Jan 27, 2025
Post Count: 1
Status: Offline
Reply to this Post  Reply with Quote 
Re: customize function keys in windows to make keyboard shortcuts

If someone else comes across this: I solved it by writing a small bash script.

Requirements: Git for Windows, to be executed by "Git Bash". With default install location of Sweet Home 3D, has to be run in a shell that has been opened with admin permissions.

Modification: Adjust the variables at the beginning of the file. Should be self-explanatory.

The script:


#!/usr/bin/bash
# -*- coding: utf-8-unix -*-
# shellcheck enable=check-unassigned-uppercase
# shellcheck disable=SC2064

set -e -u


INSTALL_DIR="C:/Program Files (x86)/Sweet Home 3D"
JAR_FILE="${INSTALL_DIR}/lib/SweetHome3D.jar"
PACKAGE_FILE="com/eteks/sweethome3d/swing/package.properties"
KEY_OVERRIDES=(
E HomePane.MODIFY_ROOM
E HomePane.MODIFY_FURNITURE
E HomePane.MODIFY_WALL
E HomePane.MODIFY_DIMENSION_LINE
E HomePane.MODIFY
"control J" HomePane.JOIN_WALLS
ESCAPE HomePane.SELECT
L HomePane.CREATE_DIMENSIONS
J HomePane.CREATE_POLYLINES
T HomePane.CREATE_LABELS
W HomePane.CREATE_WALLS
R HomePane.CREATE_ROOMS
)

# back up the original file as a starting point
if ! [[ -e "${JAR_FILE}.bak" ]]; then
cp "${JAR_FILE}" "${JAR_FILE}.bak"
fi

# set up a temporary directory
TMPDIR=$(mktemp -d)
trap "rm -rf '$TMPDIR'" exit
cd "$TMPDIR"

# extract the settings files

unzip "${JAR_FILE}.bak" "${PACKAGE_FILE}"

# list current hotkeys
echo
echo CURRENT HOTKEYS
printf "%15s %8s %-20s %s\n" PANE KEYS MODIFIERS ACTION
perl -ne '
if(/^(?<pane>.+?)\.(?<action>.+)\.AcceleratorKey=(?<modifiers>(\w+ )*)(?<key>\w+)$/) {
printf "%15s %8s %-20s %s\n", $+{pane}, $+{key}, $+{modifiers}, $+{action};
}
' "${PACKAGE_FILE}" | sort

# modify the file
echo
echo MODIFYING HOTKEYS...
i=0
cp "${PACKAGE_FILE}" "${PACKAGE_FILE}.old"
while [[ $i -lt ${#KEY_OVERRIDES[@]} ]]; do
key=${KEY_OVERRIDES[$((i++))]}
action=${KEY_OVERRIDES[$((i++))]}
perl -pe "s{^$action.AcceleratorKey=.*}{$action.AcceleratorKey=$key}" -i "${PACKAGE_FILE}"
done
diff -U0 "${PACKAGE_FILE}.old" "${PACKAGE_FILE}" || true

# updating jar file
echo
echo UPDATING JAR FILE...
zip "${JAR_FILE}" "${PACKAGE_FILE}"


echo
echo DONE...

[Jan 27, 2025, 12:02:46 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread

  Get Sweet Home 3D at SourceForge.net. Fast, secure and Free Open Source software downloads  
© Copyright 2024 Space Mushrooms - All rights reserved