Example #1
0
 def __call__(self, data, useAlternateMethod=False, mode=2):
     hwnds = eg.lastFoundWindows
     if not hwnds:
         hwnd = None
     else:
         hwnd = hwnds[0]
     eg.SendKeys(hwnd, data, useAlternateMethod, mode)
Example #2
0
    def SendKeystrokes(self, text, useAlternateMethod=False, mode=2):
        """
        Send keystrokes to the window

        :param text: Keystrokes you want to send. Same format as the
            Send Keys Action
        :type text: str
        :param useAlternateMethod: see eg.SendKeys()
        :type useAlternateMethod: bool
        :param mode: see eg.SendKeys()
        :type mode: int
        :return: None
        :rtype: None
        """
        self.AssertAlive()
        import time
        time.sleep(0.1)
        eg.SendKeys(win32gui.GetWindow(self.hwnd, win32con.GW_CHILD), text,
                    useAlternateMethod, mode)
Example #3
0
    def state1(self, line):
        if line.startswith('c'):
            self.respond(u"RemoteGhost.Pong")
            return
        if line.startswith('e'):
            self.plugin.TriggerEvent(line[1:].strip())
            self.respond_ok()
            #self.initiate_close()
            return
        if line.startswith('a'):
            sRet = self.ExecuteMacro(line[1:].strip())
            self.respond(u"RemoteGhost." + sRet)
            return
        if line.startswith('k'):
            hwnds = eg.lastFoundWindows
            if not hwnds:
                hwnd = None
            else:
                hwnd = hwnds[0]
            sCmd = line[1:]
            print(u'ORCA: Sending Keystroke:' + sCmd)
            eg.SendKeys(hwnd, sCmd, False)
            self.respond_ok()
            return
        if line.startswith('m'):
            sCmd = line[1:]
            if sCmd == '{Mouse_Left_Click}':
                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
                self.respond_ok()
                return
            if sCmd == '{Mouse_Right_Click}':
                win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0,
                                     0)
                win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
                self.respond_ok()
                return

        self.respond_error()
        print(u'ORCA:Received invalid statement:' + line)
Example #4
0
    def __call__(self):
        # Get the window handle (HWND) of the PowerDVD main window and the HWND of the PowerDVD player window.
        #     When PowerDVD is running, the main window is not hidden and always has an HWND.
        #     The player window is hidden and only exists when playback has begun.
        # Combine the two lists, the main window being the first entry.
        # If the list is empty, raise an error.
        # Else, send the key stroke to the last element in the list
        # (i.e., to the player window when playback has begun, else to the main window).
        #
        # This also works when PowerDVD is running in the background.
        #
        #
        # AutoHotKey searches HWNDs differently, requiring only two lines of code to find the window
        # and sending a key to it (also works when PowerDVD is in the background).
        # AHK code for toggling play/pause:
        #     ControlGet, OutputVar, Hwnd,,, PowerDVD
        #     ControlSend, , {space}, ahk_id %OutputVar%

        hwnds = []

        # Main window
        hwndMainWindow = ctypes.windll.user32.FindWindowA(None, "PowerDVD")
        if hwndMainWindow:
            hwnds.append(hwndMainWindow)

        # Player window
        if hwndMainWindow:
            hwndPlayerWindow = ctypes.windll.user32.FindWindowExA(
                hwndMainWindow, 0, 0, 0)
            if hwndPlayerWindow:
                hwnds.append(hwndPlayerWindow)

        if hwnds:
            eg.SendKeys(hwnds[-1], self.value)
        else:
            raise self.Exceptions.ProgramNotRunning
Example #5
0
 def __call__(self):
     hwnds = gWindowMatcher()
     if hwnds:
         eg.SendKeys(hwnds[0], self.value)
     else:
         raise self.Exceptions.ProgramNotRunning