Click here to Skip to main content
13,632,677 members
Click here to Skip to main content
Add your own
alternative version

Stats

24.2K views
227 downloads
15 bookmarked
Posted 6 Nov 2007
Licenced Public Domain

VS: Attach to Remote Process with AutoIt

, 6 Nov 2007
Rate this:
Please Sign up or sign in to vote.
Just a tiny tool to fix what was annoying me from VS 6

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

Share

About the Author

yeti11
Slovenia Slovenia
No Biography provided

You may also be interested in...

Pro

Comments and Discussions

 
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180712.1 | Last Updated 6 Nov 2007
Article Copyright 2007 by yeti11
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid