예제 #1
0
    def testClickHiddenIcon(self):
        """
        Test minimizing a sample app into the hidden area of the tray
        and restoring the app back
        """

        if is_x64_Python() != is_x64_OS():
            # We don't run this test for mixed cases:
            # a 32-bit Python process can't interact with
            # a 64-bit explorer process (taskbar) and vice versa
            return

        # Make sure that the hidden icons area is enabled
        orig_hid_state = _toggle_notification_area_icons(
                show_all=False,
                debug_img="%s_01" % (self.id())
                )

        self.dlg.Minimize()
        _wait_minimized(self.dlg)

        # Run one more instance of the sample app
        # hopefully one of the icons moves into the hidden area
        app2 = Application()
        app2.start(os.path.join(mfc_samples_folder, u"TrayMenu.exe"))
        dlg2 = app2.top_window_()
        dlg2.Wait('visible', timeout=self.tm)
        dlg2.Minimize()
        _wait_minimized(dlg2)

        # Click in the hidden area
        taskbar.explorer_app.WaitCPUUsageLower(threshold=5, timeout=40)
        taskbar.ClickHiddenSystemTrayIcon('MFCTrayDemo', double=True)
        self.dlg.Wait('visible', timeout=self.tm)

        # Restore Notification Area settings
        _toggle_notification_area_icons(show_all=orig_hid_state,
                                        debug_img="%s_02" % (self.id()))

        dlg2.SendMessage(win32defines.WM_CLOSE)
예제 #2
0
-*- coding: utf-8 -*-


from pywinauto import Application
import SendKeys
import time
from PIL import ImageGrab
from pywinauto import taskbar


app = Application().connect(path=r'C:\Program Files (x86)\TeamViewer\TeamViewer.exe')


taskbar.ClickHiddenSystemTrayIcon("会话管理", exact=True, double=True)


taskbar.SystemTrayIcons.Texts()

app.Maximize()

top_dlg = app.window(title="TeamViewer")
top_dlg.Maximize()
#
top_dlg.Minimize()
top_dlg.Restore()
#
top_dlg.type_keys("123")
#
time.sleep(1)
#
im = ImageGrab.grab()