[译]VS:使用AutoIt附加到远程进程
By robot-v1.0
本文链接 https://www.kyfws.com/applications/vs-attach-to-remote-process-with-autoit-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 3 分钟阅读 - 1150 个词 阅读量 0[译]VS:使用AutoIt附加到远程进程
原文地址:https://www.codeproject.com/Articles/21200/VS-Attach-to-Remote-Process-with-AutoIt
原文作者:yeti11
译文由本站 robot-v1.0 翻译
前言
Just a tiny tool to fix what was annoying me from VS 6
只是一个小工具,可解决VS 6中令人讨厌的问题
介绍(Introduction)
这只是一个很小的工具,解决了自Visual Studio 6以来一直困扰我的问题.附加到远程进程总是让所有不必要的点击烦人.(This is just a tiny tool that fixes the problem that was annoying me since Visual Studio 6. Attaching to remote process was always annoying with all the unnecessary clicking.)
背景(Background)
该脚本:(This script:)
- 等待VC ++成为活动进程(waits for VC++ to become active process)
- 发送" alt + d"和" p"键序列以打开"进程"对话框(sends ‘alt+d’ and ‘p’ key sequence to open Processes dialog)
- 将传输设置为TCP/IP(sets Transport to TCP/IP)
- 将名称设置为通过命令行参数指定的主机(sets Name to host specified via command line parameter)
- 等待"可用进程"列表填写(waits for “Available Processes” list to be filled)
- 搜索通过命令行参数指定的进程名称(searches for process name specified via command line parameter)
- 点击"附加…“按钮(clicks “Attach…” button)
- 等待"调试的进程"填充(waits for “Debugged Processes” to be filled)
- 点击"关闭"按钮(clicks “Close” button) 这是在使用AutoIt播放2小时(包括此文本)后完成的((This was done after 2 hours (including this text) of playing with AutoIt () http://www.autoitscript.com/autoit3(http://www.autoitscript.com/autoit3) ),我已经好几年没有使用basic了,所以如果可以做一些更优化的事情,请饶我一筹.没有autoit,它将无法运行.(), I didn’t use basic for years so please spare me if something could be done more optimised / whatever. It won’t run without autoit.)
我本可以用C ++做到的,但是用这种方法更快.(I could have done it in C++, but it was quicker this way.)
使用代码(Using the Code)
代码是在VC ++ 2003上编写和测试的,请更改窗口参数,这很简单.运行不带参数的脚本,您将获得msgbox.(Code was written and tested on VC++ 2003, please change window parameters, it’s trivial. Run the script without parameters, you will get msgbox.) 建议用途:将其添加到外部工具并在工具栏中创建按钮以快速访问.(Suggested use: Add it to external tools and create button in toolbar for quick access.)
if 3 <> UBound($CmdLine) Then
MsgBox(0, "Wrong parameters...", "attach.au host process>")
Exit(1)
EndIf
$computer = $CmdLine[1]
$process = $CmdLine[2]
$timeout = 10000
if 0 = WinWaitActive("[CLASS:wndclass_desked_gsk]", "MenuBar", $timeout) then
MsgBox(0, "Error.", "Cand find Visual Studio menu")
Exit(1)
EndIf
Send("{ALT}d")
Sleep(250)
Send("p")
if 0 = WinWaitActive("Processes", "", $timeout) then
MsgBox(0, "Error.", "Cand open Processes dialog")
Exit(1)
EndIf
ControlCommand("", "", 'ComboBox1', 'SetCurrentSelection', 'TCP/IP (Native only)')
ControlSetText("", "", "Edit1", $computer)
ControlClick("", "&Refresh", "Button6")
$item_count = ControlListView("", "List1", "SysListView321", "GetItemCount");
While 0 = $item_count
Sleep(250)
$item_count = ControlListView("", "List1", "SysListView321", "GetItemCount");
WEnd
Sleep(500)
$index_proc = ControlListView("", "List1", "SysListView321", "FindItem", $process, 0)
if $index_proc = -1 then
MsgBox(0, "Process not found!", $process)
Exit(1)
Else
ControlListView("", "List1", "SysListView321", "DeSelect", 0, ControlListView
("", "List1", "SysListView321", "GetItemCount"))
ControlListView("", "List1", "SysListView321", "Select", $index_proc)
ControlClick("", "&Attach...", "Button5")
While 0 = ControlListView("", "List2", "SysListView322", "GetItemCount")
Sleep(250)
WEnd
ControlClick("", "&Close", "Button11")
EndIf
Exit(0)
历史(History)
- 6(6)日(th)2007年11月:初始职位(November, 2007: Initial post)
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ Windows Visual-Studio VS.NET2003 Dev 新闻 翻译