Added option to set custom commands for controls

Includes a unique option for each control and supports environment
variables.
This commit is contained in:
thisismy-github
2021-08-14 21:19:32 -04:00
committed by Ibuprophen
parent be8568ce00
commit ef663d2051
4 changed files with 71 additions and 0 deletions

View File

@@ -4154,38 +4154,50 @@ CSetting g_Settings[]={
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP,0,CSetting::FLAG_HIDDEN},
{L"MouseClickCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"%userprofile%",0,L"MouseClick=3",L"Command"},
{L"ShiftClick",CSetting::TYPE_INT,IDS_SHIFT_LCLICK,IDS_SHIFT_LCLICK_TIP,2,CSetting::FLAG_BASIC},
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP,0,CSetting::FLAG_HIDDEN},
/* {L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP,0,CSetting::FLAG_HIDDEN},
{L"Cortana",CSetting::TYPE_RADIO,IDS_OPEN_CORTANA,IDS_OPEN_CORTANA_TIP},*/
{L"ShiftClickCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"%systemdrive%",0,L"ShiftClick=3",L"Command"},
{L"WinKey",CSetting::TYPE_INT,IDS_WIN_KEY,IDS_WIN_KEY_TIP,1,CSetting::FLAG_BASIC},
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP},
{L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP},
{L"WinKeyCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"cmd",0,L"WinKey=3",L"Command"},
{L"ShiftWin",CSetting::TYPE_INT,IDS_SHIFT_WIN,IDS_SHIFT_WIN_TIP,2,CSetting::FLAG_BASIC},
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP},
/* {L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP,0,CSetting::FLAG_HIDDEN},
{L"Cortana",CSetting::TYPE_RADIO,IDS_OPEN_CORTANA,IDS_OPEN_CORTANA_TIP},*/
{L"ShiftWinCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"powershell",0,L"ShiftWin=3",L"Command"},
{L"MiddleClick",CSetting::TYPE_INT,IDS_MCLICK,IDS_MCLICK_TIP,0},
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
/* {L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP,0,CSetting::FLAG_HIDDEN},
{L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP,0,CSetting::FLAG_HIDDEN},
{L"Cortana",CSetting::TYPE_RADIO,IDS_OPEN_CORTANA,IDS_OPEN_CORTANA_TIP},*/
{L"MiddleClickCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"taskmgr",0,L"MiddleClick=3",L"Command"},
{L"Hover",CSetting::TYPE_INT,IDS_HOVER,IDS_HOVER_TIP,0},
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
{L"HoverCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"",0,L"Hover=3",L"Command"},
{L"StartHoverDelay",CSetting::TYPE_INT,IDS_HOVER_DELAY,IDS_HOVER_DELAY_TIP,1000,0,L"Hover",L"Hover"},
{L"ShiftRight",CSetting::TYPE_BOOL,IDS_RIGHT_SHIFT,IDS_RIGHT_SHIFT_TIP,0},
{L"CSMHotkey",CSetting::TYPE_HOTKEY,IDS_CSM_HOTKEY,IDS_CSM_HOTKEY_TIP,0},

View File

@@ -79,6 +79,7 @@ enum
OPEN_NOTHING,
OPEN_CLASSIC,
OPEN_WINDOWS,
OPEN_CUSTOM,
OPEN_BOTH,
OPEN_DESKTOP,
OPEN_CORTANA,
@@ -3348,6 +3349,16 @@ static LRESULT CALLBACK HookProgManThread( int code, WPARAM wParam, LPARAM lPara
msg->message=WM_NULL;
if (control==OPEN_CLASSIC)
PostMessage(g_TaskBar,g_StartMenuMsg,MSG_TOGGLE,0);
else if (control==OPEN_CUSTOM)
{
CString commandText=GetSettingString(L"WinKeyCommand");
if (!commandText.IsEmpty())
{
wchar_t expandedCommand[_MAX_PATH]{};
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
}
}
}
}
}
@@ -3431,6 +3442,16 @@ if (!g_bTrimHooks)
PostMessage(g_ProgWin,WM_SYSCOMMAND,SC_TASKLIST,'WSMK');
else if (control==OPEN_CORTANA)
OpenCortana();
else if (control==OPEN_CUSTOM)
{
CString commandText=GetSettingString(L"ShiftWinCommand");
if (!commandText.IsEmpty())
{
wchar_t expandedCommand[_MAX_PATH]{};
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
}
}
}
else if (msg->wParam==MSG_DRAG || msg->wParam==MSG_SHIFTDRAG)
{
@@ -3590,12 +3611,22 @@ if (!g_bTrimHooks)
// left or middle click on start button
FindWindowsMenu();
const wchar_t *name;
const wchar_t *command;
if (bMiddle)
{
name=L"MiddleClick";
command=L"MiddleClickCommand";
}
else if (GetKeyState(VK_SHIFT)<0)
{
name=L"ShiftClick";
command=L"ShiftClickCommand";
}
else
{
name=L"MouseClick";
command=L"MouseClickCommand";
}
int control=GetSettingInt(name);
if (control==OPEN_BOTH && GetWinVersion()>=WIN_VER_WIN10)
@@ -3611,6 +3642,16 @@ if (!g_bTrimHooks)
PostMessage(g_ProgWin,WM_SYSCOMMAND,SC_TASKLIST,'WSMM');
else if (control==OPEN_CORTANA)
OpenCortana();
else if (control==OPEN_CUSTOM)
{
CString commandText=GetSettingString(command);
if (!commandText.IsEmpty())
{
wchar_t expandedCommand[_MAX_PATH]{};
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
}
}
msg->message=WM_NULL;
}
}
@@ -3751,6 +3792,16 @@ if (!g_bTrimHooks)
FindWindowsMenu();
PostMessage(g_ProgWin,WM_SYSCOMMAND,SC_TASKLIST,'WSMM');
}
else if (control==OPEN_CUSTOM)
{
CString commandText=GetSettingString(L"HoverCommand");
if (!commandText.IsEmpty())
{
wchar_t expandedCommand[_MAX_PATH]{};
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
}
}
}
}
taskBar->bTimer=false;

View File

@@ -1307,6 +1307,10 @@ BEGIN
IDS_NEW_SEARCH_HINT_TIP "The text to replace the search hint with. Empty text is a valid option"
IDS_MORE_RESULTS "Enable ""See more results"" option"
IDS_MORE_RESULTS_TIP "When this is checked, the search results will include an option to do a more advanced search"
IDS_OPEN_CMD "Custom command"
IDS_OPEN_CMD_TIP "The action will run a user-defined command"
IDS_OPEN_CMD_TEXT "Command to run"
IDS_OPEN_CMD_TEXT_TIP "Enter the command to run when you use this control"
END
#endif // English (U.S.) resources

View File

@@ -770,6 +770,10 @@
#define IDS_NEW_SEARCH_HINT_TIP 3673
#define IDS_MORE_RESULTS 3674
#define IDS_MORE_RESULTS_TIP 3675
#define IDS_OPEN_CMD 3676
#define IDS_OPEN_CMD_TIP 3677
#define IDS_OPEN_CMD_TEXT 3678
#define IDS_OPEN_CMD_TEXT_TIP 3679
#define IDS_STRING7001 7001
#define IDS_STRING7002 7002
#define IDS_STRING7003 7003