project:peekwindow
차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판이전 판다음 판 | 이전 판 | ||
project:peekwindow [2015/08/08 19:26] – [설명] changwoo | project:peekwindow [2015/08/08 20:22] (현재) – [설명] changwoo | ||
---|---|---|---|
줄 491: | 줄 491: | ||
우선 제대로 이벤트를 던지면 p_buf에는 각 항목의 텍스트가 복사됩니다. WinAPI가 여기까지는 해 줍니다. 그 다음 | 우선 제대로 이벤트를 던지면 p_buf에는 각 항목의 텍스트가 복사됩니다. WinAPI가 여기까지는 해 줍니다. 그 다음 | ||
- | '' | + | '' |
리스트의 각 항목을 선택하려면 [[https:// | 리스트의 각 항목을 선택하려면 [[https:// | ||
줄 502: | 줄 502: | ||
그런데 TeraCopy는 ListView Control에서 LVM_SETITEMSTATE 이벤트를 제대로 수신하지 않습니다. ListView Control을 이용한 다른 앱을 이용해서 확인하기 바랍니다. 추정컨데 TeraCopy는 [[https:// | 그런데 TeraCopy는 ListView Control에서 LVM_SETITEMSTATE 이벤트를 제대로 수신하지 않습니다. ListView Control을 이용한 다른 앱을 이용해서 확인하기 바랍니다. 추정컨데 TeraCopy는 [[https:// | ||
+ | ==== Control Picker ==== | ||
+ | ListView Control를 찾아내고 조정하는 역할을 합니다. | ||
+ | <code python control_picker.py> | ||
+ | # -*- coding: utf-8 | ||
+ | import win32gui | ||
+ | import pywintypes | ||
+ | from listview_peek import ListViewPeek | ||
+ | |||
+ | |||
+ | class ControlPicker: | ||
+ | def __init__(self, | ||
+ | self.parent_window_handle = 0 | ||
+ | self.child_windows = [] | ||
+ | |||
+ | try: | ||
+ | win32gui.EnumWindows(self.__enum_window_handler, | ||
+ | except pywintypes.error as e: | ||
+ | if e[0] == 0: | ||
+ | pass | ||
+ | |||
+ | win32gui.EnumChildWindows(self.parent_window_handle, | ||
+ | |||
+ | def __enum_window_handler(self, | ||
+ | window_text = win32gui.GetWindowText(window_handle) | ||
+ | if window_text.find(extra) != -1: | ||
+ | self.parent_window_handle = window_handle | ||
+ | return pywintypes.FALSE | ||
+ | |||
+ | def __enum_child_window_handler(self, | ||
+ | self.child_windows.append(window_handle) | ||
+ | |||
+ | def pick_control(self, | ||
+ | for child_window in self.child_windows: | ||
+ | window_class = win32gui.GetClassName(child_window) | ||
+ | control_id = win32gui.GetDlgCtrlID(child_window) | ||
+ | |||
+ | if window_class != target_class_name: | ||
+ | continue | ||
+ | |||
+ | if target_control_id: | ||
+ | if target_control_id == control_id: | ||
+ | return child_window | ||
+ | else: | ||
+ | return child_window | ||
+ | |||
+ | |||
+ | if __name__ == ' | ||
+ | import sys | ||
+ | import time | ||
+ | |||
+ | picker = ControlPicker(' | ||
+ | list_view_control = picker.pick_control(' | ||
+ | if not list_view_control: | ||
+ | print " | ||
+ | sys.exit(1) | ||
+ | |||
+ | peek = ListViewPeek(list_view_control) | ||
+ | |||
+ | print "There are %d items in the ListView control!" | ||
+ | for x in peek.get_list_items(): | ||
+ | print x | ||
+ | |||
+ | |||
+ | if peek.get_item_count() < 2: | ||
+ | print "Make sure Subrenamer has enough unmatched video lists!" | ||
+ | sys.exit(1) | ||
+ | |||
+ | pause = 5 | ||
+ | win32gui.SetActiveWindow(picker.parent_window_handle) | ||
+ | win32gui.SetForegroundWindow(list_view_control) | ||
+ | print " | ||
+ | time.sleep(pause) | ||
+ | |||
+ | peek.select_item(-1, | ||
+ | print "No item selected. %d seconds sleep..." | ||
+ | time.sleep(pause) | ||
+ | |||
+ | peek.select_item(0, | ||
+ | print "The first item selected. %d seconds sleep..." | ||
+ | time.sleep(pause) | ||
+ | |||
+ | peek.select_item(-1, | ||
+ | peek.select_item(1, | ||
+ | print "The second item selected. %d seconds sleep..." | ||
+ | time.sleep(pause) | ||
+ | |||
+ | peek.select_item(-1, | ||
+ | print "All selected. %d seconds sleep..." | ||
+ | time.sleep(pause) | ||
+ | |||
+ | peek.select_item(-1, | ||
+ | print "None selected again." | ||
+ | print " | ||
+ | |||
+ | </ | ||
+ | |||
+ | === 설명 === | ||
+ | |||
+ | {{: | ||
+ | |||
+ | 위 그림이 SubRenamer입니다. [[https:// | ||
+ | |||
+ | 이 프로그램은 동영상과 자막을 맞춰주는 프로그램입니다. [[.: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | control picker 스크립트도 subrenamer 프로그램을 상대로 제작했습니다. 스크립트를 실행하면 subrenamer 창을 찾고, 창을 가장 위로 올린 다음, 리스트 컨트롤의 항목을 선택하는 데모를 보여 줍니다. | ||
project/peekwindow.1439062005.txt.gz · 마지막으로 수정됨: 2015/08/08 19:26 저자 changwoo