快速输入用于Visual Studio调试的命令行参数?
我想改变我的命令行参数,然后调试我的可执行文件。快速输入用于Visual Studio调试的命令行参数?
在默认Visual Studio的用户界面,这需要我几个曲折的鼠标和键盘操作:
项目...右键单击...配置属性... ...调试命令参数... 型ARGS ... ... ENTER F5
有没有一种方法,使这项共同行动容易,因为其他常见的操作,例如,搜索肚里的模式中的所有文件:
CNTL + SHIFT + F ... 类型的搜索模式 ... ENTER
例如,是否有创建一个自定义编辑框,以便快速进入调试命令行参数的方式?或者有一个键绑定的方式弹出一个简单的“调试对话框”,其中可以输入参数并直接进行调试?例如
ALT + F5 ... 型ARGS ... ENTER
我使用C++和Visual Studio 2010速成。谢谢!
下面的宏应该有所帮助。打开“工具 - >宏 - >宏浏览器”,然后创建新模块,编辑它,然后复制粘贴下面的代码。所需的命令是SetCommandArgsProperty。用户界面不好,但它的工作原理(VS 2005,我希望这也可以在VS 2010中工作)。然后添加你喜欢的任何快捷方式来运行这个宏。
这里还有一些细节:
- 查找启动项目
- 选择激活它的配置和名称为“CommandArguments”
- 在它的当前值创建编辑框中
-
更新找物业财产如果确定选择
Sub SetCommandArgsProperty() Dim newVal As Object newVal = InputValue(GetCommandArgsPropertyValue()) If TypeOf newVal Is String Then SetCommandArgsProperty(newVal) End If End Sub Function InputValue(ByVal defaultText As String) Dim frm As New System.Windows.Forms.Form Dim btn As New System.Windows.Forms.Button Dim edit As New System.Windows.Forms.TextBox edit.Text = defaultText edit.Width = 100 btn.Text = "OK" btn.DialogResult = System.Windows.Forms.DialogResult.OK frm.Text = "Input command line properties" frm.Controls.Add(btn) btn.Dock = System.Windows.Forms.DockStyle.Bottom frm.Controls.Add(edit) edit.Dock = System.Windows.Forms.DockStyle.Top frm.Height = 80 frm.Width = 300 If frm.ShowDialog() = System.Windows.Forms.DialogResult.OK Then Return edit.Text End If Return System.DBNull.Value End Function Function GetCommandArgsProperty() As EnvDTE.Property Dim solution As Solution Dim project As Project Dim sb As SolutionBuild Dim str As String Dim cm As ConfigurationManager Dim config As Configuration Dim properties As Properties Dim prop As EnvDTE.Property solution = DTE.Solution sb = solution.SolutionBuild For Each str In sb.StartupProjects project = solution.Item(str) cm = project.ConfigurationManager config = cm.ActiveConfiguration properties = config.Properties For Each prop In properties If prop.Name = "CommandArguments" Then Return prop End If Next Next End Function Function GetCommandArgsPropertyValue() Return GetCommandArgsProperty().Value End Function Sub SetCommandArgsProperty(ByVal value As String) GetCommandArgsProperty().Value = value End Sub
不幸的是我只有Visual Studio Express,所以没有宏。但我喜欢这种饮料。 – paperjam 2011-03-28 17:00:39
扩展CLIArgsMadeEasy 2010/2012是一个很棒的小东西,它将项目的调试会话的命令行参数放在Visual Studio工具栏IMO的一个小文本框中,它比使用宏更简单,更简单。
链路
http://visualstudiogallery.msdn.microsoft.com/8159cd7d-2c81-47f3-9794-a347ec1fba09?SRC=VSIDE
您只需在扩展管理器,它会发现它很快在画廊搜索框中键入CLIArgsMadeEasy,这就是我如何安装它,如果你需要知道的。希望这可以帮助!
+1 ATM这个版本只能与VS2010一起工作(不要被名字弄糊涂......)。这里有一个VS2012版本:http://n0n4m3.codingcorner.net/?p=214。它的工作原理,但仍然有一些问题。 – 2013-07-12 14:27:42
是否有VS2013的版本? – kdmin 2014-06-25 11:54:33
@kdmin:是的,这里http://n0n4m3.codingcorner.net/?p=1056 – 2014-10-29 16:10:12
至少在Visual Studio 2012中,可以使用Alt+F7
快捷方式直接访问项目属性。
此外,打开的属性页面通常会记住最后打开的项目,即Configuration Properties -> Debugging
。
好像你可以为此写一个宏。记录它,然后编辑它来提示而不是使用键入的文本。分配一个热键,你非常接近? – 2011-03-28 15:24:33
@CraigStuntz - 宏记录器不会记录您在模态对话框中执行的任何操作。 – voetsjoeba 2012-06-08 19:20:50
它也值得考虑[不同的方法](http://stackoverflow.com/questions/4791140/how-do-i-start-a-program-with-arguments-when-debugging);请参阅使用编译器指令的Øyvind解决方案。 – 2013-09-21 20:28:16