[General]
Description=命令例子：窗口Window插件
BeginHotkey=121
BeginHotkeyMod=0
PauseHotkey=0
PauseHotkeyMod=0
StopHotkey=123
StopHotkeyMod=0
RunOnce=1
EnableWindow=
Enable=0
AutoRun=0
[Repeat]
Type=0
Number=1
[Relative]
SetupOCXFile=
[Comment]
Content=

[Script]
//测试OK
Dim MyArray
VBSCall RunApp("notepad.exe")
Delay 1000
//=================================================================================
//下面这句是查找窗口类名(0)或者标题("无标题 - 记事本"),返回找到的句柄Hwnd
Plugin Hwnd = Window.Find(0, "无标题 - 记事本")
MsgBox "查找到的父窗口句柄为："&Hwnd
//下面这句是根据父窗口句柄(Hwnd)查找子窗口匹配类名("Edit")或者匹配标题(0),返回找到匹配的句柄Hwnd
Plugin Hwnd = Window.FindEx(Hwnd, 0, "Edit", 0)
MsgBox "查找到的子窗口句柄为："&Hwnd
//=================================================================================
//下面这句是激活窗口
Plugin Window.Active(Hwnd)
MsgBox "当前激活窗口"
//下面这句是得到当前最前面的窗口句柄
Plugin Hwnd = Window.Foreground()
MsgBox "得到当前最前面的窗口句柄为："&Hwnd
//下面这句是最小化窗口
Plugin Window.Min(Hwnd)
MsgBox "当前最小化"
//下面这句是还原窗口
Plugin Window.Restore(Hwnd)
MsgBox "当前还原窗口"
//下面这句是最大化窗口
Plugin Window.Max(Hwnd)
MsgBox "当前最大化"
//下面这句是还原窗口
Plugin Window.Restore(Hwnd)
MsgBox "当前还原窗口"
//下面这句是得到鼠标指向的窗口句柄
Plugin Hwnd0 = Window.MousePoint()
MsgBox "得到鼠标指向的窗口句柄为："&Hwnd0
//下面这句是隐藏窗口
Plugin Window.Hide(Hwnd)
MsgBox "当前隐藏窗口"
//下面这句是显示窗口
Plugin Window.Show(Hwnd)
MsgBox "当前显示窗口"
//=================================================================================
//下面这句是得到窗口句柄的边框大小(包括标题栏)
Plugin Rect = Window.GetWindowRect(Hwnd)
MsgBox "得到窗口句柄的边框大小(包括标题栏)为："&Rect
//下面这句用于分割字符串,将横坐标和纵坐标分成两个字符串
MyArray = Split(Rect, "|")
//下面这句将字符串转换成数值
W1 = Clng(MyArray(0)): H1 = Clng(MyArray(1))
W2 = Clng(MyArray(2)): H2 = Clng(MyArray(3))
MsgBox "边框大小：       "  &  W2-W1 & "             " & H2-H1
//下面这句是改变窗口大小为(100, 100)
Plugin Window.Size(Hwnd, 100, 100)
MsgBox "当前改变窗口大小"
//下面这句是得到窗口句柄的客户区大小
Plugin Rect = Window.GetClientRect(Hwnd)
MsgBox "得到窗口句柄的客户区大小为："&Rect
//下面这句用于分割字符串,将横坐标和纵坐标分成两个字符串
MyArray = Split(Rect, "|")
//下面这句将字符串转换成数值
L = Clng(MyArray(0)): T = Clng(MyArray(1))
R = Clng(MyArray(2)): B = Clng(MyArray(3))
//下面这句是改变窗口大小为(W, H)
Plugin Window.Size(Hwnd, W2-W1, H2-H1)
MsgBox "当前改变窗口大小"
//=================================================================================
//下面这句是移动窗口到(100, 100)位置
Plugin Window.Move(Hwnd, 100, 100)
MsgBox "当前移动窗口到(100, 100)位置"
//下面这句是判断窗口是否打开
Plugin Window = Window.IsWindow(Hwnd)
If Window = 1
    MsgBox "窗口打开中"
Else 
    MsgBox "窗口没有打开"
EndIf 
//下面这句是得到窗口句柄的标题
Plugin Text = Window.GetText(Hwnd)
MsgBox "得到窗口句柄的标题为："&Text
//下面这句是得到窗口句柄的类名
Plugin Class1 = Window.GetClass(Hwnd)
MsgBox "得到窗口句柄的类名为："&Class1
//=================================================================================
//下面这句是遍历符合窗口标题("记事本")的句柄保存到数组(HwndEx)里
Plugin HwndEx = Window.Search("记事本")
MsgBox "查找到符合的窗口句柄为："&HwndEx
//下面这句用于分割字符串,将横坐标和纵坐标分成两个字符串
MyArray = Split(HwndEx, "|")
If UBound(MyArray)>=0
    i=0
    For UBound(MyArray)
        //下面这句将字符串转换成数值
        Msgbox "第 "&i+1&" 个窗口句柄为："&Clng(MyArray(i))
        i=i+1
    EndFor 
EndIf 
//=================================================================================
//下面这句是改变窗口大小为(300, 200)
Plugin Window.Size(Hwnd, 300, 200)
MsgBox "当前改变窗口大小"
//=================================================================================
//下面这句是窗口属性设置为(窗口置前)
Plugin Window.Top(Hwnd, 0)
MsgBox "当前窗口置前"
//下面这句是窗口属性设置为(取消窗口置前)
Plugin Window.Top(Hwnd, 1)
MsgBox "当前取消窗口置前"
//=================================================================================
//下面这句是关闭窗口
Plugin Window.Close(Hwnd)
MsgBox "当前关闭窗口"
