-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWinManager.lua
More file actions
63 lines (51 loc) · 1.3 KB
/
WinManager.lua
File metadata and controls
63 lines (51 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
require "winapi"
require "Class"
local WM_LBUTTONDOWN = 0x0201
local WM_LBUTTONPU = 0x0202
local BM_SETCHECK = 0x00F1
Window=class()
function Window:ctor(hwnd)
print("Window ctor " .. tostring(hwnd))
self.hwnd = hwnd
end
function Window:Attach(className,winName)
self.hwnd = FindWindow(className,winName)
print("Window Attach " .. tostring(self.hwnd))
return self:IsWindow()
end
function Window:IsWindow()
return self.hwnd ~= nil and self.hwnd ~= 0
end
function Window:FindControl(id)
print("FindControl " .. tostring(self.hwnd) .. " " .. tostring(id))
if self:IsWindow() then
ch = GetDlgItem(self.hwnd,id)
c = WControl.new(ch)
print("FindControl result " .. tostring(ch) )
return c
end
end
function Window:FindWindow(afterhWnd,className,winName)
if self:IsWindow() then
ch = FindWindowEx(self.hwnd,afterhWnd,className,winName)
c = WControl.new(ch)
print("FindWindow result " .. tostring(ch) )
return c
end
end
function Window:Show(s)
ShowWindow(self.hwnd,s);
end
WControl = class(Window)
function WControl:Click()
SendMessage(self.hwnd,WM_LBUTTONDOWN,0,0);
Sleep(20);
SendMessage(self.hwnd,WM_LBUTTONPU,0,0);
end
function WControl:SetCheck(c)
if c then check = 1 else check = 0 end
SendMessage(self.hwnd,BM_SETCHECK,check,0);
end
function WControl:SetText(t)
EditSetText(self.hwnd,t);
end