[Script] Dedicated hotkeys for navigating in ZBrush

Post your working scripts, libraries and tools
Villitz
Posts: 6
Joined: 20 Oct 2019, 22:01

[Script] Dedicated hotkeys for navigating in ZBrush

21 Oct 2019, 11:43

A simple script for ZBrush users who dislike the default navigation options (and the complete lack of customizable navigation hotkeys despite being around for 20 years and costing an arm/leg) and want separate hotkeys for each viewport navigation action (pan, rotate, zoom). Doesn't affect any native ZBrush hotkeys.

Script hotkeys:
-Rotate: Capslock + q
-Pan: CapsLock + e
-Zoom: Capslock +w

It also prevents CapsLock from turning on after hotkey use, while allowing it to function normally otherwise.

Code: Select all

;This script assigns the ZBrush viewport navigation functions to new hotkeys: "CapsLock + q", "CapsLock + w", and "CapsLock + e". 
;CapsLock must be held down before pressing the q/w/e keys to prevent accessing the transform widget.
;Right-click navigation must be enabled in Preferences > Interface > Navigation for this script to work correctly
;CapsLock will always return to an 'off' state and remain functional outside of ZBrush.

#NoEnv                             ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir%        ; Ensures a consistent starting directory.
#InstallKeybdHook
#InstallMouseHook                  ; These hooks are probably not needed, but this works as is so i'm keeping them in.
#MenuMaskKey vk07                  ; Reassigns the default MenuMaskKey to the unassigned key vk07. 
                                   ; This prevents AHK from sending the default mask key (Left Control) upon release of Left Alt in the 'zoom' function below.

#IfWinActive, ahk_exe ZBrush.exe   ; Only run the script if ZBrush is the active window
setCapsLockState, off              ; Ensures CapsLock is off. Repeated several times throughout script just to make sure.

CapsLock & q::RButton              ; (Rotate: CapsLock + q) Send right mouse button command when the CapsLock key is pressed
Keywait, CapsLock                  ; Waits for the release of CapsLock and returns it to 'off' state
SetCapsLockState, off

CapsLock & e::!RButton             ; (Pan: CapsLock + e) Send alt+Right Mouse Button command when the CapsLock key is pressed
Keywait, CapsLock                  
SetCapsLockState, off               

CapsLock & w::                     ; (Zoom: CapsLock + w) Send alt command, wait, then send Right Mouse Button command.
SendInput {LAlt down}
sleep, 50                          
SendInput {RButton down}
Keywait, w                         ; Waits until w key is released, then releases keys in correct order to prevent accidental pan/zoom because ZBrush is picky. 
SendInput {RButton up}             ; Note that the Keywait command probably waits for a keypress AND release, but only responds to a key release in this
sleep, 50                          ; context since the w key is already down.
SendInput {LAlt up}                ; If you find the viewport 'jumping' around after releasing this hotkey, increase the sleep timer to ensure proper button release order.
SetCapsLockState, off

Return to “Scripts and Functions”

Who is online

Users browsing this forum: No registered users and 25 guests