mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 02:06:36 +02:00
[KBM]Launch apps / URI with keyboard shortcuts, support chords (#30121)
* Working UI update with just runProgram Path and isRunProgram * First working, basic. no args or path, or setting change detections. * Revert and fixed. * Some clean up, working with config file monitor * Args and Start-in should be working. * File monitor, quotes, xaml screens one * Fixed enable/disable toogle from XAML * Code cleanup. * Betting logging. * Cleanup, start of RunProgramDescriptor and usage of run_non_elevated/run_elevated * Code moved to KeyboardEventHandlers, but not enabled since it won't build as is, needs elevation.h. Other testing.. * Key chords working, pretty much * Added gui for elevation level, need to refresh on change... * f: include shellapi.h and reference wil in KBMEL * run_elevated/run_non_elevated sorted out. Working! * Removed lots of old temp code. * Fix some speling errors. * Cleanup before trying to add a UI for the chord * Added "DifferentUser" option * Closer on UI for chords. * Better UI, lots working. * Clean up * Text for “Allow chords” – needs to look better… * Bugs and clean-up * Cleanup * Refactor and clean up. * More clean up * Some localization. * Don’t show “Allow chords“ to the “to” shortcut * Maybe better foreground after opening new app * Better chord matching. * Runprogram fix for stealing existing shortcut. * Better runProgram stuff * Temp commit * Working well * Toast test * More toast * Added File and Folder picker UI * Pre-check on run program file exists. * Refactor to SetupRunProgramControls * Open URI UI is going. * Open URI working well * Open URI stuff working well * Allowed AppSpecific shortcut and fixed backup/restore shortcut dups * Fixed settings screen * Start of code to find by name... * UI fixed * Small fixes * Some single edit code working. * UI getting better. * Fixes * Fixed and merge from main * UI updates * UI updates. * UI stuff * Fixed crash from move ui item locations. * Fixed crash from move ui item locations. * Added delete confirm * Basic sound working. * Localized some stuff * Added sounds * Better experiance when shortcut is in use. * UI tweaks * Fixed KBM ui for unicode shortcut not having "," * Some clean up * Cleanup * Cleanup * Fixed applyXamlStyling * Added back stuff lost in merge * applyXamlStyling, again * Fixed crash on change from non shortcut to shortcut * Update src/modules/keyboardmanager/KeyboardManagerEngineTest/KeyboardManagerEngineTest.vcxproj * Fixed some spelling type issues. * ImplementationLibrary 231216 * Comment bump to see if the Microsoft.Windows.ImplementationLibrary version thing gets picked up * Correct, Microsoft.Windows.ImplementationLibrary, finally? * Fixed two test that failed because we now allow key-chords. * Removed shortcut sounds. * use original behavior when "allow chords" is off in shortcut window * fix crash when editing a shortcut that has apps specified for it * split KBM chords with comma on dashboard page * Fix some spelling items. * More "spelling" * Fix XAML styling * align TextBlock and ToggleSwitch * fix cutoff issue at the top * increase ComboBox width * Added *Unsupported* for backwards compat on config of KBM * fix spellcheck * Fix crash on Remap key screen * Fixed Remap Keys ComboBox width too short. * Removed KBM Single Edit mode, fixed crash. * Fix Xaml with xaml cops * Fix crash on setting "target app" for some types of shortcuts. * Space to toggle chord, combobox back * fix spellcheck * fix some code nits * Code review updates. * Add exclusions to the bug report tool * Code review and kill CloseAndEndTask * Fix alignment / 3 comboboxes per row * Fix daily telemetry events to exclude start app and open URI * Add chords and remove app start and open uri from config telemetry * comma instead of plus in human readable shortcut telemetry data * Code review, restore default-old state when new row added in KBM * Code review, restore default-old state when new row added in KBM, part 2 * Still show target app on Settings * Only allow enabling chords for origin shortcuts --------- Co-authored-by: Andrey Nekrasov <yuyoyuppe@users.noreply.github.com> Co-authored-by: Jaime Bernardo <jaime@janeasystems.com>
This commit is contained in:
@@ -77,8 +77,26 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
type = static_cast<KeyboardManagerEditorType>(_wtoi(cmdArgs[1]));
|
||||
}
|
||||
|
||||
if (numArgs == 3)
|
||||
std::wstring keysForShortcutToEdit = L"";
|
||||
std::wstring action = L"";
|
||||
|
||||
|
||||
// do some parsing of the cmdline arg to see if we need to behave different
|
||||
// like, single edit mode, or "delete" mode.
|
||||
// These extra args are from "OpenEditor" in the KeyboardManagerViewModel
|
||||
if (numArgs >= 3)
|
||||
{
|
||||
if (numArgs >= 4)
|
||||
{
|
||||
keysForShortcutToEdit = std::wstring(cmdArgs[3]);
|
||||
}
|
||||
|
||||
if (numArgs >= 5)
|
||||
{
|
||||
action = std::wstring(cmdArgs[4]);
|
||||
}
|
||||
|
||||
|
||||
std::wstring pid = std::wstring(cmdArgs[2]);
|
||||
Logger::trace(L"Editor started from the settings with pid {}", pid);
|
||||
if (!pid.empty())
|
||||
@@ -108,7 +126,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
return -1;
|
||||
}
|
||||
|
||||
editor->OpenEditorWindow(type);
|
||||
editor->OpenEditorWindow(type, keysForShortcutToEdit, action);
|
||||
|
||||
editor = nullptr;
|
||||
|
||||
@@ -149,7 +167,7 @@ bool KeyboardManagerEditor::StartLowLevelKeyboardHook()
|
||||
return (hook != nullptr);
|
||||
}
|
||||
|
||||
void KeyboardManagerEditor::OpenEditorWindow(KeyboardManagerEditorType type)
|
||||
void KeyboardManagerEditor::OpenEditorWindow(KeyboardManagerEditorType type, std::wstring keysForShortcutToEdit, std::wstring action)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@@ -157,7 +175,7 @@ void KeyboardManagerEditor::OpenEditorWindow(KeyboardManagerEditorType type)
|
||||
CreateEditKeyboardWindow(hInstance, keyboardManagerState, mappingConfiguration);
|
||||
break;
|
||||
case KeyboardManagerEditorType::ShortcutEditor:
|
||||
CreateEditShortcutsWindow(hInstance, keyboardManagerState, mappingConfiguration);
|
||||
CreateEditShortcutsWindow(hInstance, keyboardManagerState, mappingConfiguration, keysForShortcutToEdit, action);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,20 +23,20 @@ public:
|
||||
}
|
||||
|
||||
bool StartLowLevelKeyboardHook();
|
||||
void OpenEditorWindow(KeyboardManagerEditorType type);
|
||||
void OpenEditorWindow(KeyboardManagerEditorType type, std::wstring keysForShortcutToEdit, std::wstring action);
|
||||
|
||||
// Function called by the hook procedure to handle the events. This is the starting point function for remapping
|
||||
intptr_t HandleKeyboardHookEvent(LowlevelKeyboardEvent* data) noexcept;
|
||||
|
||||
private:
|
||||
static LRESULT CALLBACK KeyHookProc(int nCode, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
|
||||
inline static HHOOK hook;
|
||||
HINSTANCE hInstance;
|
||||
|
||||
KBMEditor::KeyboardManagerState keyboardManagerState;
|
||||
MappingConfiguration mappingConfiguration;
|
||||
|
||||
|
||||
// Object of class which implements InputInterface. Required for calling library functions while enabling testing
|
||||
KeyboardManagerInput::Input inputHandler;
|
||||
};
|
||||
|
||||
@@ -154,7 +154,9 @@
|
||||
<Manifest Include="KeyboardManagerEditor.exe.manifest" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources.resx" />
|
||||
<None Include="Resources.resx">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Image Include="Keyboard.ico" />
|
||||
|
||||
@@ -144,6 +144,15 @@
|
||||
<data name="EditShortcuts_WindowName" xml:space="preserve">
|
||||
<value>Remap shortcuts</value>
|
||||
</data>
|
||||
<data name="Edit_This_Shortcut_WindowName" xml:space="preserve">
|
||||
<value>Edit shortcut</value>
|
||||
</data>
|
||||
<data name="Browse_For_Program_Button" xml:space="preserve">
|
||||
<value>Select program</value>
|
||||
</data>
|
||||
<data name="Browse_For_Path_Button" xml:space="preserve">
|
||||
<value>Select path</value>
|
||||
</data>
|
||||
<data name="Ok_Button" xml:space="preserve">
|
||||
<value>OK</value>
|
||||
</data>
|
||||
@@ -161,12 +170,60 @@
|
||||
<value>To send:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_TargetHeader" xml:space="preserve">
|
||||
<value>To send:</value>
|
||||
<value>To:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_TargetAppHeader" xml:space="preserve">
|
||||
<value>Target app:</value>
|
||||
</data>
|
||||
<data name="EditKeyboard_OrphanedDialogTitle" xml:space="preserve">
|
||||
<data name="EditShortcuts_Label_Args" xml:space="preserve">
|
||||
<value>Args:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Elevation" xml:space="preserve">
|
||||
<value>Elevation:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Start_As" xml:space="preserve">
|
||||
<value>Visibility:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Program" xml:space="preserve">
|
||||
<value>App:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Start_In" xml:space="preserve">
|
||||
<value>Start in:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Action" xml:space="preserve">
|
||||
<value>Action:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Path_URI" xml:space="preserve">
|
||||
<value>Path/URI:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Shortcut" xml:space="preserve">
|
||||
<value>Shortcut:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_Keys" xml:space="preserve">
|
||||
<value>Keys:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Visibility_Normal" xml:space="preserve">
|
||||
<value>Normal</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Visibility_Hidden" xml:space="preserve">
|
||||
<value>Hidden</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_If_Running" xml:space="preserve">
|
||||
<value>If running:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Label_App_Running_Sound" xml:space="preserve">
|
||||
<value>Running sound:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_LabelApp_Not_Running_Sound" xml:space="preserve">
|
||||
<value>Start sound:</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Bad_Key" xml:space="preserve">
|
||||
<value>Key in use</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_BtnSelectFile" xml:space="preserve">
|
||||
<value>Select file</value>
|
||||
</data>
|
||||
<data name="EditKeyboard_OrphanedDialogTitle" xml:space="preserve">
|
||||
<value>Warning: The following keys do not have assignments:</value>
|
||||
<comment>Key on a keyboard</comment>
|
||||
</data>
|
||||
@@ -184,7 +241,11 @@
|
||||
<comment>Key on a keyboard</comment>
|
||||
</data>
|
||||
<data name="EditShortcuts_Info" xml:space="preserve">
|
||||
<value>Select the shortcut you want to change ("Select") and then configure the key, shortcut or text you want it to send ("To send").</value>
|
||||
<value>Edit shortcuts to activate and then configure the actions to happen when activated.</value>
|
||||
<comment>Key on a keyboard</comment>
|
||||
</data>
|
||||
<data name="Edit_Single_Shortcut_Info" xml:space="preserve">
|
||||
<value>Edit shortcut to activate and then configure the action to happen when activated.</value>
|
||||
<comment>Key on a keyboard</comment>
|
||||
</data>
|
||||
<data name="EditShortcuts_InfoExample" xml:space="preserve">
|
||||
@@ -211,6 +272,9 @@
|
||||
<value>Keys selected:</value>
|
||||
<comment>Keys on a keyboard</comment>
|
||||
</data>
|
||||
<data name="Type_HoldSpace" xml:space="preserve">
|
||||
<value>Hold Space to toggle allow chord</value>
|
||||
</data>
|
||||
<data name="Type_HoldEnter" xml:space="preserve">
|
||||
<value>Hold Enter to continue</value>
|
||||
</data>
|
||||
@@ -220,6 +284,24 @@
|
||||
<data name="EditShortcuts_AllApps" xml:space="preserve">
|
||||
<value>All apps</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Allow_Chords" xml:space="preserve">
|
||||
<value>Allow chords</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Path_To_Program" xml:space="preserve">
|
||||
<value>Path to program</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Uri_Example" xml:space="preserve">
|
||||
<value>E.g.: https://website.url</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_What_Can_I_Use_Link" xml:space="preserve">
|
||||
<value>What can I use?</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Args_For_Program" xml:space="preserve">
|
||||
<value>Arguments for program</value>
|
||||
</data>
|
||||
<data name="EditShortcuts_Start_In_Dir_For_Program" xml:space="preserve">
|
||||
<value>Start in directory</value>
|
||||
</data>
|
||||
<data name="ErrorMessage_RemapSuccessful" xml:space="preserve">
|
||||
<value>Remapping successful</value>
|
||||
</data>
|
||||
@@ -288,12 +370,20 @@
|
||||
<comment>Key on a keyboard</comment>
|
||||
</data>
|
||||
<data name="Mapping_Type_DropDown_Text" xml:space="preserve">
|
||||
<value>Text</value>
|
||||
<value>Send Text</value>
|
||||
</data>
|
||||
<data name="Mapping_Type_DropDown_Key_Shortcut" xml:space="preserve">
|
||||
<value>Key/Shortcut</value>
|
||||
<value>Send Key/Shortcut</value>
|
||||
<comment>Key on a keyboard</comment>
|
||||
</data>
|
||||
<data name="Mapping_Type_DropDown_Run_Program" xml:space="preserve">
|
||||
<value>Run Program</value>
|
||||
<comment>Run Program</comment>
|
||||
</data>
|
||||
<data name="Mapping_Type_DropDown_Open_URI" xml:space="preserve">
|
||||
<value>Open URI</value>
|
||||
<comment>URI to open.</comment>
|
||||
</data>
|
||||
<data name="Add_Key_Remap_Button" xml:space="preserve">
|
||||
<value>Add key remapping</value>
|
||||
<comment>Key on a keyboard</comment>
|
||||
@@ -304,6 +394,33 @@
|
||||
<data name="Delete_Remapping_Button" xml:space="preserve">
|
||||
<value>Delete remapping</value>
|
||||
</data>
|
||||
<data name="Already_Running_Do_Nothing" xml:space="preserve">
|
||||
<value>Do nothing</value>
|
||||
</data>
|
||||
<data name="Already_Running_Show_Window" xml:space="preserve">
|
||||
<value>Show window</value>
|
||||
</data>
|
||||
<data name="Already_Running_Start_Another" xml:space="preserve">
|
||||
<value>Start another</value>
|
||||
</data>
|
||||
<data name="Already_Running_Close" xml:space="preserve">
|
||||
<value>Close</value>
|
||||
</data>
|
||||
<data name="Already_Running_Terminate" xml:space="preserve">
|
||||
<value>End task</value>
|
||||
</data>
|
||||
<data name="Already_Running_Close_And_Terminate" xml:space="preserve">
|
||||
<value>Close and end task</value>
|
||||
</data>
|
||||
<data name="Elevation_Type_Normal" xml:space="preserve">
|
||||
<value>Normal</value>
|
||||
</data>
|
||||
<data name="Elevation_Type_Elevated" xml:space="preserve">
|
||||
<value>Elevated</value>
|
||||
</data>
|
||||
<data name="Elevation_Type_Different_User" xml:space="preserve">
|
||||
<value>Different User</value>
|
||||
</data>
|
||||
<data name="Delete_Remapping_Event" xml:space="preserve">
|
||||
<value>Remapping deleted</value>
|
||||
</data>
|
||||
|
||||
Reference in New Issue
Block a user