Click here to Skip to main content
Click here to Skip to main content

VS: Attach to Remote Process with AutoIt

By , 6 Nov 2007
 

Introduction

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:

  • waits for VC++ to become active process
  • sends 'alt+d' and 'p' key sequence to open Processes dialog
  • 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

This was done after 2 hours (including this text) of playing with AutoIt (http://www.autoitscript.com/autoit3), 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.

I could have done it in C++, but it was quicker this way.

Using the Code

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

  • 6th November, 2007: Initial post

License

This article, along with any associated source code and files, is licensed under A Public Domain dedication

About the Author

yeti11
Slovenia Slovenia
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 6 Nov 2007
Article Copyright 2007 by yeti11
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid