|
Revision 1557, 1.8 kB
(checked in by mswat, 17 months ago)
|
|
Added find in files capability
|
| Line | |
|---|
| 1 | import win32gui |
|---|
| 2 | import time |
|---|
| 3 | import sys |
|---|
| 4 | import win32con |
|---|
| 5 | import string |
|---|
| 6 | |
|---|
| 7 | def win_enum_callback(hwnd, results): |
|---|
| 8 | if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd) != '': |
|---|
| 9 | results.append(hwnd) |
|---|
| 10 | |
|---|
| 11 | def print_list(): |
|---|
| 12 | handles = [] |
|---|
| 13 | win32gui.EnumWindows(win_enum_callback, handles) |
|---|
| 14 | print '\n'.join(['%d\t%s' % (h, win32gui.GetWindowText(h)) for h in |
|---|
| 15 | handles]) |
|---|
| 16 | |
|---|
| 17 | def win_enum_callback_twedit(hwnd, results): |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | if str(win32gui.GetWindowText(hwnd)).count("CC3D-Twedit"): |
|---|
| 21 | |
|---|
| 22 | print "GOT TWEDIT ",win32gui.GetWindowText(hwnd) |
|---|
| 23 | results.append(hwnd) |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | def getTweditWindowHandle(): |
|---|
| 27 | handle = [] |
|---|
| 28 | win32gui.EnumWindows(win_enum_callback_twedit, handle) |
|---|
| 29 | |
|---|
| 30 | win32gui.SetForegroundWindow(handle[0]) |
|---|
| 31 | |
|---|
| 32 | print "this is twedit window handle,",handle[0] |
|---|
| 33 | |
|---|
| 34 | def cycle_foreground(): |
|---|
| 35 | handles = [] |
|---|
| 36 | win32gui.EnumWindows(win_enum_callback, handles) |
|---|
| 37 | for handle in handles: |
|---|
| 38 | print handle, win32gui.GetWindowText(handle) |
|---|
| 39 | win32gui.SetForegroundWindow(handle) |
|---|
| 40 | time.sleep(2.0) |
|---|
| 41 | |
|---|
| 42 | if __name__ == '__main__': |
|---|
| 43 | if len(sys.argv) == 2 and sys.argv[1] == 'cycle': |
|---|
| 44 | cycle_foreground() |
|---|
| 45 | sys.exit(0) |
|---|
| 46 | |
|---|
| 47 | if len(sys.argv) == 2: |
|---|
| 48 | win32gui.SetForegroundWindow(int(sys.argv[1])) |
|---|
| 49 | else: |
|---|
| 50 | |
|---|
| 51 | getTweditWindowHandle() |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | |
|---|
| 59 | |
|---|