Hey guys,
I'm not sure how to approach a script like this. I've googled this for a bit and haven't been successful finding much. Here's what I'm trying to do. I'm using a 3D program and I'd like when I enter a specific tool (like when I press B for brush[painting]) all of my keys change to suit a painting environment. But if I click another key, such as "S" it switches to all of my sculpting binds, replacing my painting key binds.
Thanks so much for your time and help!
Pressing 1 key changes a bunch of keybinds at once, pressing another key rewrites said keys to something else.
Re: Pressing 1 key changes a bunch of keybinds at once, pressing another key rewrites said keys to something else.
Pretty straightforward:
Don’t change anything in the above script other than to add the hotkeys for each mode where the comment lines say to add them. You can remove the example x hotkeys, of course. They are there to demonstrate that the same key has a different action depending on what mode you’re in.
Code: Select all
Mode := "b" ; set initial default mode
return
b::
s::
Mode := A_ThisHotkey
SoundBeep
return
#If Mode = "b"
; all the definitions of your hotkeys for brush mode go here
x::MsgBox, You pressed "X" while in brush mode
#If Mode = "s"
; all the definitions of your hotkeys for sculpting mode go here
x::MsgBox, You pressed "X" while in sculpting mode
Don’t change anything in the above script other than to add the hotkeys for each mode where the comment lines say to add them. You can remove the example x hotkeys, of course. They are there to demonstrate that the same key has a different action depending on what mode you’re in.
Re: Pressing 1 key changes a bunch of keybinds at once, pressing another key rewrites said keys to something else.
Here's a sample template of how to do this in v2. Same concept as @boiler . Substitute "ahk_exe notepad.exe" with your 3D program.
Code: Select all
Escape::ExitApp ; optional, use Escape for this script to exit.
global brushMode:=0
global sculptMode:=0
#HotIf WinActive("ahk_exe notepad.exe")
b::{ ; brushMode
global
sculptMode:=0
brushMode:=1
Tip("Brush Mode")
}
s::{ ; sculptMode
global
brushMode:=0
sculptMode:=1
Tip("Sculpt Mode")
}
d::{ ; default
global
brushMode:=0
sculptMode:=0
Tip("Default Mode")
}
#HotIf WinActive("ahk_exe notepad.exe") and brushMode
a::{
Tip("a pressed in brushMode")
}
#HotIf Winactive("ahk_exe notepad.exe") and sculptMode=1
a::{
Tip("a pressed in sculptMode")
}
#HotIf ; turn off context sensitivity
Tip(Text:=""){ ; Function to Display Tooltip Text for 1 Second
ToolTip(Text)
SetTimer(ToolTip,-1000)
}
Re: Pressing 1 key changes a bunch of keybinds at once, pressing another key rewrites said keys to something else.
Amazing! Thanks for the help guys, I'll give this a shot!