root/branch/twedit/cycle_windows.py

Revision 1557, 1.8 kB (checked in by mswat, 17 months ago)

Added find in files capability

Line 
1import win32gui
2import time
3import sys
4import win32con
5import string
6
7def win_enum_callback(hwnd, results):
8    if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd) != '':
9        results.append(hwnd)
10
11def 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 
15handles])
16
17def win_enum_callback_twedit(hwnd, results):
18    # if win32gui.IsWindowVisible(hwnd) and win32gui.GetWindowText(hwnd) != 'CC3D-Twedit':
19    # if win32gui.IsWindowVisible(hwnd):
20    if str(win32gui.GetWindowText(hwnd)).count("CC3D-Twedit"):
21
22        print "GOT TWEDIT ",win32gui.GetWindowText(hwnd)
23        results.append(hwnd)
24
25
26def getTweditWindowHandle():
27    handle = []
28    win32gui.EnumWindows(win_enum_callback_twedit, handle)
29   
30    win32gui.SetForegroundWindow(handle[0])
31    # win32gui.BringWindowToTop(handle[0])
32    print "this is twedit window handle,",handle[0]
33
34def 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   
42if __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        # print_list()
51        getTweditWindowHandle()
52        # import re
53        # prog = re.compile(".*CC3D-Twedit$")
54        # print prog.match("jfhgdjf gdjhfg djkhgf kdjgk CC3D-Twedit")
55
56
57        # nameRe=re.compile('CC3D-Twedit$')
58        # print re.match('CC3D-Twedit$',"jfhgdjf gdjhfg djkhgf kdjgk CC3D-Twedit")
59       
Note: See TracBrowser for help on using the browser.