gpt4 book ai didi

VB.net SendMessage等待问题

转载 作者:行者123 更新时间:2023-12-02 01:54:14 24 4
gpt4 key购买 nike

我使用以下代码来单击一个按钮,以显示另一个要单击的表单:

Dim hwnd As Integer = FindWindow(vbNullString, "Virtual CDRom Control Panel")
Dim x As Integer = FindWindowEx(hwnd, 0, vbNullString, "Driver Control ...")

SendMessage(x, BM_CLICK, 0&, 0&)
Thread.Sleep(200)
hwnd = FindWindow(vbNullString, "Virtual CD-ROM Driver Control")
Debug.Print(hwnd)

问题是当它达到

SendMessage(x, BM_CLICK, 0&, 0&)

单击按钮,它会停止代码,直到我退出弹出的框。我希望能够继续,而不必从下一行开始退出框

hwnd = FindWindow(vbNullString, "虚拟光驱控制")

找到弹出窗口并单击该框中的按钮。

任何帮助都会很棒! :o)

大卫

已解决

Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As IntPtr, ByVal hWndChildAfter As Integer, ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" (ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
Private Declare Function PostMessage Lib "user32.dll" Alias "PostMessageA" (ByVal hwnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr

Dim hwnd As IntPtr = FindWindow(vbNullString, "Virtual CDRom Control Panel")
Dim x As IntPtr = FindWindowEx(hwnd, 0, vbNullString, "Driver Control ...")

PostMessage(x, BM_CLICK, 0&, 0&)
Thread.Sleep(200)
hwnd = FindWindow(vbNullString, "Virtual CD-ROM Driver Control")
Debug.Print(hwnd)

最佳答案

尝试将 SendMessage 更改为 PostMessage .

另请注意,所有 HWND 必须声明为 IntPtr
SendMessagePostMessagewParamlParam 也是 IntPtr
这将使您的代码与 x64 环境兼容。

关于VB.net SendMessage等待问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5168671/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com