mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-06-07 09:28:03 +08:00
[Analyzers][CPP]Changes to fix warning 26493 on src/modules/ (H to K) (#23484)
* Changes to fix warning 26493 on src/modules/ starting with letter H to Letter K * change from PR comments
This commit is contained in:
parent
fb531139c8
commit
0c5b528c54
@ -57,7 +57,7 @@ private:
|
|||||||
void bring_process_to_front()
|
void bring_process_to_front()
|
||||||
{
|
{
|
||||||
auto enum_windows = [](HWND hwnd, LPARAM param) -> BOOL {
|
auto enum_windows = [](HWND hwnd, LPARAM param) -> BOOL {
|
||||||
HANDLE process_handle = (HANDLE)param;
|
HANDLE process_handle = reinterpret_cast<HANDLE>(param);
|
||||||
DWORD window_process_id = 0;
|
DWORD window_process_id = 0;
|
||||||
|
|
||||||
GetWindowThreadProcessId(hwnd, &window_process_id);
|
GetWindowThreadProcessId(hwnd, &window_process_id);
|
||||||
|
@ -227,7 +227,7 @@ private:
|
|||||||
auto val = get_last_error_message(GetLastError());
|
auto val = get_last_error_message(GetLastError());
|
||||||
Logger::warn(L"UuidCreate can not create guid. {}", val.has_value() ? val.value() : L"");
|
Logger::warn(L"UuidCreate can not create guid. {}", val.has_value() ? val.value() : L"");
|
||||||
}
|
}
|
||||||
else if (UuidToString(&temp_uuid, (RPC_WSTR*)&uuid_chars) != RPC_S_OK)
|
else if (UuidToString(&temp_uuid, reinterpret_cast<RPC_WSTR*>(& uuid_chars)) != RPC_S_OK)
|
||||||
{
|
{
|
||||||
auto val = get_last_error_message(GetLastError());
|
auto val = get_last_error_message(GetLastError());
|
||||||
Logger::warn(L"UuidToString can not convert to string. {}", val.has_value() ? val.value() : L"");
|
Logger::warn(L"UuidToString can not convert to string. {}", val.has_value() ? val.value() : L"");
|
||||||
@ -236,7 +236,7 @@ private:
|
|||||||
if (uuid_chars != nullptr)
|
if (uuid_chars != nullptr)
|
||||||
{
|
{
|
||||||
pipe_name += std::wstring(uuid_chars);
|
pipe_name += std::wstring(uuid_chars);
|
||||||
RpcStringFree((RPC_WSTR*)&uuid_chars);
|
RpcStringFree(reinterpret_cast<RPC_WSTR*>(&uuid_chars));
|
||||||
uuid_chars = nullptr;
|
uuid_chars = nullptr;
|
||||||
}
|
}
|
||||||
create_pipe_thread = std::thread(&ImageResizerContextMenuCommand::StartNamedPipeServerAndSendData, this, pipe_name);
|
create_pipe_thread = std::thread(&ImageResizerContextMenuCommand::StartNamedPipeServerAndSendData, this, pipe_name);
|
||||||
|
@ -130,7 +130,7 @@ HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu,
|
|||||||
mii.fType = MFT_STRING;
|
mii.fType = MFT_STRING;
|
||||||
mii.dwTypeData = (PWSTR)strResizePictures;
|
mii.dwTypeData = (PWSTR)strResizePictures;
|
||||||
mii.fState = MFS_ENABLED;
|
mii.fState = MFS_ENABLED;
|
||||||
HICON hIcon = (HICON)LoadImage(g_hInst_imageResizer, MAKEINTRESOURCE(IDI_RESIZE_PICTURES), IMAGE_ICON, 16, 16, 0);
|
HICON hIcon = static_cast<HICON>(LoadImage(g_hInst_imageResizer, MAKEINTRESOURCE(IDI_RESIZE_PICTURES), IMAGE_ICON, 16, 16, 0));
|
||||||
if (hIcon)
|
if (hIcon)
|
||||||
{
|
{
|
||||||
mii.fMask |= MIIM_BITMAP;
|
mii.fMask |= MIIM_BITMAP;
|
||||||
@ -185,7 +185,7 @@ HRESULT CContextMenuHandler::GetCommandString(UINT_PTR idCmd, UINT uType, _In_ U
|
|||||||
{
|
{
|
||||||
if (uType == GCS_VERBW)
|
if (uType == GCS_VERBW)
|
||||||
{
|
{
|
||||||
wcscpy_s((LPWSTR)pszName, cchMax, RESIZE_PICTURES_VERBW);
|
wcscpy_s(reinterpret_cast<LPWSTR>(pszName), cchMax, RESIZE_PICTURES_VERBW);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -211,7 +211,7 @@ HRESULT CContextMenuHandler::InvokeCommand(_In_ CMINVOKECOMMANDINFO* pici)
|
|||||||
}
|
}
|
||||||
else if (fUnicode && HIWORD(((CMINVOKECOMMANDINFOEX*)pici)->lpVerbW))
|
else if (fUnicode && HIWORD(((CMINVOKECOMMANDINFOEX*)pici)->lpVerbW))
|
||||||
{
|
{
|
||||||
if (wcscmp(((CMINVOKECOMMANDINFOEX*)pici)->lpVerbW, RESIZE_PICTURES_VERBW) == 0)
|
if (wcscmp((reinterpret_cast<CMINVOKECOMMANDINFOEX*>(pici))->lpVerbW, RESIZE_PICTURES_VERBW) == 0)
|
||||||
{
|
{
|
||||||
hr = ResizePictures(pici, nullptr);
|
hr = ResizePictures(pici, nullptr);
|
||||||
}
|
}
|
||||||
@ -230,7 +230,7 @@ HRESULT CContextMenuHandler::ResizePictures(CMINVOKECOMMANDINFO* pici, IShellIte
|
|||||||
// Set the application path based on the location of the dll
|
// Set the application path based on the location of the dll
|
||||||
std::wstring path = get_module_folderpath(g_hInst_imageResizer);
|
std::wstring path = get_module_folderpath(g_hInst_imageResizer);
|
||||||
path = path + L"\\PowerToys.ImageResizer.exe";
|
path = path + L"\\PowerToys.ImageResizer.exe";
|
||||||
LPTSTR lpApplicationName = (LPTSTR)path.c_str();
|
LPTSTR lpApplicationName = &path[0];
|
||||||
// Create an anonymous pipe to stream filenames
|
// Create an anonymous pipe to stream filenames
|
||||||
SECURITY_ATTRIBUTES sa;
|
SECURITY_ATTRIBUTES sa;
|
||||||
HANDLE hReadPipe;
|
HANDLE hReadPipe;
|
||||||
|
@ -29,9 +29,9 @@ namespace BufferValidationHelpers
|
|||||||
if (selectedKeyCode != -1)
|
if (selectedKeyCode != -1)
|
||||||
{
|
{
|
||||||
// Check if the value being set is the same as the other column
|
// Check if the value being set is the same as the other column
|
||||||
if (remapBuffer[rowIndex].first[std::abs(int(colIndex) - 1)].index() == 0)
|
if (remapBuffer[rowIndex].first[std::abs(colIndex - 1)].index() == 0)
|
||||||
{
|
{
|
||||||
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].first[std::abs(int(colIndex) - 1)]);
|
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].first[std::abs(colIndex - 1)]);
|
||||||
if (otherColumnKeyCode == selectedKeyCode || IsKeyRemappingToItsCombinedKey(selectedKeyCode, otherColumnKeyCode))
|
if (otherColumnKeyCode == selectedKeyCode || IsKeyRemappingToItsCombinedKey(selectedKeyCode, otherColumnKeyCode))
|
||||||
{
|
{
|
||||||
errorType = ShortcutErrorType::MapToSameKey;
|
errorType = ShortcutErrorType::MapToSameKey;
|
||||||
@ -189,7 +189,7 @@ namespace BufferValidationHelpers
|
|||||||
// If the user tries to set an action key check if all drop down menus after this are empty if it is not the first key.
|
// If the user tries to set an action key check if all drop down menus after this are empty if it is not the first key.
|
||||||
// If it is a hybrid control, this can be done even on the first key
|
// If it is a hybrid control, this can be done even on the first key
|
||||||
bool isClear = true;
|
bool isClear = true;
|
||||||
for (int i = dropDownIndex + 1; i < (int)dropDownCount; i++)
|
for (int i = dropDownIndex + 1; i < static_cast<int>(dropDownCount); i++)
|
||||||
{
|
{
|
||||||
if (selectedCodes[i] != -1)
|
if (selectedCodes[i] != -1)
|
||||||
{
|
{
|
||||||
@ -244,9 +244,9 @@ namespace BufferValidationHelpers
|
|||||||
if (tempShortcut.index() == 1)
|
if (tempShortcut.index() == 1)
|
||||||
{
|
{
|
||||||
// If shortcut to shortcut
|
// If shortcut to shortcut
|
||||||
if (remapBuffer[rowIndex].first[std::abs(int(colIndex) - 1)].index() == 1)
|
if (remapBuffer[rowIndex].first[std::abs(colIndex - 1)].index() == 1)
|
||||||
{
|
{
|
||||||
auto& shortcut = std::get<Shortcut>(remapBuffer[rowIndex].first[std::abs(int(colIndex) - 1)]);
|
auto& shortcut = std::get<Shortcut>(remapBuffer[rowIndex].first[std::abs(colIndex - 1)]);
|
||||||
if (shortcut == std::get<Shortcut>(tempShortcut) && EditorHelpers::IsValidShortcut(shortcut) && EditorHelpers::IsValidShortcut(std::get<Shortcut>(tempShortcut)))
|
if (shortcut == std::get<Shortcut>(tempShortcut) && EditorHelpers::IsValidShortcut(shortcut) && EditorHelpers::IsValidShortcut(std::get<Shortcut>(tempShortcut)))
|
||||||
{
|
{
|
||||||
errorType = ShortcutErrorType::MapToSameShortcut;
|
errorType = ShortcutErrorType::MapToSameShortcut;
|
||||||
@ -258,9 +258,9 @@ namespace BufferValidationHelpers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If key to key
|
// If key to key
|
||||||
if (remapBuffer[rowIndex].first[std::abs(int(colIndex) - 1)].index() == 0)
|
if (remapBuffer[rowIndex].first[std::abs(colIndex - 1)].index() == 0)
|
||||||
{
|
{
|
||||||
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].first[std::abs(int(colIndex) - 1)]);
|
DWORD otherColumnKeyCode = std::get<DWORD>(remapBuffer[rowIndex].first[std::abs(colIndex - 1)]);
|
||||||
DWORD shortcutKeyCode = std::get<DWORD>(tempShortcut);
|
DWORD shortcutKeyCode = std::get<DWORD>(tempShortcut);
|
||||||
if ((otherColumnKeyCode == shortcutKeyCode || IsKeyRemappingToItsCombinedKey(otherColumnKeyCode, shortcutKeyCode)) && otherColumnKeyCode != NULL && shortcutKeyCode != NULL)
|
if ((otherColumnKeyCode == shortcutKeyCode || IsKeyRemappingToItsCombinedKey(otherColumnKeyCode, shortcutKeyCode)) && otherColumnKeyCode != NULL && shortcutKeyCode != NULL)
|
||||||
{
|
{
|
||||||
|
@ -137,14 +137,14 @@ inline void CreateEditKeyboardWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMan
|
|||||||
windowClass.lpfnWndProc = EditKeyboardWindowProc;
|
windowClass.lpfnWndProc = EditKeyboardWindowProc;
|
||||||
windowClass.hInstance = hInst;
|
windowClass.hInstance = hInst;
|
||||||
windowClass.lpszClassName = szWindowClass;
|
windowClass.lpszClassName = szWindowClass;
|
||||||
windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
|
windowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW);
|
||||||
windowClass.hIcon = (HICON)LoadImageW(
|
windowClass.hIcon = static_cast<HICON>(LoadImageW(
|
||||||
windowClass.hInstance,
|
windowClass.hInstance,
|
||||||
MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON),
|
MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
48,
|
48,
|
||||||
48,
|
48,
|
||||||
LR_DEFAULTCOLOR);
|
LR_DEFAULTCOLOR));
|
||||||
|
|
||||||
if (RegisterClassEx(&windowClass) == NULL)
|
if (RegisterClassEx(&windowClass) == NULL)
|
||||||
{
|
{
|
||||||
@ -433,7 +433,7 @@ LRESULT CALLBACK EditKeyboardWindowProc(HWND hWnd, UINT messageCode, WPARAM wPar
|
|||||||
// To avoid UI elements overlapping on making the window smaller enforce a minimum window size
|
// To avoid UI elements overlapping on making the window smaller enforce a minimum window size
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
{
|
{
|
||||||
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
|
LPMINMAXINFO mmi = reinterpret_cast<LPMINMAXINFO>(lParam);
|
||||||
float minWidth = EditorConstants::MinimumEditKeyboardWindowWidth;
|
float minWidth = EditorConstants::MinimumEditKeyboardWindowWidth;
|
||||||
float minHeight = EditorConstants::MinimumEditKeyboardWindowHeight;
|
float minHeight = EditorConstants::MinimumEditKeyboardWindowHeight;
|
||||||
DPIAware::Convert(MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL), minWidth, minHeight);
|
DPIAware::Convert(MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL), minWidth, minHeight);
|
||||||
|
@ -75,14 +75,14 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
|
|||||||
windowClass.lpfnWndProc = EditShortcutsWindowProc;
|
windowClass.lpfnWndProc = EditShortcutsWindowProc;
|
||||||
windowClass.hInstance = hInst;
|
windowClass.hInstance = hInst;
|
||||||
windowClass.lpszClassName = szWindowClass;
|
windowClass.lpszClassName = szWindowClass;
|
||||||
windowClass.hbrBackground = (HBRUSH)(COLOR_WINDOW);
|
windowClass.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW);
|
||||||
windowClass.hIcon = (HICON)LoadImageW(
|
windowClass.hIcon = static_cast<HICON>(LoadImageW(
|
||||||
windowClass.hInstance,
|
windowClass.hInstance,
|
||||||
MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON),
|
MAKEINTRESOURCE(IDS_KEYBOARDMANAGER_ICON),
|
||||||
IMAGE_ICON,
|
IMAGE_ICON,
|
||||||
48,
|
48,
|
||||||
48,
|
48,
|
||||||
LR_DEFAULTCOLOR);
|
LR_DEFAULTCOLOR));
|
||||||
if (RegisterClassEx(&windowClass) == NULL)
|
if (RegisterClassEx(&windowClass) == NULL)
|
||||||
{
|
{
|
||||||
MessageBox(NULL, GET_RESOURCE_STRING(IDS_REGISTERCLASSFAILED_ERRORMESSAGE).c_str(), GET_RESOURCE_STRING(IDS_REGISTERCLASSFAILED_ERRORTITLE).c_str(), NULL);
|
MessageBox(NULL, GET_RESOURCE_STRING(IDS_REGISTERCLASSFAILED_ERRORMESSAGE).c_str(), GET_RESOURCE_STRING(IDS_REGISTERCLASSFAILED_ERRORTITLE).c_str(), NULL);
|
||||||
@ -199,7 +199,7 @@ inline void CreateEditShortcutsWindowImpl(HINSTANCE hInst, KBMEditor::KeyboardMa
|
|||||||
StackPanel tableHeader = StackPanel();
|
StackPanel tableHeader = StackPanel();
|
||||||
tableHeader.Orientation(Orientation::Horizontal);
|
tableHeader.Orientation(Orientation::Horizontal);
|
||||||
tableHeader.Margin({ 10, 0, 0, 10 });
|
tableHeader.Margin({ 10, 0, 0, 10 });
|
||||||
auto originalShortcutContainer = UIHelpers::GetWrapped(originalShortcutHeader, EditorConstants::ShortcutOriginColumnWidth + (double)EditorConstants::ShortcutArrowColumnWidth);
|
auto originalShortcutContainer = UIHelpers::GetWrapped(originalShortcutHeader, EditorConstants::ShortcutOriginColumnWidth + static_cast<double>(EditorConstants::ShortcutArrowColumnWidth));
|
||||||
tableHeader.Children().Append(originalShortcutContainer.as<FrameworkElement>());
|
tableHeader.Children().Append(originalShortcutContainer.as<FrameworkElement>());
|
||||||
auto newShortcutHeaderContainer = UIHelpers::GetWrapped(newShortcutHeader, EditorConstants::ShortcutTargetColumnWidth);
|
auto newShortcutHeaderContainer = UIHelpers::GetWrapped(newShortcutHeader, EditorConstants::ShortcutTargetColumnWidth);
|
||||||
tableHeader.Children().Append(newShortcutHeaderContainer.as<FrameworkElement>());
|
tableHeader.Children().Append(newShortcutHeaderContainer.as<FrameworkElement>());
|
||||||
@ -386,7 +386,7 @@ LRESULT CALLBACK EditShortcutsWindowProc(HWND hWnd, UINT messageCode, WPARAM wPa
|
|||||||
// To avoid UI elements overlapping on making the window smaller enforce a minimum window size
|
// To avoid UI elements overlapping on making the window smaller enforce a minimum window size
|
||||||
case WM_GETMINMAXINFO:
|
case WM_GETMINMAXINFO:
|
||||||
{
|
{
|
||||||
LPMINMAXINFO mmi = (LPMINMAXINFO)lParam;
|
LPMINMAXINFO mmi = reinterpret_cast<LPMINMAXINFO>(lParam);
|
||||||
float minWidth = EditorConstants::MinimumEditShortcutsWindowWidth;
|
float minWidth = EditorConstants::MinimumEditShortcutsWindowWidth;
|
||||||
float minHeight = EditorConstants::MinimumEditShortcutsWindowHeight;
|
float minHeight = EditorConstants::MinimumEditShortcutsWindowHeight;
|
||||||
DPIAware::Convert(MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL), minWidth, minHeight);
|
DPIAware::Convert(MonitorFromWindow(hWnd, MONITOR_DEFAULTTONULL), minWidth, minHeight);
|
||||||
|
@ -326,7 +326,7 @@ void KeyDropDownControl::AddDropDown(StackPanel& table, StackPanel row, Variable
|
|||||||
keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->SetSelectionHandler(table, row, parent, colIndex, shortcutRemapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow);
|
keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->SetSelectionHandler(table, row, parent, colIndex, shortcutRemapBuffer, keyDropDownControlObjects, targetApp, isHybridControl, isSingleKeyWindow);
|
||||||
|
|
||||||
// Update accessible name
|
// Update accessible name
|
||||||
SetAccessibleNameForComboBox(keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->GetComboBox(), (int)keyDropDownControlObjects.size());
|
SetAccessibleNameForComboBox(keyDropDownControlObjects[keyDropDownControlObjects.size() - 1]->GetComboBox(), static_cast<int>(keyDropDownControlObjects.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to get the list of key codes from the shortcut combo box stack panel
|
// Function to get the list of key codes from the shortcut combo box stack panel
|
||||||
|
@ -254,7 +254,7 @@ void ShortcutControl::AddNewShortcutControlRow(StackPanel& parent, std::vector<s
|
|||||||
row.Children().Append(deleteShortcutContainer);
|
row.Children().Append(deleteShortcutContainer);
|
||||||
|
|
||||||
// Set accessible names
|
// Set accessible names
|
||||||
UpdateAccessibleNames(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->GetShortcutControl(), keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->GetShortcutControl(), targetAppTextBox, deleteShortcut, (int)keyboardRemapControlObjects.size());
|
UpdateAccessibleNames(keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][0]->GetShortcutControl(), keyboardRemapControlObjects[keyboardRemapControlObjects.size() - 1][1]->GetShortcutControl(), targetAppTextBox, deleteShortcut, static_cast<int>(keyboardRemapControlObjects.size()));
|
||||||
|
|
||||||
// Set the shortcut text if the two vectors are not empty (i.e. default args)
|
// Set the shortcut text if the two vectors are not empty (i.e. default args)
|
||||||
if (EditorHelpers::IsValidShortcut(originalKeys) && !(newKeys.index() == 0 && std::get<DWORD>(newKeys) == NULL) && !(newKeys.index() == 1 && !EditorHelpers::IsValidShortcut(std::get<Shortcut>(newKeys))))
|
if (EditorHelpers::IsValidShortcut(originalKeys) && !(newKeys.index() == 0 && std::get<DWORD>(newKeys) == NULL) && !(newKeys.index() == 1 && !EditorHelpers::IsValidShortcut(std::get<Shortcut>(newKeys))))
|
||||||
|
@ -206,7 +206,7 @@ void SingleKeyRemapControl::AddNewControlKeyRemapRow(StackPanel& parent, std::ve
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set accessible names
|
// Set accessible names
|
||||||
UpdateAccessibleNames(keyboardRemapControlObjects.back()[0]->getSingleKeyRemapControl(), keyboardRemapControlObjects.back()[1]->getSingleKeyRemapControl(), deleteRemapKeys, (int)keyboardRemapControlObjects.size());
|
UpdateAccessibleNames(keyboardRemapControlObjects.back()[0]->getSingleKeyRemapControl(), keyboardRemapControlObjects.back()[1]->getSingleKeyRemapControl(), deleteRemapKeys, static_cast<int>(keyboardRemapControlObjects.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to return the stack panel element of the SingleKeyRemapControl. This is the externally visible UI element which can be used to add it to other layouts
|
// Function to return the stack panel element of the SingleKeyRemapControl. This is the externally visible UI element which can be used to add it to other layouts
|
||||||
|
@ -141,7 +141,7 @@ bool XamlBridge::NavigateFocus(MSG* msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Function to run the message loop for the xaml island window
|
// Function to run the message loop for the xaml island window
|
||||||
int XamlBridge::MessageLoop()
|
WPARAM XamlBridge::MessageLoop()
|
||||||
{
|
{
|
||||||
MSG msg = {};
|
MSG msg = {};
|
||||||
HRESULT hr = S_OK;
|
HRESULT hr = S_OK;
|
||||||
@ -160,10 +160,10 @@ int XamlBridge::MessageLoop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Logger::trace("XamlBridge::MessageLoop() stopped");
|
Logger::trace("XamlBridge::MessageLoop() stopped");
|
||||||
return (int)msg.wParam;
|
return msg.wParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const WPARAM invalidKey = (WPARAM)-1;
|
static const WPARAM invalidKey = 0xFFFFFFFFFFFFFFFF;
|
||||||
|
|
||||||
constexpr WPARAM GetKeyFromReason(winrt::Windows::UI::Xaml::Hosting::XamlSourceFocusNavigationReason reason)
|
constexpr WPARAM GetKeyFromReason(winrt::Windows::UI::Xaml::Hosting::XamlSourceFocusNavigationReason reason)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ class XamlBridge
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// Function to run the message loop for the xaml island window
|
// Function to run the message loop for the xaml island window
|
||||||
int MessageLoop();
|
WPARAM MessageLoop();
|
||||||
|
|
||||||
// Constructor
|
// Constructor
|
||||||
XamlBridge(HWND parent) :
|
XamlBridge(HWND parent) :
|
||||||
|
@ -66,11 +66,11 @@ namespace KeyboardEventHandlers
|
|||||||
{
|
{
|
||||||
if (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP)
|
if (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, (WORD)target, KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, static_cast<WORD>(target), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, (WORD)target, 0, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, static_cast<WORD>(target), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -79,7 +79,7 @@ namespace KeyboardEventHandlers
|
|||||||
Shortcut targetShortcut = std::get<Shortcut>(it->second);
|
Shortcut targetShortcut = std::get<Shortcut>(it->second);
|
||||||
if (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP)
|
if (data->wParam == WM_KEYUP || data->wParam == WM_SYSKEYUP)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)targetShortcut.GetActionKey(), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(targetShortcut.GetActionKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
||||||
i++;
|
i++;
|
||||||
Helpers::SetModifierKeyEvents(targetShortcut, ModifierKey::Disabled, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
Helpers::SetModifierKeyEvents(targetShortcut, ModifierKey::Disabled, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
||||||
// Dummy key is not required here since SetModifierKeyEvents will only add key-up events for the modifiers here, and the action key key-up is already sent before it
|
// Dummy key is not required here since SetModifierKeyEvents will only add key-up events for the modifiers here, and the action key key-up is already sent before it
|
||||||
@ -88,7 +88,7 @@ namespace KeyboardEventHandlers
|
|||||||
{
|
{
|
||||||
// Dummy key is not required here since SetModifierKeyEvents will only add key-down events for the modifiers here, and the action key key-down is already sent after it
|
// Dummy key is not required here since SetModifierKeyEvents will only add key-down events for the modifiers here, and the action key key-down is already sent after it
|
||||||
Helpers::SetModifierKeyEvents(targetShortcut, ModifierKey::Disabled, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
Helpers::SetModifierKeyEvents(targetShortcut, ModifierKey::Disabled, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)targetShortcut.GetActionKey(), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(targetShortcut.GetActionKey()), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SINGLEKEY_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,13 +236,13 @@ namespace KeyboardEventHandlers
|
|||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first);
|
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first);
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)std::get<Shortcut>(it->second.targetShortcut).GetActionKey(), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(std::get<Shortcut>(it->second.targetShortcut).GetActionKey()), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Dummy key, key up for all the original shortcut modifier keys and key down for all the new shortcut keys but common keys in each are not repeated
|
// Dummy key, key up for all the original shortcut modifier keys and key down for all the new shortcut keys but common keys in each are not repeated
|
||||||
key_count = KeyboardManagerConstants::DUMMY_KEY_EVENT_SIZE + (src_size - 1) + (dest_size) - (2 * (size_t)commonKeys);
|
key_count = KeyboardManagerConstants::DUMMY_KEY_EVENT_SIZE + (src_size - 1) + (dest_size) - (2 * static_cast<size_t>(commonKeys));
|
||||||
keyEventList = new INPUT[key_count]();
|
keyEventList = new INPUT[key_count]();
|
||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
|
|
||||||
@ -255,7 +255,7 @@ namespace KeyboardEventHandlers
|
|||||||
|
|
||||||
// Set new shortcut key down state
|
// Set new shortcut key down state
|
||||||
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first);
|
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first);
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)std::get<Shortcut>(it->second.targetShortcut).GetActionKey(), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(std::get<Shortcut>(it->second.targetShortcut).GetActionKey()), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -295,14 +295,14 @@ namespace KeyboardEventHandlers
|
|||||||
// Set target key down state
|
// Set target key down state
|
||||||
if (std::get<DWORD>(it->second.targetShortcut) != CommonSharedConstants::VK_DISABLED)
|
if (std::get<DWORD>(it->second.targetShortcut) != CommonSharedConstants::VK_DISABLED)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut)), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut))), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Modifier state reset might be required for this key depending on the shortcut's action and target modifier - ex: Win+Caps -> Ctrl
|
// Modifier state reset might be required for this key depending on the shortcut's action and target modifier - ex: Win+Caps -> Ctrl
|
||||||
if (it->first.GetCtrlKey() == NULL && it->first.GetAltKey() == NULL && it->first.GetShiftKey() == NULL)
|
if (it->first.GetCtrlKey() == NULL && it->first.GetAltKey() == NULL && it->first.GetShiftKey() == NULL)
|
||||||
{
|
{
|
||||||
ResetIfModifierKeyForLowerLevelKeyHandlers(ii, (WORD)Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut)), data->lParam->vkCode);
|
ResetIfModifierKeyForLowerLevelKeyHandlers(ii,static_cast<WORD>(Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut))), data->lParam->vkCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,7 +313,7 @@ namespace KeyboardEventHandlers
|
|||||||
state.SetActivatedApp(*activatedApp);
|
state.SetActivatedApp(*activatedApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@ -350,7 +350,7 @@ namespace KeyboardEventHandlers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// release all new shortcut keys except the common modifiers and add all original shortcut modifiers except the common ones, and dummy key
|
// release all new shortcut keys except the common modifiers and add all original shortcut modifiers except the common ones, and dummy key
|
||||||
key_count = (dest_size - 1) + (src_size - 2) - (2 * (size_t)commonKeys) + KeyboardManagerConstants::DUMMY_KEY_EVENT_SIZE;
|
key_count = (dest_size - 1) + (src_size - 2) - (2 * static_cast<size_t>(commonKeys)) + KeyboardManagerConstants::DUMMY_KEY_EVENT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the target shortcut's action key is pressed, then it should be released
|
// If the target shortcut's action key is pressed, then it should be released
|
||||||
@ -368,7 +368,7 @@ namespace KeyboardEventHandlers
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
if (isActionKeyPressed)
|
if (isActionKeyPressed)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)std::get<Shortcut>(it->second.targetShortcut).GetActionKey(), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(std::get<Shortcut>(it->second.targetShortcut).GetActionKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first, data->lParam->vkCode);
|
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first, data->lParam->vkCode);
|
||||||
@ -407,7 +407,7 @@ namespace KeyboardEventHandlers
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
if (std::get<DWORD>(it->second.targetShortcut) != CommonSharedConstants::VK_DISABLED && isTargetKeyPressed)
|
if (std::get<DWORD>(it->second.targetShortcut) != CommonSharedConstants::VK_DISABLED && isTargetKeyPressed)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut)), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut))), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ namespace KeyboardEventHandlers
|
|||||||
// key count can be 0 if both shortcuts have same modifiers and the action key is not held down. delete will throw an error if keyEventList is empty
|
// key count can be 0 if both shortcuts have same modifiers and the action key is not held down. delete will throw an error if keyEventList is empty
|
||||||
if (key_count > 0)
|
if (key_count > 0)
|
||||||
{
|
{
|
||||||
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
@ -457,14 +457,14 @@ namespace KeyboardEventHandlers
|
|||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
if (remapToShortcut)
|
if (remapToShortcut)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, (WORD)std::get<Shortcut>(it->second.targetShortcut).GetActionKey(), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, static_cast<WORD>(std::get<Shortcut>(it->second.targetShortcut).GetActionKey()), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, (WORD)Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut)), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, static_cast<WORD>(Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut))), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -478,7 +478,7 @@ namespace KeyboardEventHandlers
|
|||||||
{
|
{
|
||||||
keyEventList = new INPUT[key_count]();
|
keyEventList = new INPUT[key_count]();
|
||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, (WORD)std::get<Shortcut>(it->second.targetShortcut).GetActionKey(), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, static_cast<WORD>(std::get<Shortcut>(it->second.targetShortcut).GetActionKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
}
|
}
|
||||||
else if (std::get<DWORD>(it->second.targetShortcut) == CommonSharedConstants::VK_DISABLED)
|
else if (std::get<DWORD>(it->second.targetShortcut) == CommonSharedConstants::VK_DISABLED)
|
||||||
{
|
{
|
||||||
@ -497,7 +497,7 @@ namespace KeyboardEventHandlers
|
|||||||
{
|
{
|
||||||
keyEventList = new INPUT[key_count]();
|
keyEventList = new INPUT[key_count]();
|
||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, (WORD)Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut)), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD,static_cast<WORD>(Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut))), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -512,7 +512,7 @@ namespace KeyboardEventHandlers
|
|||||||
|
|
||||||
// Release new key state
|
// Release new key state
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut)), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(Helpers::FilterArtificialKeys(std::get<DWORD>(it->second.targetShortcut))), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// Set original shortcut key down state except the action key
|
// Set original shortcut key down state except the action key
|
||||||
@ -534,7 +534,7 @@ namespace KeyboardEventHandlers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -586,23 +586,23 @@ namespace KeyboardEventHandlers
|
|||||||
if (newRemapping.RemapToKey())
|
if (newRemapping.RemapToKey())
|
||||||
{
|
{
|
||||||
DWORD to = std::get<0>(newRemapping.targetShortcut);
|
DWORD to = std::get<0>(newRemapping.targetShortcut);
|
||||||
bool isLastKeyStillPressed = ii.GetVirtualKeyState((WORD)from.actionKey);
|
bool isLastKeyStillPressed = ii.GetVirtualKeyState(static_cast<WORD>(from.actionKey));
|
||||||
key_count = static_cast<size_t>(from.Size()) - 1 + 1 + (isLastKeyStillPressed ? 1 : 0);
|
key_count = static_cast<size_t>(from.Size()) - 1 + 1 + (isLastKeyStillPressed ? 1 : 0);
|
||||||
keyEventList = new INPUT[key_count]();
|
keyEventList = new INPUT[key_count]();
|
||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Helpers::SetModifierKeyEvents(from, it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetModifierKeyEvents(from, it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
if (ii.GetVirtualKeyState((WORD)from.actionKey))
|
if (ii.GetVirtualKeyState(static_cast<WORD>(from.actionKey)))
|
||||||
{
|
{
|
||||||
// If the action key from the last shortcut is still being pressed, release it.
|
// If the action key from the last shortcut is still being pressed, release it.
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)from.actionKey, KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(from.actionKey), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)to, 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(to), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
}else
|
}else
|
||||||
{
|
{
|
||||||
Shortcut to = std::get<Shortcut>(newRemapping.targetShortcut);
|
Shortcut to = std::get<Shortcut>(newRemapping.targetShortcut);
|
||||||
bool isLastKeyStillPressed = ii.GetVirtualKeyState((WORD)from.actionKey);
|
bool isLastKeyStillPressed = ii.GetVirtualKeyState(static_cast<WORD>(from.actionKey));
|
||||||
|
|
||||||
size_t temp_key_count_calculation = static_cast<size_t>(from.Size()) - 1;
|
size_t temp_key_count_calculation = static_cast<size_t>(from.Size()) - 1;
|
||||||
temp_key_count_calculation += static_cast<size_t>(to.Size()) - 1;
|
temp_key_count_calculation += static_cast<size_t>(to.Size()) - 1;
|
||||||
@ -612,14 +612,14 @@ namespace KeyboardEventHandlers
|
|||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Helpers::SetModifierKeyEvents(from, it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, to);
|
Helpers::SetModifierKeyEvents(from, it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, to);
|
||||||
if (ii.GetVirtualKeyState((WORD)from.actionKey))
|
if (ii.GetVirtualKeyState(static_cast<WORD>(from.actionKey)))
|
||||||
{
|
{
|
||||||
// If the action key from the last shortcut is still being pressed, release it.
|
// If the action key from the last shortcut is still being pressed, release it.
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)from.actionKey, KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(from.actionKey), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Helpers::SetModifierKeyEvents(to, it->second.winKeyInvoked, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, from);
|
Helpers::SetModifierKeyEvents(to, it->second.winKeyInvoked, keyEventList, i, true, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, from);
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)to.actionKey, 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(to.actionKey), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
newRemapping.isShortcutInvoked = true;
|
newRemapping.isShortcutInvoked = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -636,7 +636,7 @@ namespace KeyboardEventHandlers
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Key up for all new shortcut keys, key down for original shortcut modifiers and current key press but common keys aren't repeated
|
// Key up for all new shortcut keys, key down for original shortcut modifiers and current key press but common keys aren't repeated
|
||||||
key_count = (dest_size) + (src_size - 1) - (2 * (size_t)commonKeys);
|
key_count = (dest_size) + (src_size - 1) - (2 * static_cast<size_t>(commonKeys));
|
||||||
|
|
||||||
// If the target shortcut's action key is pressed, then it should be released and original shortcut's action key should be set
|
// If the target shortcut's action key is pressed, then it should be released and original shortcut's action key should be set
|
||||||
bool isActionKeyPressed = false;
|
bool isActionKeyPressed = false;
|
||||||
@ -653,7 +653,7 @@ namespace KeyboardEventHandlers
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
if (isActionKeyPressed)
|
if (isActionKeyPressed)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)std::get<Shortcut>(it->second.targetShortcut).GetActionKey(), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(std::get<Shortcut>(it->second.targetShortcut).GetActionKey()), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first);
|
Helpers::SetModifierKeyEvents(std::get<Shortcut>(it->second.targetShortcut), it->second.winKeyInvoked, keyEventList, i, false, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG, it->first);
|
||||||
@ -664,12 +664,12 @@ namespace KeyboardEventHandlers
|
|||||||
// key down for original shortcut action key with shortcut flag so that we don't invoke the same shortcut remap again
|
// key down for original shortcut action key with shortcut flag so that we don't invoke the same shortcut remap again
|
||||||
if (isActionKeyPressed)
|
if (isActionKeyPressed)
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)it->first.GetActionKey(), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(it->first.GetActionKey()), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send current key pressed without shortcut flag so that it can be reprocessed in case the physical keys pressed are a different remapped shortcut
|
// Send current key pressed without shortcut flag so that it can be reprocessed in case the physical keys pressed are a different remapped shortcut
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)data->lParam->vkCode, 0, 0);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(data->lParam->vkCode), 0, 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// Do not send a dummy key as we want the current key press to behave as normal i.e. it can do press+release functionality if required. Required to allow a shortcut to Win key remap invoked directly after shortcut to shortcut is released to open start menu
|
// Do not send a dummy key as we want the current key press to behave as normal i.e. it can do press+release functionality if required. Required to allow a shortcut to Win key remap invoked directly after shortcut to shortcut is released to open start menu
|
||||||
@ -686,7 +686,7 @@ namespace KeyboardEventHandlers
|
|||||||
state.SetActivatedApp(KeyboardManagerConstants::NoActivatedApp);
|
state.SetActivatedApp(KeyboardManagerConstants::NoActivatedApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -730,7 +730,7 @@ namespace KeyboardEventHandlers
|
|||||||
if (isRemapToDisable && isOriginalActionKeyPressed)
|
if (isRemapToDisable && isOriginalActionKeyPressed)
|
||||||
{
|
{
|
||||||
// Set original action key
|
// Set original action key
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)it->first.GetActionKey(), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD,static_cast<WORD>(it->first.GetActionKey()), 0, KeyboardManagerConstants::KEYBOARDMANAGER_SHORTCUT_FLAG);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -739,7 +739,7 @@ namespace KeyboardEventHandlers
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send current key pressed without shortcut flag so that it can be reprocessed in case the physical keys pressed are a different remapped shortcut
|
// Send current key pressed without shortcut flag so that it can be reprocessed in case the physical keys pressed are a different remapped shortcut
|
||||||
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, (WORD)data->lParam->vkCode, 0, 0);
|
Helpers::SetKeyEvent(keyEventList, i, INPUT_KEYBOARD, static_cast<WORD>(data->lParam->vkCode), 0, 0);
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
// Do not send a dummy key as we want the current key press to behave as normal i.e. it can do press+release functionality if required. Required to allow a shortcut to Win key remap invoked directly after another shortcut to key remap is released to open start menu
|
// Do not send a dummy key as we want the current key press to behave as normal i.e. it can do press+release functionality if required. Required to allow a shortcut to Win key remap invoked directly after another shortcut to key remap is released to open start menu
|
||||||
@ -755,7 +755,7 @@ namespace KeyboardEventHandlers
|
|||||||
state.SetActivatedApp(KeyboardManagerConstants::NoActivatedApp);
|
state.SetActivatedApp(KeyboardManagerConstants::NoActivatedApp);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -858,8 +858,8 @@ namespace KeyboardEventHandlers
|
|||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
|
|
||||||
// Use the suppress flag to ensure these are not intercepted by any remapped keys or shortcuts
|
// Use the suppress flag to ensure these are not intercepted by any remapped keys or shortcuts
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, (WORD)key, KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SUPPRESS_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, static_cast<WORD>(key), KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SUPPRESS_FLAG);
|
||||||
UINT res = ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
UINT res = ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace RemappingLogicTests
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (intptr_t)1;
|
return 1LL;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -103,15 +103,15 @@ namespace Helpers
|
|||||||
|
|
||||||
// Set wScan to the value from MapVirtualKey as some applications may use the scan code for handling input, for instance, Windows Terminal ignores non-character input which has scancode set to 0.
|
// Set wScan to the value from MapVirtualKey as some applications may use the scan code for handling input, for instance, Windows Terminal ignores non-character input which has scancode set to 0.
|
||||||
// MapVirtualKey returns 0 if the key code does not correspond to a physical key (such as unassigned/reserved keys). More details at https://github.com/microsoft/PowerToys/pull/7143#issue-498877747
|
// MapVirtualKey returns 0 if the key code does not correspond to a physical key (such as unassigned/reserved keys). More details at https://github.com/microsoft/PowerToys/pull/7143#issue-498877747
|
||||||
keyEventArray[index].ki.wScan = (WORD)MapVirtualKey(keyCode, MAPVK_VK_TO_VSC);
|
keyEventArray[index].ki.wScan = static_cast<WORD>(MapVirtualKey(keyCode, MAPVK_VK_TO_VSC));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function to set the dummy key events used for remapping shortcuts, required to ensure releasing a modifier doesn't trigger another action (For example, Win->Start Menu or Alt->Menu bar)
|
// Function to set the dummy key events used for remapping shortcuts, required to ensure releasing a modifier doesn't trigger another action (For example, Win->Start Menu or Alt->Menu bar)
|
||||||
void SetDummyKeyEvent(LPINPUT keyEventArray, int& index, ULONG_PTR extraInfo)
|
void SetDummyKeyEvent(LPINPUT keyEventArray, int& index, ULONG_PTR extraInfo)
|
||||||
{
|
{
|
||||||
SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)KeyboardManagerConstants::DUMMY_KEY, 0, extraInfo);
|
SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(KeyboardManagerConstants::DUMMY_KEY), 0, extraInfo);
|
||||||
index++;
|
index++;
|
||||||
SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)KeyboardManagerConstants::DUMMY_KEY, KEYEVENTF_KEYUP, extraInfo);
|
SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(KeyboardManagerConstants::DUMMY_KEY), KEYEVENTF_KEYUP, extraInfo);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,22 +184,22 @@ namespace Helpers
|
|||||||
// If shortcutToCompare is non-empty, then the key event is sent only if both shortcut's don't have the same modifier key. If keyToBeReleased is non-NULL, then the key event is sent if either the shortcuts don't have the same modifier or if the shortcutToBeSent's modifier matches the keyToBeReleased
|
// If shortcutToCompare is non-empty, then the key event is sent only if both shortcut's don't have the same modifier key. If keyToBeReleased is non-NULL, then the key event is sent if either the shortcuts don't have the same modifier or if the shortcutToBeSent's modifier matches the keyToBeReleased
|
||||||
if (shortcutToBeSent.GetWinKey(winKeyInvoked) != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetWinKey(winKeyInvoked) != shortcutToCompare.GetWinKey(winKeyInvoked)) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckWinKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetWinKey(winKeyInvoked) != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetWinKey(winKeyInvoked) != shortcutToCompare.GetWinKey(winKeyInvoked)) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckWinKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetWinKey(winKeyInvoked), 0, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetWinKey(winKeyInvoked)), 0, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (shortcutToBeSent.GetCtrlKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetCtrlKey() != shortcutToCompare.GetCtrlKey()) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckCtrlKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetCtrlKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetCtrlKey() != shortcutToCompare.GetCtrlKey()) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckCtrlKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetCtrlKey(), 0, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetCtrlKey()), 0, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (shortcutToBeSent.GetAltKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetAltKey() != shortcutToCompare.GetAltKey()) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckAltKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetAltKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetAltKey() != shortcutToCompare.GetAltKey()) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckAltKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetAltKey(), 0, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetAltKey()), 0, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (shortcutToBeSent.GetShiftKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetShiftKey() != shortcutToCompare.GetShiftKey()) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckShiftKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetShiftKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetShiftKey() != shortcutToCompare.GetShiftKey()) && (keyToBeReleased == NULL || !shortcutToBeSent.CheckShiftKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetShiftKey(), 0, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetShiftKey()), 0, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -210,22 +210,22 @@ namespace Helpers
|
|||||||
// If shortcutToCompare is non-empty, then the key event is sent only if both shortcut's don't have the same modifier key. If keyToBeReleased is non-NULL, then the key event is sent if either the shortcuts don't have the same modifier or if the shortcutToBeSent's modifier matches the keyToBeReleased
|
// If shortcutToCompare is non-empty, then the key event is sent only if both shortcut's don't have the same modifier key. If keyToBeReleased is non-NULL, then the key event is sent if either the shortcuts don't have the same modifier or if the shortcutToBeSent's modifier matches the keyToBeReleased
|
||||||
if (shortcutToBeSent.GetShiftKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetShiftKey() != shortcutToCompare.GetShiftKey() || shortcutToBeSent.CheckShiftKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetShiftKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetShiftKey() != shortcutToCompare.GetShiftKey() || shortcutToBeSent.CheckShiftKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetShiftKey(), KEYEVENTF_KEYUP, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetShiftKey()), KEYEVENTF_KEYUP, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (shortcutToBeSent.GetAltKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetAltKey() != shortcutToCompare.GetAltKey() || shortcutToBeSent.CheckAltKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetAltKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetAltKey() != shortcutToCompare.GetAltKey() || shortcutToBeSent.CheckAltKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetAltKey(), KEYEVENTF_KEYUP, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetAltKey()), KEYEVENTF_KEYUP, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (shortcutToBeSent.GetCtrlKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetCtrlKey() != shortcutToCompare.GetCtrlKey() || shortcutToBeSent.CheckCtrlKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetCtrlKey() != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetCtrlKey() != shortcutToCompare.GetCtrlKey() || shortcutToBeSent.CheckCtrlKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetCtrlKey(), KEYEVENTF_KEYUP, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetCtrlKey()), KEYEVENTF_KEYUP, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
if (shortcutToBeSent.GetWinKey(winKeyInvoked) != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetWinKey(winKeyInvoked) != shortcutToCompare.GetWinKey(winKeyInvoked) || shortcutToBeSent.CheckWinKey(keyToBeReleased)))
|
if (shortcutToBeSent.GetWinKey(winKeyInvoked) != NULL && (shortcutToCompare.IsEmpty() || shortcutToBeSent.GetWinKey(winKeyInvoked) != shortcutToCompare.GetWinKey(winKeyInvoked) || shortcutToBeSent.CheckWinKey(keyToBeReleased)))
|
||||||
{
|
{
|
||||||
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, (WORD)shortcutToBeSent.GetWinKey(winKeyInvoked), KEYEVENTF_KEYUP, extraInfoFlag);
|
Helpers::SetKeyEvent(keyEventArray, index, INPUT_KEYBOARD, static_cast<WORD>(shortcutToBeSent.GetWinKey(winKeyInvoked)), KEYEVENTF_KEYUP, extraInfoFlag);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace KeyboardEventHandlers
|
|||||||
// Use the suppress flag to ensure these are not intercepted by any remapped keys or shortcuts
|
// Use the suppress flag to ensure these are not intercepted by any remapped keys or shortcuts
|
||||||
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, VK_NUMLOCK, KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SUPPRESS_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 0, INPUT_KEYBOARD, VK_NUMLOCK, KEYEVENTF_KEYUP, KeyboardManagerConstants::KEYBOARDMANAGER_SUPPRESS_FLAG);
|
||||||
Helpers::SetKeyEvent(keyEventList, 1, INPUT_KEYBOARD, VK_NUMLOCK, 0, KeyboardManagerConstants::KEYBOARDMANAGER_SUPPRESS_FLAG);
|
Helpers::SetKeyEvent(keyEventList, 1, INPUT_KEYBOARD, VK_NUMLOCK, 0, KeyboardManagerConstants::KEYBOARDMANAGER_SUPPRESS_FLAG);
|
||||||
ii.SendVirtualInput((UINT)key_count, keyEventList, sizeof(INPUT));
|
ii.SendVirtualInput(static_cast<UINT>(key_count), keyEventList, sizeof(INPUT));
|
||||||
delete[] keyEventList;
|
delete[] keyEventList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +296,7 @@ bool MappingConfiguration::SaveSettingsToFile()
|
|||||||
for (const auto& it : singleKeyReMap)
|
for (const auto& it : singleKeyReMap)
|
||||||
{
|
{
|
||||||
json::JsonObject keys;
|
json::JsonObject keys;
|
||||||
keys.SetNamedValue(KeyboardManagerConstants::OriginalKeysSettingName, json::value(winrt::to_hstring((unsigned int)it.first)));
|
keys.SetNamedValue(KeyboardManagerConstants::OriginalKeysSettingName, json::value(winrt::to_hstring(static_cast<unsigned int>(it.first))));
|
||||||
|
|
||||||
// For key to key remapping
|
// For key to key remapping
|
||||||
if (it.second.index() == 0)
|
if (it.second.index() == 0)
|
||||||
|
@ -425,23 +425,23 @@ winrt::hstring Shortcut::ToHstringVK() const
|
|||||||
winrt::hstring output;
|
winrt::hstring output;
|
||||||
if (winKey != ModifierKey::Disabled)
|
if (winKey != ModifierKey::Disabled)
|
||||||
{
|
{
|
||||||
output = output + winrt::to_hstring((unsigned int)GetWinKey(ModifierKey::Both)) + winrt::to_hstring(L";");
|
output = output + winrt::to_hstring(static_cast<unsigned int>(GetWinKey(ModifierKey::Both))) + winrt::to_hstring(L";");
|
||||||
}
|
}
|
||||||
if (ctrlKey != ModifierKey::Disabled)
|
if (ctrlKey != ModifierKey::Disabled)
|
||||||
{
|
{
|
||||||
output = output + winrt::to_hstring((unsigned int)GetCtrlKey()) + winrt::to_hstring(L";");
|
output = output + winrt::to_hstring(static_cast<unsigned int>(GetCtrlKey())) + winrt::to_hstring(L";");
|
||||||
}
|
}
|
||||||
if (altKey != ModifierKey::Disabled)
|
if (altKey != ModifierKey::Disabled)
|
||||||
{
|
{
|
||||||
output = output + winrt::to_hstring((unsigned int)GetAltKey()) + winrt::to_hstring(L";");
|
output = output + winrt::to_hstring(static_cast<unsigned int>(GetAltKey())) + winrt::to_hstring(L";");
|
||||||
}
|
}
|
||||||
if (shiftKey != ModifierKey::Disabled)
|
if (shiftKey != ModifierKey::Disabled)
|
||||||
{
|
{
|
||||||
output = output + winrt::to_hstring((unsigned int)GetShiftKey()) + winrt::to_hstring(L";");
|
output = output + winrt::to_hstring(static_cast<unsigned int>(GetShiftKey())) + winrt::to_hstring(L";");
|
||||||
}
|
}
|
||||||
if (actionKey != NULL)
|
if (actionKey != NULL)
|
||||||
{
|
{
|
||||||
output = output + winrt::to_hstring((unsigned int)GetActionKey()) + winrt::to_hstring(L";");
|
output = output + winrt::to_hstring(static_cast<unsigned int>(GetActionKey())) + winrt::to_hstring(L";");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!output.empty())
|
if (!output.empty())
|
||||||
|
Loading…
Reference in New Issue
Block a user