admin
2024-01-11 5a2ef3a696ddccbc1faef1e2e90f5b535ec24a0d
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import time
# 获取同花顺副屏幕1句柄
import win32con
 
import win32_util
import win32gui
 
 
def get_ths_second_screen_menu_hwnd():
    hwnds = win32_util.search_window("副屏1")
    if hwnds:
        hwnd = hwnds[0]
        hwnd = win32gui.FindWindowEx(hwnd, None, "AfxFrameOrView100s", None)
        temp = None
        for i in range(0, 100):
            temp = win32gui.FindWindowEx(hwnd, temp, "AfxWnd100s", None)
            if win32gui.IsWindowVisible(temp):
                left, top, right, bottom = win32gui.GetWindowRect(temp)
                if bottom - top > right - left:
                    break
        if temp is None:
            return None
        hwnd = temp
        hwnd = win32gui.FindWindowEx(hwnd, None, "#32770", None)
        hwnd = win32gui.FindWindowEx(hwnd, None, "block_list_page", None)
        if hwnd:
            return hwnd
 
    return None
 
 
def get_trade_refesh_hwnd():
    hwnds = win32_util.search_window("网上股票交易系统")
    if hwnds:
        for hwnd in hwnds:
            content_hwnd = win32gui.FindWindowEx(hwnd, None, "AfxMDIFrame140s", None)
            temp = win32gui.FindWindowEx(content_hwnd, None, "#32770", None)
            for i in range(10):
                if win32gui.IsWindowVisible(temp):
                    break
                temp = win32gui.FindWindowEx(content_hwnd, temp, "#32770", None)
            if not temp:
                continue
            t1 = win32gui.FindWindowEx(temp, None, None, "过滤")
            if not win32gui.IsWindowVisible(t1):
                continue
 
            tool_hwnd = win32gui.FindWindowEx(hwnd, None, "ToolbarWindow32", None)
            temp = win32gui.FindWindowEx(tool_hwnd, None, "#32770", None)
            if temp:
                nq = win32gui.FindWindowEx(temp, None, None, "内嵌")
                if nq and win32gui.IsWindowVisible(nq):
                    continue
            return tool_hwnd
    return None
 
 
# 获取交易句柄
def get_trade_hwnd():
    hwnds = win32_util.search_window("网上股票交易系统")
    if hwnds:
        hwnd = hwnds[0]
        return hwnd
    return None
 
 
def get_ths_main_content_hwnd():
    hwnds = win32_util.search_window("同花顺")
    if hwnds:
        hwnd = hwnds[0]
        child = None
        for i in range(0, 20):
            child = win32gui.FindWindowEx(hwnd, child, None, None)
            if child:
                left, top, right, bottom = win32gui.GetWindowRect(child)
                if right - left > 1000 and bottom - top > 800:
                    return child
    return None
 
 
# 批量点击事件
def betch_click(hwnd, ps, space_time=0.5):
    for p in ps:
        win32_util.visual_click(hwnd, p)
        time.sleep(space_time)
 
 
if __name__ == "__main__":
    print(get_ths_main_content_hwnd())