예제 #1
0
def _get_tooltip_handles(hwnd, resultList):
    '''
    Adds a window handle to resultList if its class-name is 'tooltips_class32',
    i.e. the window is a tooltip.
    '''
    if GetClassName(hwnd) == TOOLTIPS_CLASS:
        resultList.append(hwnd)
 def __call__(self, only_sel=False):
     self.only_sel = only_sel
     res = []
     for hwnd in GetTargetWindows():
         if not IsWindow(hwnd):
             self.PrintError("Not a window")
             continue
         clsName = GetClassName(hwnd)
         if not IsChild(GetParent(hwnd),
                        hwnd) or clsName in win32_ctrls['statics']:
             val = eg.WinApi.GetWindowText(hwnd)
         elif clsName in win32_ctrls['edits']:
             val = self.getEditText(hwnd)
         elif clsName in win32_ctrls['combos']:
             val = self.getComboboxItems(hwnd)
         elif clsName in win32_ctrls['listboxes']:
             val = self.getListboxItems(hwnd)
         elif clsName in win32_ctrls['listviews']:
             val = self.getListViewItems(hwnd)
         elif match_cls(clsName, win32_ctrls['statusbars']):
             val = self.getStatusBarItems(hwnd)
         else:
             val = None
         res.append(val)
     return res
예제 #3
0
def show_window_attr(hWnd):
    '''
    显示窗口的属性
    :return:
    '''
    if not hWnd:
        return

    # 中文系统默认title是gb2312的编码
    title = GetWindowText(hWnd)
    clsname = GetClassName(hWnd)

    print('窗口句柄:%x ' % (hWnd))
    print('窗口标题:%s' % (title))
    print('窗口类名:%s' % (clsname))
    print()
    def add_window_to_event(event):
        assert isinstance(event, dict)
        window = getActiveWindow()
        if window:
            event["window"] = {
                "title": window.title,
                "class_name": GetClassName(window._hWnd),
                "top": window.top,
                "left": window.left,
                "width": window.width,
                "height": window.height
            }

            # print(window.title)
        else:
            event["window"] = None
        return event
예제 #5
0
def OnMouseEvent(event):
    print("On Mouse Event ")
    Log('MessageName:' + str(event.MessageName))
    Log('Message:' + str(event.Message))
    Log('Time:' + str(event.Time))
    Log('Window:' + str(event.Window))
    if event.Window != 0:
        Log('Window Rect:' + str(GetWindowRect(event.Window)))
        Log('Window Class Name:' + str(GetClassName(event.Window)))
        #Log('Window Text:' + str( GetWindowText(event.Window)))
        Log('WindowName:' + str(event.WindowName))
        Log('Position:' + str(event.Position))
        Log('Wheel:' + str(event.Wheel))
        Log('Injected:' + str(event.Injected))
        Log('---')

        # return True to pass the event to other handlers
        # return False to stop the event from propagating
    return True
예제 #6
0
    def examine_wind(hwnd, *args):
        """ examines a window title accordingly to program tokens """
        del args
        if Main.running:
            window_title = GetWindowText(hwnd).decode('cp1252')
            window_class = GetClassName(hwnd).decode('cp1252')
            title = ''

            # If the selected program is in class Misc
            # Set title to what the function returns
            if Main.selectedProgram in ProgramToken.MiscFunctions:
                title = ProgramToken.MiscFunctions[Main.selectedProgram]()

            # if the selected program is a webapp
            elif Main.selectedProgram in ProgramToken.WebappFunctions.keys():
                for browser in ProgramToken.WebbrowserFunctions.values():
                    # a token returns Text if true or False if not true.
                    browser_title = browser(window_title, window_class)
                    # if the currently iterated browser is apparent
                    if browser_title:
                        # if the currently iterated webapp is apparent
                        title = ProgramToken.WebappFunctions\
                            [Main.selectedProgram](browser_title)

            # if the selected program is a standalone program
            elif Main.selectedProgram in ProgramToken.ProgramFunctions.keys():
                title = ProgramToken.ProgramFunctions[Main.selectedProgram]\
                    (window_title, window_class)

            oldtitle = Wr.read()
            # title is set to false if nothing could be found.
            if title:
                # oldtitle is <type 'str'>, title is <type 'unicode'>
                # so I had to decode oldtitle
                if not title == oldtitle.decode('utf-8'):
                    if Constants.OPTIONS['splitText']:
                        firsthalf = title[:int(len(title) / 2)]
                        title = firsthalf
                    Wr.write(title)
                    Constants.UI.set_playing(title)
예제 #7
0
def OnKeyboardEvent(event):
    print("On keyboard Event ")
    Log('MessageName:' + str(event.MessageName))
    Log('Message:' + str(event.Message))
    Log('Time:' + str(event.Time))
    Log('Window:' + str(event.Window))
    if event.Window != 0:
        Log('Window Rect:' + str(GetWindowRect(event.Window)))
        Log('Window Class Name:' + str(GetClassName(event.Window)))
        Log('Window Text:' + str(GetWindowText(event.Window)))
        Log('WindowName:' + str(event.WindowName))
        Log('Ascii:' + str(event.Ascii) + str(chr(event.Ascii)))
        Log('Key:' + str(event.Key))
        Log('KeyID:' + str(event.KeyID))
        Log('ScanCode:' + str(event.ScanCode))
        Log('Extended:' + str(event.Extended))
        Log('Injected:' + str(event.Injected))
        Log('Alt' + str(event.Alt))
        Log('Transition' + str(event.Transition))
        Log('---')

    # return True to pass the event to other handlers
    # return False to stop the event from propagating
    return True
예제 #8
0
 def foo(hwnd,mouse):
  #去掉下面这句就所有都输出了,但是我不需要那么多
  if IsWindow(hwnd) and IsWindowEnabled(hwnd) and IsWindowVisible(hwnd):
      if(GetClassName(hwnd) == class_name):     titles.add(hwnd)
예제 #9
0
파일: index.py 프로젝트: ennache/Rigel
 def exec(self, *args):
     ShellWindows = Dispatch(ShellWindowsCLSID)
     for x in ShellWindows:
         print(GetClassName(x.HWND), x)
예제 #10
0
 def _handler(hwnd, results):
     results.append((hwnd, GetWindowText(hwnd), GetClassName(hwnd)))
예제 #11
0
 def callback(handle, data):
     title = GetWindowText(handle)
     classname = GetClassName(handle)
     if title:
         titles[handle] = (title, classname)
예제 #12
0
from win32com . client import Dispatch 
from win32gui import GetClassName

ShellWindowsCLSID = '{9BA05972-F6A8-11CF-A442-00A0C90A8F39}'
ShellWindows = Dispatch ( ShellWindowsCLSID )

for shellwindow in ShellWindows :
    if GetClassName ( shellwindow . HWND ) == 'IEFrame' :
        print shellwindow 
        print shellwindow . LocationName
        print shellwindow . LocationURL
        print 50 * '-'
예제 #13
0
def enumWinProc(h, lparams):

    if GetClassName(h) == 'ExploreWClass':
        lparams.append(h)