Open tufu9441 opened 7 years ago
You need to use applescript, I came pretty close, but need to go to bed. Will take another crack at it again tomorrow. Test this one out 1st see if it works for you.
<vkopenurldef>
<name>KeyCode::VK_OPEN_URL_HIDE_ALL_WINDOW</name>
<url type="shell">
osascript -e '
tell application "System Events"
key down {option}
key down {command}
keystroke "mh"
key up {option}
key up {command}
end
'
</url>
</vkopenurldef>
<item>
<name>remap Control_L + D to Hide all windows</name>
<identifier>private.remap.Control_L.+.D.to.hide.all.windows</identifier>
<autogen>
__KeyToKey__
KeyCode::D, ModifierFlag::CONTROL_L, ModifierFlag::NONE,
KeyCode::VK_OPEN_URL_HIDE_ALL_WINDOW,
</autogen>
</item>
BTW the reference doc url is at https://pqrs.org/osx/karabiner/xml.html.en
Thanks very much! I have tested and it can work normally.
This is a cleaner version. With the applescript I was trying to simulate simultaneous key presses "h" and "m" together but failed. The code above and below do exactly the same thing but the new one is much cleaner.
<item>
<name>remap Control_L + D to Hide all windows</name>
<identifier>private.remap.Control_L.+.D.to.hide.all.windows</identifier>
<autogen>
__KeyToKey__
KeyCode::D, ModifierFlag::CONTROL_L, ModifierFlag::NONE,
<!-- Will run next 2 key combo which is similar effect to option + command + h + m -->
KeyCode::M, ModifierFlag::OPTION_L, ModifierFlag::COMMAND_L,
KeyCode::H, ModifierFlag::OPTION_L, ModifierFlag::COMMAND_L,
</autogen>
</item>
OK I see, it works perfectly, thanks again for your guidance and help!
Since I want to use Control_L + D to hide all the windows, but I cannot find a correct way to realize it after many tries, please introduce me a right syntax, thanks very much!