我已經搜索了一下,但似乎無法弄清楚如何在控制檯窗口中右鍵單擊我自己的控制檯應用程序時顯示控制檯菜單,如下所示:控制檯應用程序中的右鍵菜單
http://i44.tinypic.com/2jbl82w.png
右鍵單擊控制檯窗口時,如何使菜單顯示在我自己的控制檯應用程序中?
是的,我知道我可以使用左上角的圖標來顯示菜單功能,但我正在尋找右鍵單擊解決方案!
(這個問題似乎是,當我通過CMD.EXE執行.exe文件,而不是直接運行它的出現)
我已經搜索了一下,但似乎無法弄清楚如何在控制檯窗口中右鍵單擊我自己的控制檯應用程序時顯示控制檯菜單,如下所示:控制檯應用程序中的右鍵菜單
http://i44.tinypic.com/2jbl82w.png
右鍵單擊控制檯窗口時,如何使菜單顯示在我自己的控制檯應用程序中?
是的,我知道我可以使用左上角的圖標來顯示菜單功能,但我正在尋找右鍵單擊解決方案!
(這個問題似乎是,當我通過CMD.EXE執行.exe文件,而不是直接運行它的出現)
修正了以下變通,因爲沒有直接的解決問題/問題:
string filelocation = Assembly.GetExecutingAssembly().Location;
string filename = Process.GetCurrentProcess().MainModule.ModuleName;
filename = filename.Replace(".exe", "");
Process[] processArray = Process.GetProcesses();
int processesExists = 0;
for (int i2 = 0; i2 < (processArray.Length - 1); i2++)
{
if (processArray[i2].ProcessName.Contains(filename))
{
processesExists++;
}
}
if (processesExists == 1 && !Console.Title.Contains("cmd"))
{
Process.Start("cmd.exe", "/C " + "\"" + filelocation + "\"");
}
if (!Console.Title.Contains("cmd"))
{
Process.GetCurrentProcess().Kill();
}
使用SetConsoleMode
清除ENABLE_QUICK_EDIT_MODE
模式。當程序退出時,將標誌恢復到之前的設置只是禮貌。
你在調試器中運行呢? http://stackoverflow.com/questions/1060240/what-happened-to-the-context-menu-in-my-console-application –
你可能想讀這個:http://stackoverflow.com/questions/1944481/console-app-mouse-click-xy-coordinate-detection-comparison –
如果您在Visual Studio(調試)或Visual Studio之外運行應用程序(應用程序直接執行) – Birdman