
老师来为你解答:
PluginWindowmousewindow()
因为句柄并不是每次打开一个窗口都一样的
所以你一定要用Hwnd来获取句柄,
获取不到句柄,很有可能是标题名不对
所以要先用PluginWindowmousewindow()+鼠标指向窗口获取标题名,然后存在剪贴板中,再粘贴到脚本里
为师就帮你到这里,剩下的看你悟性了,希望对你有帮助
获取所有句柄,源码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
btn_listwindow: TButton;
procedure btn_listwindowClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
function EnumWindowsProc(AhWnd:LongInt;AForm:TForm1):boolean;stdcall;
implementation
{$R dfm}
function EnumWindowsProc(AhWnd:LongInt;AForm:TForm1):boolean;
var
lpszClassName,lpszWindowText:array[0254] of char;
begin
GetWindowText(AhWnd,lpszWindowText,254);
GetClassName(AhWnd,lpszClassName,254);
Aformmemo1linesadd(StrPas(lpszWindowText));
Aformmemo1linesadd(StrPas(lpszClassName));
Aformmemo1linesadd( '-------------------- ');
Result:=True;
end;
procedure TForm1btn_listwindowClick(Sender: TObject);
begin
EnumWindows(@EnumWindowsProc,LongInt(self));
end;
end
F9,运行,看看结果。最好是F7单步跟踪调试一下,看看回调函数是怎么被调用的。
能获得所有webbrowser的句柄,但是不知道哪个哪个
添加一个list ,一个command,多个webbrowser
加入以下代码
Private Const GW_HWNDNEXT = 2
Private Const GW_CHILD = 5
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Sub Command1_Click()
GetBrowserWindow Mehwnd
End Sub
Private Function GetBrowserWindow(hwndBrowserContainer As Long) As Long
Dim RetVal As Long
Dim hwndPeer As Long
Dim ClassString As String 256
hwndPeer = GetWindow(hwndBrowserContainer, GW_CHILD)
RetVal = GetClassName(hwndPeer, ClassString, 256)
If InStr(ClassString, "Shell Embedding") <> 0 Then
List1AddItem Str(hwndPeer) & "|" & ClassString
End If
Do While hwndPeer <> 0
hwndPeer = GetWindow(hwndPeer, GW_HWNDNEXT)
RetVal = GetClassName(hwndPeer, ClassString, 256)
If InStr(ClassString, "Shell Embedding") <> 0 Then
List1AddItem Str(hwndPeer) & "|" & ClassString
End If
Loop
GetBrowserWindow = hwndPeer
End Function
是不是变成Internet Explorer了
下边这个是获取所有控件的ID和类名:
Private Function GetBrowserWindow(hwndBrowserContainer As Long) As Long
Dim RetVal As Long
Dim hwndPeer As Long
Dim ClassString As String 256
hwndPeer = GetWindow(hwndBrowserContainer, GW_CHILD)
RetVal = GetClassName(hwndPeer, ClassString, 256)
List1AddItem Str(hwndPeer) & "|" & ClassString
Do While hwndPeer <> 0
hwndPeer = GetWindow(hwndPeer, GW_HWNDNEXT)
RetVal = GetClassName(hwndPeer, ClassString, 256)
List1AddItem Str(hwndPeer) & "|" & ClassString
Loop
GetBrowserWindow = hwndPeer
End Function
我只能帮你这么多了,我也试图通过句柄来获取控件的名称,但还是找不到
以上就是关于按键精灵9 自动获取窗口句柄 公式,Hwnd = Plugin.Window.Search("记事本") ,鼠标座标应该怎么写才正确全部的内容,包括:按键精灵9 自动获取窗口句柄 公式,Hwnd = Plugin.Window.Search("记事本") ,鼠标座标应该怎么写才正确、delphi主流浏览器窗口句柄获取源码、VC 如何获取WebBrowser控件里面网页句柄等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)