English 中文(简体)
How to Press a Button on a Different Process (nunit.exe)
原标题:How to Press a Button on a Different Process (nunit.exe)

我已经记录到这一宏观情况,对我来说是一个进程。 现在,我想在我所重视的这一进程的窗口上打一个叫“Run”的纽子,但如何? 我记录了这一宏观:

Sub DebugNUnit()
DTE.ExecuteCommand("Tools.ExternalCommand6")
 need a short delay for nunit process to appear in process list:
Threading.Thread.Sleep(200)

Try

    Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger

    Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")

    Dim dbgeng(1) As EnvDTE80.Engine

    dbgeng(0) = trans.Engines.Item("Managed (v4.0)")

    Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "myPC").Item("nunit.exe")

    proc2.Attach2(dbgeng)

Catch ex As System.Exception

    MsgBox(ex.Message)

End Try
End Sub

<><>UPDATE: 我已经根据这种答案调整了文字。

Sub DebugNUnit()
    DTE.ExecuteCommand("Tools.ExternalCommand6")
     need a short delay for nunit process to appear in process list:
    Threading.Thread.Sleep(200)

    Try

        Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger

        Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")

        Dim dbgeng(1) As EnvDTE80.Engine

        dbgeng(0) = trans.Engines.Item("Managed (v4.0)")

        Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "myPC").Item("nunit.exe")

        proc2.Attach2(dbgeng)

         added this because we may need a short delay for nunit gui to load
         (would prefer to replace it with a wait on some loaded event or something)
        Threading.Thread.Sleep(5000)

         use Process.Handle or Process.MainWindowHandle? anyway, both do not seem to work.. are the parameters incorrect?
        Dim ButtonHandle As IntPtr = FindWindowEx(System.Diagnostics.Process.GetProcessById(proc2.ProcessID).Handle, 0, "Button", "Run")
         Dim ButtonHandle As IntPtr = FindWindowEx(System.Diagnostics.Process.GetProcessById(proc2.ProcessID).MainWindowHandle, 0, "Button", "Run")

        SendMessage(ButtonHandle, &HF5, 0, 0)

    Catch ex As System.Exception

        MsgBox(ex.Message)

    End Try

End Sub

但是,启动的努尼特用户界面上的“Run”纽特语区(通过工具)。 对外通商6号仍然未受到压力。 这一点是有意义的,因为纽特人似乎总是零。 有谁可以找到解决办法?

<><>UPDATE: 我已经根据编辑的回答对文字做了调整。

Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
Imports System.Runtime.InteropServices
Imports System.Windows.Forms

Public Module RecordingModule

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _
    Private Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
End Function

Sub DebugNUnit()
    DTE.ExecuteCommand("Tools.ExternalCommand6")
     need a short delay for nunit processes to appear in process list:
    Threading.Thread.Sleep(1000)

    Try

        Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger
        Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")
        Dim dbgeng(1) As EnvDTE80.Engine
        dbgeng(0) = trans.Engines.Item("Managed (v4.0)")
        Dim proc2nunitagent As EnvDTE80.Process2 = dbg2.GetProcesses(trans, Environment.MachineName).Item("nunit-agent.exe")
        Dim proc2nunit As EnvDTE80.Process2 = dbg2.GetProcesses(trans, Environment.MachineName).Item("nunit.exe")
        proc2nunitagent.Attach2(dbgeng)

        PostMessage(System.Diagnostics.Process.GetProcessById(proc2nunit.ProcessID).MainWindowHandle, &H100, Keys.Alt Or Keys.R, IntPtr.Zero)

    Catch ex As System.Exception

        MsgBox(ex.Message + Environment.NewLine + ex.StackTrace)

    End Try

End Sub
End Module

我正在使用第2条第7款,并随附和伪造你需要的工作,以配合努尼特人手和按努尼特人编印的新闻,以了解你可以随附的努尼特人的最新版本。

以上文字使视力工作室的视像素分解能够使用简单的视觉演播室和显像仪。 你们都需要做的是,把努尼特作为外部工具(目前的项目作为参数),创造习惯工具,并在使用上述文字的该工具路障上添加一个子。 这将从努尼特开始,随附,开始进行试验,打破你的时间间隔。

另有一件事:在工具->中,不可分的“每个项目的太阳视觉状态”中;装置->树木显示器或核子吉将记住最后一次试验,如果这并非你想要的试样,那是一种痛苦。

可能的改进:在启动核心任务之前再接再厉。

最佳回答

为此:

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr
End Function
<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, ByVal childAfter As IntPtr, ByVal lclassName As String, ByVal windowTitle As String) As IntPtr
End Function

Dim ButtonHandle As IntPtr = FindWindowEx(YOURPROCESS.HANDLE, 0, "Button", "&Run")
SendMessage(ButtonHandle, &HF5, 0, 0)

www.un.org/Depts/DGACM/index_russian.htm Seems such as NUint is a .NET app which means You can t 获得纽芬兰的方便处理。 你们可以在Spy++的帮助下看到这一点。

I noticed that the button Run has a keyboard shortcut of ALT + R so instead you can use this code:

<DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)>
Private Shared Function PostMessage(ByVal hWnd As IntPtr, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As Boolean
End Function
PostMessage(MAIN_WINDOW_HANDLE, &H100, Keys.Alt Or Keys.R, IntPtr.Zero)

我对此进行了测试,并做了罚款。

问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签