Skip to content

Commit ef663d2

Browse files
thisismy-githubIbuprophen
authored andcommitted
Added option to set custom commands for controls
Includes a unique option for each control and supports environment variables.
1 parent be8568c commit ef663d2

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed

Src/StartMenu/StartMenuDLL/SettingsUI.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4154,38 +4154,50 @@ CSetting g_Settings[]={
41544154
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
41554155
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
41564156
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
4157+
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
41574158
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP,0,CSetting::FLAG_HIDDEN},
4159+
{L"MouseClickCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"%userprofile%",0,L"MouseClick=3",L"Command"},
41584160
{L"ShiftClick",CSetting::TYPE_INT,IDS_SHIFT_LCLICK,IDS_SHIFT_LCLICK_TIP,2,CSetting::FLAG_BASIC},
41594161
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
41604162
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
41614163
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
4164+
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
41624165
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP,0,CSetting::FLAG_HIDDEN},
41634166
/* {L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP,0,CSetting::FLAG_HIDDEN},
41644167
{L"Cortana",CSetting::TYPE_RADIO,IDS_OPEN_CORTANA,IDS_OPEN_CORTANA_TIP},*/
4168+
{L"ShiftClickCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"%systemdrive%",0,L"ShiftClick=3",L"Command"},
41654169
{L"WinKey",CSetting::TYPE_INT,IDS_WIN_KEY,IDS_WIN_KEY_TIP,1,CSetting::FLAG_BASIC},
41664170
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
41674171
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
41684172
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
4173+
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
41694174
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP},
41704175
{L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP},
4176+
{L"WinKeyCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"cmd",0,L"WinKey=3",L"Command"},
41714177
{L"ShiftWin",CSetting::TYPE_INT,IDS_SHIFT_WIN,IDS_SHIFT_WIN_TIP,2,CSetting::FLAG_BASIC},
41724178
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
41734179
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
41744180
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
4181+
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
41754182
{L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP},
41764183
/* {L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP,0,CSetting::FLAG_HIDDEN},
41774184
{L"Cortana",CSetting::TYPE_RADIO,IDS_OPEN_CORTANA,IDS_OPEN_CORTANA_TIP},*/
4185+
{L"ShiftWinCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"powershell",0,L"ShiftWin=3",L"Command"},
41784186
{L"MiddleClick",CSetting::TYPE_INT,IDS_MCLICK,IDS_MCLICK_TIP,0},
41794187
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
41804188
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
41814189
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
4190+
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
41824191
/* {L"Both",CSetting::TYPE_RADIO,IDS_OPEN_BOTH,IDS_OPEN_BOTH_TIP,0,CSetting::FLAG_HIDDEN},
41834192
{L"Desktop",CSetting::TYPE_RADIO,IDS_OPEN_DESKTOP,IDS_OPEN_DESKTOP_TIP,0,CSetting::FLAG_HIDDEN},
41844193
{L"Cortana",CSetting::TYPE_RADIO,IDS_OPEN_CORTANA,IDS_OPEN_CORTANA_TIP},*/
4194+
{L"MiddleClickCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"taskmgr",0,L"MiddleClick=3",L"Command"},
41854195
{L"Hover",CSetting::TYPE_INT,IDS_HOVER,IDS_HOVER_TIP,0},
41864196
{L"Nothing",CSetting::TYPE_RADIO,IDS_OPEN_NOTHING,IDS_OPEN_NOTHING_TIP},
41874197
{L"ClassicMenu",CSetting::TYPE_RADIO,IDS_OPEN_CSM,IDS_OPEN_CSM_TIP},
41884198
{L"WindowsMenu",CSetting::TYPE_RADIO,IDS_OPEN_WSM,IDS_OPEN_WSM_TIP},
4199+
{L"Command",CSetting::TYPE_RADIO,IDS_OPEN_CMD,IDS_OPEN_CMD_TIP},
4200+
{L"HoverCommand",CSetting::TYPE_STRING,IDS_OPEN_CMD_TEXT,IDS_OPEN_CMD_TEXT_TIP,"",0,L"Hover=3",L"Command"},
41894201
{L"StartHoverDelay",CSetting::TYPE_INT,IDS_HOVER_DELAY,IDS_HOVER_DELAY_TIP,1000,0,L"Hover",L"Hover"},
41904202
{L"ShiftRight",CSetting::TYPE_BOOL,IDS_RIGHT_SHIFT,IDS_RIGHT_SHIFT_TIP,0},
41914203
{L"CSMHotkey",CSetting::TYPE_HOTKEY,IDS_CSM_HOTKEY,IDS_CSM_HOTKEY_TIP,0},

Src/StartMenu/StartMenuDLL/StartMenuDLL.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ enum
7979
OPEN_NOTHING,
8080
OPEN_CLASSIC,
8181
OPEN_WINDOWS,
82+
OPEN_CUSTOM,
8283
OPEN_BOTH,
8384
OPEN_DESKTOP,
8485
OPEN_CORTANA,
@@ -3348,6 +3349,16 @@ static LRESULT CALLBACK HookProgManThread( int code, WPARAM wParam, LPARAM lPara
33483349
msg->message=WM_NULL;
33493350
if (control==OPEN_CLASSIC)
33503351
PostMessage(g_TaskBar,g_StartMenuMsg,MSG_TOGGLE,0);
3352+
else if (control==OPEN_CUSTOM)
3353+
{
3354+
CString commandText=GetSettingString(L"WinKeyCommand");
3355+
if (!commandText.IsEmpty())
3356+
{
3357+
wchar_t expandedCommand[_MAX_PATH]{};
3358+
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
3359+
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
3360+
}
3361+
}
33513362
}
33523363
}
33533364
}
@@ -3431,6 +3442,16 @@ if (!g_bTrimHooks)
34313442
PostMessage(g_ProgWin,WM_SYSCOMMAND,SC_TASKLIST,'WSMK');
34323443
else if (control==OPEN_CORTANA)
34333444
OpenCortana();
3445+
else if (control==OPEN_CUSTOM)
3446+
{
3447+
CString commandText=GetSettingString(L"ShiftWinCommand");
3448+
if (!commandText.IsEmpty())
3449+
{
3450+
wchar_t expandedCommand[_MAX_PATH]{};
3451+
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
3452+
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
3453+
}
3454+
}
34343455
}
34353456
else if (msg->wParam==MSG_DRAG || msg->wParam==MSG_SHIFTDRAG)
34363457
{
@@ -3590,12 +3611,22 @@ if (!g_bTrimHooks)
35903611
// left or middle click on start button
35913612
FindWindowsMenu();
35923613
const wchar_t *name;
3614+
const wchar_t *command;
35933615
if (bMiddle)
3616+
{
35943617
name=L"MiddleClick";
3618+
command=L"MiddleClickCommand";
3619+
}
35953620
else if (GetKeyState(VK_SHIFT)<0)
3621+
{
35963622
name=L"ShiftClick";
3623+
command=L"ShiftClickCommand";
3624+
}
35973625
else
3626+
{
35983627
name=L"MouseClick";
3628+
command=L"MouseClickCommand";
3629+
}
35993630

36003631
int control=GetSettingInt(name);
36013632
if (control==OPEN_BOTH && GetWinVersion()>=WIN_VER_WIN10)
@@ -3611,6 +3642,16 @@ if (!g_bTrimHooks)
36113642
PostMessage(g_ProgWin,WM_SYSCOMMAND,SC_TASKLIST,'WSMM');
36123643
else if (control==OPEN_CORTANA)
36133644
OpenCortana();
3645+
else if (control==OPEN_CUSTOM)
3646+
{
3647+
CString commandText=GetSettingString(command);
3648+
if (!commandText.IsEmpty())
3649+
{
3650+
wchar_t expandedCommand[_MAX_PATH]{};
3651+
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
3652+
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
3653+
}
3654+
}
36143655
msg->message=WM_NULL;
36153656
}
36163657
}
@@ -3751,6 +3792,16 @@ if (!g_bTrimHooks)
37513792
FindWindowsMenu();
37523793
PostMessage(g_ProgWin,WM_SYSCOMMAND,SC_TASKLIST,'WSMM');
37533794
}
3795+
else if (control==OPEN_CUSTOM)
3796+
{
3797+
CString commandText=GetSettingString(L"HoverCommand");
3798+
if (!commandText.IsEmpty())
3799+
{
3800+
wchar_t expandedCommand[_MAX_PATH]{};
3801+
::ExpandEnvironmentStrings(commandText, expandedCommand, _countof(expandedCommand));
3802+
ShellExecute(NULL,NULL,expandedCommand,NULL,NULL,SW_SHOWNORMAL);
3803+
}
3804+
}
37543805
}
37553806
}
37563807
taskBar->bTimer=false;

Src/StartMenu/StartMenuDLL/StartMenuDLL.rc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,6 +1307,10 @@ BEGIN
13071307
IDS_NEW_SEARCH_HINT_TIP "The text to replace the search hint with. Empty text is a valid option"
13081308
IDS_MORE_RESULTS "Enable ""See more results"" option"
13091309
IDS_MORE_RESULTS_TIP "When this is checked, the search results will include an option to do a more advanced search"
1310+
IDS_OPEN_CMD "Custom command"
1311+
IDS_OPEN_CMD_TIP "The action will run a user-defined command"
1312+
IDS_OPEN_CMD_TEXT "Command to run"
1313+
IDS_OPEN_CMD_TEXT_TIP "Enter the command to run when you use this control"
13101314
END
13111315

13121316
#endif // English (U.S.) resources

Src/StartMenu/StartMenuDLL/resource.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,6 +770,10 @@
770770
#define IDS_NEW_SEARCH_HINT_TIP 3673
771771
#define IDS_MORE_RESULTS 3674
772772
#define IDS_MORE_RESULTS_TIP 3675
773+
#define IDS_OPEN_CMD 3676
774+
#define IDS_OPEN_CMD_TIP 3677
775+
#define IDS_OPEN_CMD_TEXT 3678
776+
#define IDS_OPEN_CMD_TEXT_TIP 3679
773777
#define IDS_STRING7001 7001
774778
#define IDS_STRING7002 7002
775779
#define IDS_STRING7003 7003

0 commit comments

Comments
 (0)