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())
|