Code Monkey home page Code Monkey logo

globalhotkeymanager's Introduction

GlobalHotkeyManager

  • A Windows background tool built by Qt used to manage global hotkeys.

Environment

  • Qt 5.15.2 (MinGW 8.1.0 64-bit)
  • Windows 10 21H2 x64

Build and deploy

  • Build
# 1. Qmake and generate Makefile
mkdir build
cd build
qmake ..

# 2. Build in debug mode (with console)
make debug
# Or build in release mode (without console)
make release
# Or build both in debug and release modes
make all

# 3. Initialize registry config
default_config.reg # only contains application default configuration
# Or
example_config.reg # contains application default configuration and four hotkeys

# 4. Run the built executable
./build/debug/GlobalHotkeyManager.exe
# Or
./build/release/GlobalHotkeyManager.exe
  • Build with multi-language supported (English, Simplified Chinese, Japanese)
# 1. Build qm files from current ts files
lrelease GlobalHotkeyManager.pro

# 2. Build qt_zh_CN.qm
lconvert -o res/qt_zh_CN.ts <Qt installation path>/translations/qt_zh_CN.qm
sed -i "s/QDialogButtonBox/QPlatformTheme/g" res/qt_zh_CN.ts # fix QMessageBox translation bug in Chinese
lrelease res/qt_zh_CN.ts -qm res/qt_zh_CN.qm

# 3. Build qt_ja_JP.qm
lconvert -o res/qt_ja_JP.ts <Qt installation path>/translations/qtbase_ja.qm <Qt installation path>/translations/qtdeclarative_ja.qm
lrelease res/qt_ja_JP.ts -qm res/qt_ja_JP.qm

# 4. Build GlobalHotkeyManager again
cd build
make debug
  • Deploy with Qt dependencies
# 1. Build GlobalHotkeyManager in release mode first
cd build
make release

# 2. Deploy to self-contained folder
cd ..
mkdir dist
cp build/release/GlobalHotkeyManager.exe dist/GlobalHotkeyManager.exe
windeployqt dist/GlobalHotkeyManager.exe

# 3. Run the deployed executable (which can be executed in environment without qt)
./dist/GlobalHotkeyManager.exe

Configure

; From example_config.reg

[HKEY_CURRENT_USER\SOFTWARE\AoiHosizora\GlobalHotkeyManager]
"Hotkey"="Ctrl+Shift+Alt+F12"
"Lang"="en"

[HKEY_CURRENT_USER\SOFTWARE\AoiHosizora\GlobalHotkeyManager\01 cmd]
@="Command Prompt"
"Parameter"="/s /k pushd \"%USERPROFILE%\""
"Hotkey"="Ctrl+Alt+X"
"File"="cmd.exe"

[HKEY_CURRENT_USER\SOFTWARE\AoiHosizora\GlobalHotkeyManager\02 cmd admin]
@="Command Prompt (Admin)"
"Operation"="runas"
"Parameter"="/s /k pushd \"%USERPROFILE%\""
"Hotkey"="Ctrl+Alt+Z"
"File"="cmd.exe"

Root key

  • Hotkey - Hotkey to open the config dialog, defaults to Ctrl+Shift+Alt+F12
  • Lang - Language, defaults to en, available items: en or en_us, zh or zh_cn, ja or ja_jp

Sub key

  • key name - Hotkey ID, required, it is actually useless except sorting hotkey items
  • @ - Hotkey title, required
  • File - Executable file path, required
  • Hotkey - Hotkey for executable file, required
    • Some examples: F10 / Shift+Esc / Ctrl+Alt+0 / Ctrl+Shift+Alt+Z / Ctrl+Win+Insert
  • Operation - Execute operation, defaults to open, it can be set to runas to execute as administrator
  • Parameter - Execute parameter, optional
    • Command prompt example: /s /k pushd "%USERPROFILE%"
    • Powershell example: -noexit -command Set-Location -literalPath "$env:USERPROFILE"
  • Directory - Working directory to execute file, optional
  • Style - Window style when executing, defaults to SW_NORMAL, it can be set to SW_HIDE or 0 to hide window

Screenshots

main_window registry

Reference

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.