Exemplo n.º 1
0
    def OnCommand(self, hwnd, msg, wparam, lparam):
        FolderSelector_Parent.OnCommand(self, hwnd, msg, wparam, lparam)
        id = win32api.LOWORD(wparam)
        id_name = self._GetIDName(id)
        code = win32api.HIWORD(wparam)

        if code == win32con.BN_CLICKED:
            if id in (win32con.IDOK, win32con.IDCANCEL) and self.in_label_edit:
                cancel = id == win32con.IDCANCEL
                win32gui.SendMessage(self.list, commctrl.TVM_ENDEDITLABELNOW,
                                     cancel, 0)
                return
            # Button clicks
            if id == win32con.IDOK:
                if not self._CheckSelectionsValid(True):
                    return
                self.selected_ids, self.checkbox_state = self.GetSelectedIDs()
                win32gui.EndDialog(hwnd, id)
            elif id == win32con.IDCANCEL:
                win32gui.EndDialog(hwnd, id)
            elif id_name == "IDC_BUT_CLEARALL":
                for info, spec in self._YieldCheckedChildren():
                    self.UnselectItem(info)
            elif id_name == "IDC_BUT_NEW":
                # Force a new entry in the tree at our location, and begin
                # editing.
                # Add the new item to the tree.
                h = win32gui.SendMessage(self.list, commctrl.TVM_GETNEXTITEM,
                                         commctrl.TVGN_CARET,
                                         commctrl.TVI_ROOT)
                parent_item = self._GetTVItem(h)
                if parent_item[6] == 0:
                    # eeek - parent has no existig children - say we have one
                    # so we can be expanded.
                    update_item, extra = PackTVITEM(h, None, None, None, None,
                                                    None, 1, None)
                    win32gui.SendMessage(self.list, commctrl.TVM_SETITEM, 0,
                                         update_item)

                item_id = self._MakeItemParam(None)
                temp_spec = FolderSpec(None, "New folder")
                hnew = self._InsertFolder(h, temp_spec, None,
                                          commctrl.TVI_FIRST)

                win32gui.SendMessage(self.list, commctrl.TVM_ENSUREVISIBLE, 0,
                                     hnew)
                win32gui.SendMessage(self.list, commctrl.TVM_SELECTITEM,
                                     commctrl.TVGN_CARET, hnew)

                # Allow label editing
                s = win32api.GetWindowLong(self.list, win32con.GWL_STYLE)
                s |= commctrl.TVS_EDITLABELS
                win32api.SetWindowLong(self.list, win32con.GWL_STYLE, s)

                win32gui.SetFocus(self.list)
                self.in_label_edit = True
                win32gui.SendMessage(self.list, commctrl.TVM_EDITLABEL, 0,
                                     hnew)

        self._UpdateStatus()
Exemplo n.º 2
0
def showTweditWindowInForeground1():
    # documentaiton of win32con window flags and win32gui showWindow functions

    # style=win32con.SW_SHOWNORMAL : int

    # Specifies how the window is to be shown. It must be one of win32con.SW_HIDE, win32con.SW_MINIMIZE,
    # win32con.SW_RESTORE, win32con.SW_SHOW, win32con.SW_SHOWMAXIMIZED win32con.SW_SHOWMINIMIZED, win32con.
    # SW_SHOWMINNOACTIVE, win32con.SW_SHOWNA, win32con.SW_SHOWNOACTIVATE, or win32con.SW_SHOWNORMAL

    import win32gui
    import win32con

    handle = []

    win32gui.EnumWindows(win_enum_callback_twedit, handle)

    if len(handle):
        # win32gui.SetForegroundWindow(handle[0])

        win32gui.SetActiveWindow(handle[0])

        win32gui.BringWindowToTop(handle[0])

        win32gui.SetFocus(handle[0])

        win32gui.ShowWindow(handle[0], win32con.SW_RESTORE)
Exemplo n.º 3
0
def get_new_desktop_name(parent_hwnd):
    """ Create a dialog box to ask the user for name of desktop to be created """
    msgs = {
        win32con.WM_COMMAND: desktop_name_dlgproc,
        win32con.WM_CLOSE: desktop_name_dlgproc,
        win32con.WM_DESTROY: desktop_name_dlgproc
    }
    # dlg item [type, caption, id, (x,y,cx,cy), style, ex style
    style = win32con.WS_BORDER | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU  ## |win32con.DS_SYSMODAL
    h = win32gui.CreateDialogIndirect(win32api.GetModuleHandle(None), [
        ['One ugly dialog box !', (100, 100, 200, 100), style, 0],
        [
            'Button', 'Create', win32con.IDOK,
            (10, 10, 30, 20), win32con.WS_VISIBLE | win32con.WS_TABSTOP
            | win32con.BS_HOLLOW | win32con.BS_DEFPUSHBUTTON
        ],
        [
            'Button', 'Never mind', win32con.IDCANCEL, (45, 10, 50, 20),
            win32con.WS_VISIBLE | win32con.WS_TABSTOP | win32con.BS_HOLLOW
        ],
        ['Static', 'Desktop name:', 71, (10, 40, 70, 10), win32con.WS_VISIBLE],
        ['Edit', '', 72, (75, 40, 90, 10), win32con.WS_VISIBLE]
    ], parent_hwnd, msgs)  ## parent_hwnd, msgs)

    win32gui.EnableWindow(h, True)
    hcontrol = win32gui.GetDlgItem(h, 72)
    win32gui.EnableWindow(hcontrol, True)
    win32gui.SetFocus(hcontrol)
Exemplo n.º 4
0
    def _on_focus_object_changed(self, focus_object: QObject):
        """
        Args:
            QObject focus_object: Object to track focus change
        """

        if focus_object is self.blender_widget:
            win32gui.SetFocus(self._hwnd)
Exemplo n.º 5
0
    def set_focus(self):
        '''put the focus on the new window'''
        win32gui.SetFocus(self._handle)


# w = WindowMgr()
# w.find_window_wildcard("PowerChart")
# w.set_foreground()
Exemplo n.º 6
0
 def Focus(self):
     """
     Makes the window in focus.
     :return: None
     :rtype: None
     """
     self.AssertAlive()
     win32gui.SetFocus(self.hwnd)
Exemplo n.º 7
0
def p_w(hwnd, param):
    print(win32gui.GetWindowText(hwnd), win32gui.GetClassName(hwnd))
    if win32gui.GetClassName(hwnd) == "Edit":
        win32gui.SetForegroundWindow(hwnd)
        win32gui.SetFocus(hwnd)

    # print(win32gui.GetClassName(hwnd))
    return True
Exemplo n.º 8
0
 def set_focus_window(hwnd):
     """Within current thread
 @param  hwnd  HWND
 """
     try:
         return bool(win32gui.SetFocus(hwnd))
     except:
         return False
Exemplo n.º 9
0
    def __init__(self):
        self.renderer = self.batch = None

        pygame.init()
        info_obj = pygame.display.Info()
        self.WIDTH, self.HEIGHT = info_obj.current_w, info_obj.current_h
        self.screen = pygame.display.set_mode(
            (self.WIDTH, self.HEIGHT),
            pygame.OPENGL | pygame.DOUBLEBUF | pygame.NOFRAME)

        self.hwnd = pygame.display.get_wm_info()["window"]
        win32gui.SetFocus(self.hwnd)
        win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0,
                              win32con.SWP_NOMOVE | win32con.SWP_NOSIZE)
        win32gui.ShowWindow(self.hwnd, win32con.SW_HIDE)

        self.clock = pygame.time.Clock()
        self.skeletons = []

        self._sprites = []
        self._sprite_index = -1
        root = '../asset_ripper/extracted/'

        for i in ['c08020', 'c00090', 'c08060', 'c08000']:  #os.listdir(root):
            #for i in ['c08020']:#os.listdir(root):
            atlas = atlas_map = spine = None

            for j in os.listdir(root + i + '/tex2d'):
                if not j.startswith('root'):
                    continue
                pth = os.path.join(root, i, 'tex2d', j)
                s = os.path.getsize(pth)
                if atlas is None or s > atlas[0]:
                    im = pygame.image.load(pth)
                    if im.get_size() in ((1024, 1024), (2048, 2048)):
                        continue
                    atlas = (s, pth)

            if not os.path.exists(root + i + '/text'):
                continue
            for j in os.listdir(root + i + '/text'):
                if not j.startswith('root'):
                    continue
                pth = os.path.join(root, i, 'text', j)
                s = os.path.getsize(pth)
                if j.startswith('root.atlas'):
                    if atlas_map is None or s > atlas_map[0]:
                        atlas_map = (s, pth)
                else:
                    if spine is None or s > spine[0]:
                        spine = (s, pth)

            if spine is None or atlas_map is None or atlas is None:
                print('Failed to find assets for', i)
                continue
            self._sprites.append((atlas[1], atlas_map[1], spine[1]))
        #random.shuffle(self._sprites)
        self.next_sprite()
Exemplo n.º 10
0
    def on_close(self, evt):
        """
		Event handler for EVT_CLOSE event.
		"""
        self.Show(False)
        self.Destroy()
        win32gui.DestroyWindow(self.GetHandle())

        # Regular wx Destroy waits for the application to destroy the window.
        # Since there is no wxApp running, we do it ourselves.
        win32gui.SetFocus(MB_Sub_Frame._top_mb_window_handle)
Exemplo n.º 11
0
    def show(self):
        # Show main window
        win32gui.ShowWindow(self.hwnd, win32con.SW_SHOWNORMAL)
        win32gui.UpdateWindow(self.hwnd)

        # Show AtlAx window
        win32gui.ShowWindow(self.atlhwnd, win32con.SW_SHOW)
        win32gui.UpdateWindow(self.atlhwnd)
        win32gui.SetFocus(self.atlhwnd)

        # Pump messages
        win32gui.PumpMessages()
Exemplo n.º 12
0
    def show(self):
        # Show main window
        win32gui.SetWindowPos(self.hwnd, win32con.HWND_TOP, self.pos_x,
                              self.pos_y, self.width, self.height,
                              win32con.SWP_SHOWWINDOW)
        win32gui.ShowWindow(self.hwnd, win32con.SW_SHOWNORMAL)
        win32gui.UpdateWindow(self.hwnd)

        # Show AtlAx window
        win32gui.ShowWindow(self.atlhwnd, win32con.SW_SHOW)
        win32gui.UpdateWindow(self.atlhwnd)
        win32gui.SetFocus(self.atlhwnd)

        # Pump messages
        win32gui.PumpMessages()
Exemplo n.º 13
0
    def show(self):
        # Show main window
        win32gui.ShowWindow(self.hwnd, win32con.SW_SHOWNORMAL)
        win32gui.UpdateWindow(self.hwnd)

        # Show AtlAx window
        win32gui.ShowWindow(self.atlhwnd, win32con.SW_SHOW)
        win32gui.UpdateWindow(self.atlhwnd)
        win32gui.SetFocus(self.atlhwnd)

        # Load URL here instead in CreateWindow to prevent a dead-lock
        self.browser.Navigate2(self.url)

        # Start sending and receiving messages
        win32gui.PumpMessages()
Exemplo n.º 14
0
    def show(self):
        # Show main window
        win32gui.ShowWindow(self.hwnd, win32con.SW_SHOWNORMAL)
        win32gui.UpdateWindow(self.hwnd)

        # Show AtlAx window
        win32gui.ShowWindow(self.atlhwnd, win32con.SW_SHOW)
        win32gui.UpdateWindow(self.atlhwnd)
        win32gui.SetFocus(self.atlhwnd)

        # Pump messages
        msg = MSG()
        pMsg = pointer(msg)

        while _user32.GetMessageW(pMsg, None, 0, 0) != 0:
            _user32.TranslateMessage(pMsg)
            _user32.DispatchMessageW(pMsg)

        return msg.wParam
Exemplo n.º 15
0
def set_focus_window(hdl):
    '''
    Set the game window to focus and then we can do next jobs.
    '''
    tid, pid = win32process.GetWindowThreadProcessId(hdl)
    m_tid = win32api.GetCurrentThreadId()

    try:
        win32process.AttachThreadInput(m_tid, tid, -1)
        win32gui.BringWindowToTop(hdl)
        shell = win32com.client.Dispatch('WScript.Shell')
        shell.SendKeys('%')

        win32gui.SetForegroundWindow(hdl)
        win32gui.SetFocus(hdl)
    except Exception as e:
        print(e)
        print('Can not set focus')
    win32process.AttachThreadInput(m_tid, tid, 0)
Exemplo n.º 16
0
    def set_foreground(self):

        try:
            foreground_one = win32gui.GetForegroundWindow()
            if foreground_one != self._hwnd:
                # if KILL_THE_ENEMY:  # @todo quizas una lista blanca de procesos
                #     sleep(TIME_WAIT_AFTER_KILLING)
                #     win32gui.PostMessage(foreground_one, win32con.WM_CLOSE, 0, 0)

                self._logger.info("checking foreground: {}".format(
                    "Hay un Usurpador, un vampiro digital"))
                self.maximize_window()
                #shell = win32com.client.Dispatch("WScript.Shell")
                #shell.SendKeys('%')
                win32gui.SetForegroundWindow(self._hwnd)
                win32gui.SetActiveWindow(self._hwnd)
                win32gui.SetFocus(self._hwnd)
                self.window_features()  # refresh dims

        except Exception as e:
            self._logger.error("set_foreground exception -> ".format(e))
Exemplo n.º 17
0
def maximize_window(window_title):
    '''
    Sets focus to window and maximizes window size.

    Parameters
    ----------
    window_title : String
	    Window title.

    Returns
    ----------
    Boolean
	    True for success, False otherwise.
    '''
    hwnd = _get_window_hwnd(window_title)
    if hwnd is not None:
        win32gui.SetForegroundWindow(hwnd)
        win32gui.SetFocus(hwnd)
        return True
    else:
        return False
Exemplo n.º 18
0
        def wndproc(hwnd, msg, wParam, lParam):
            # FIXME: not print()ing in wndproc mysteriously cause "OSError: exception: access violation"
            print("MW: %08x %08x %08x" % (msg, wParam, lParam))
            if msg == win32con.WM_COMMAND and win32api.HIWORD(
                    wParam) == win32con.EN_CHANGE:
                text = win32gui.GetWindowText(self.hwnd_edit)
                if len(text) == 0: return 0
                proposals = self.cmds.proposals(text)
                if not proposals:
                    return 0
                win32gui.SetWindowText(self.hwnd_edit, proposals[0])
                win32api.SendMessage(self.hwnd_edit, win32con.EM_SETSEL,
                                     len(text), -1)

            if msg == win32con.WM_SETFOCUS:
                win32gui.SetFocus(self.hwnd_edit)
            windll.user32.DefWindowProcW.argtypes = (ctypes.wintypes.HWND,
                                                     ctypes.wintypes.UINT,
                                                     ctypes.wintypes.WPARAM,
                                                     ctypes.wintypes.LPARAM)
            return windll.user32.DefWindowProcW(hwnd, msg, wParam, lParam)
Exemplo n.º 19
0
    def set_property(self, element, propertyName, value):
        validProperties = ['TEXT', 'FOCUS', 'ACTIVE']
        name = propertyName.upper()
        if name not in validProperties:
            raise ValueError('%s not supported!' % name)
        if name == 'FOCUS' and value is True:
            current_id = win32api.GetCurrentThreadId()
            target_id = win32process.GetWindowThreadProcessId(element)[0]
            win32process.AttachThreadInput(target_id, current_id, True)
            win32gui.SetFocus(element)
            win32process.AttachThreadInput(target_id, current_id, False)
        elif name == 'TEXT':
            pass
        elif name == 'active' and value is True:
            fwnd = win32gui.GetForegroundWindow()
            if fwnd == element:
                return
            if fwnd == 0:
                try:
                    win32gui.SetForegroundWindow(element)
                    return
                except win32api.error:
                    # 防止有菜单弹出导致异常
                    Keyboard.input_keys('{ESC}')
                    win32gui.SetForegroundWindow(element)
                    return

            ftid, _ = win32process.GetWindowThreadProcessId(fwnd)
            wtid, _ = win32process.GetWindowThreadProcessId(element)

            ctypes.windll.user32.AttachThreadInput(wtid, ftid, True)
            st = time.time()
            while (time.time() - st) < 5:
                if win32gui.GetForegroundWindow() == element:
                    break
                ctypes.windll.user32.SetForegroundWindow(element)
                time.sleep(0.5)

            ctypes.windll.user32.AttachThreadInput(wtid, ftid, False)
Exemplo n.º 20
0
    def switch_active_monitor(self, show_cam=False, show_spf=False):
        # Webcam setup
        cap = cv2.VideoCapture(0)
        cap_width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
        cap_height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
        width_factor = cap_width / self.width
        height_factor = cap_height / self.height

        # Get monitors' IDs
        p_mon_id = int(win32api.EnumDisplayMonitors()[0][0])
        s_mon_id = int(win32api.EnumDisplayMonitors()[1][0])

        # Get thread's ID
        cur_thread_id = win32api.GetCurrentThreadId()

        with tf.Session() as sess:
            init = tf.global_variables_initializer()
            sess.run(init)
            saver = tf.train.Saver()
            save_dir = "checkpoints"
            save_path = os.path.join(save_dir, "model.ckpt")
            saver.save(sess, save_path)
            flag, frame = cap.read()

            while flag:
                if show_spf:
                    startime = time.time()

                orig_image = frame
                frame = cv2.resize(frame, (self.width, self.height))
                frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
                frame = frame.astype(float)
                frame = frame * (2.0 / 255.0) - 1.0
                frame = np.array(frame, dtype=np.float32)
                frame = frame.reshape(1, self.width, self.height, 3)
                (
                    heatmaps_result,
                    offsets_result,
                    displacementFwd_result,
                    displacementBwd_result,
                ) = sess.run(
                    [
                        self.heatmaps,
                        self.offsets,
                        self.displacementFwd,
                        self.displacementBwd,
                    ],
                    feed_dict={self.image: frame},
                )
                poses = decode_single_pose(heatmaps_result, offsets_result, 16,
                                           width_factor, height_factor)

                if show_spf:
                    endtime = time.time()
                    print("Time cost per frame : %f" % (endtime - startime))

                # Calculate the distance between nose and shoulders
                nose_pos = poses[0]["keypoints"][0]["position"]
                nose_pos_array = np.array((nose_pos["x"], nose_pos["y"]))
                lshoulder_pos = poses[0]["keypoints"][5]["position"]
                lshoulder_pos_array = np.array(
                    (lshoulder_pos["x"], lshoulder_pos["y"]))
                rshoulder_pos = poses[0]["keypoints"][6]["position"]
                rshoulder_pos_array = np.array(
                    (rshoulder_pos["x"], rshoulder_pos["y"]))
                ldiff = nose_pos_array - lshoulder_pos_array
                ldist = np.linalg.norm(ldiff)
                rdiff = nose_pos_array - rshoulder_pos_array
                rdist = np.linalg.norm(rdiff)

                # Get active monitor's ID
                win_id = win32gui.GetForegroundWindow()
                act_mon_id = int(win32api.MonitorFromWindow(win_id, 2))

                if act_mon_id == p_mon_id:
                    if win_id != 0:
                        p_mon_win = win_id

                    if rdist < ldist:
                        try:
                            win_thread_id, _ = win32process.GetWindowThreadProcessId(
                                s_mon_win)
                            win32process.AttachThreadInput(
                                cur_thread_id, win_thread_id, True)
                            win32gui.SetFocus(s_mon_win)
                            win32gui.SetForegroundWindow(s_mon_win)

                        except Exception:
                            pass

                elif act_mon_id == s_mon_id:
                    if win_id != 0:
                        s_mon_win = win_id

                    if rdist >= ldist:
                        try:
                            win_thread_id, _ = win32process.GetWindowThreadProcessId(
                                p_mon_win)
                            win32process.AttachThreadInput(
                                cur_thread_id, win_thread_id, True)
                            win32gui.SetFocus(p_mon_win)
                            win32gui.SetForegroundWindow(p_mon_win)

                        except Exception:
                            pass

                else:
                    raise Exception()

                if show_cam:
                    for i, _ in enumerate(poses):
                        if poses[i]["score"] > 0.2:
                            color = self.color_table[i]
                            drawKeypoints(poses[i], orig_image, color)
                            drawSkeleton(poses[i], orig_image)

                    cv2.imshow("1", orig_image)

                cv2.waitKey(1)
                flag, frame = cap.read()
Exemplo n.º 21
0
 def SaveAllControls(self):
     for p in self.all_processors:
         if not self.ApplyHandlingOptionValueError(p.Done):
             win32gui.SetFocus(p.GetControl())
             return False
     return True
Exemplo n.º 22
0
 def focus(self):
     win32gui.ShowWindow(self._hwnd, 1)
     win32gui.SetForegroundWindow(self._hwnd)
     win32gui.SetFocus(self._hwnd)
Exemplo n.º 23
0
 def login(self):
     win32gui.SetFocus(int(self.winId()))
     t = threading.Thread(target=self.loginThread, name="loginThread")
     t.start()
Exemplo n.º 24
0
 def verifi(self):
     win32gui.SetFocus(int(self.winId()))
     t = threading.Thread(target=self.verifiThread, name="verifiThread")
     t.start()
Exemplo n.º 25
0
 def SetFocus(self):
     win32gui.SetFocus(self._hwnd)
Exemplo n.º 26
0
    def __call__(self, ensoapi, window=None):
        if window is None:
            return None
        logging.debug("Go to window '%s'" % window)
        for hwnd, title in self.windows:
            title = xml.sax.saxutils.escape(title).lower()
            if title == window:
                try:
                    dwCurrentThread = win32api.GetCurrentThreadId()

                    [dwFGThread, _] = win32process.GetWindowThreadProcessId(
                        win32gui.GetForegroundWindow())
                    #                    [dwTGThread, _] = win32process.GetWindowThreadProcessId(hwnd)

                    ctypes.windll.user32.AttachThreadInput(
                        dwCurrentThread, dwFGThread, 1)
                    try:
                        if win32gui.IsIconic(hwnd):
                            win32gui.ShowWindow(hwnd, win32con.SW_RESTORE)

                        win32gui.SetWindowPos(
                            hwnd, win32con.HWND_NOTOPMOST, 0, 0, 0, 0,
                            win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)
                        win32gui.SetWindowPos(
                            hwnd, win32con.HWND_TOPMOST, 0, 0, 0, 0,
                            win32con.SWP_NOMOVE + win32con.SWP_NOSIZE)
                        win32gui.SetWindowPos(
                            hwnd, win32con.HWND_NOTOPMOST, 0, 0, 0, 0,
                            win32con.SWP_SHOWWINDOW + win32con.SWP_NOMOVE +
                            win32con.SWP_NOSIZE)

                        try:
                            win32gui.SetForegroundWindow(hwnd)
                        except Exception as e:
                            print(e)

                        try:
                            win32gui.SetActiveWindow(hwnd)
                        except Exception as e:
                            print(e)

                        try:
                            win32gui.SetFocus(hwnd)
                        except Exception as e:
                            print(e)

                    finally:
                        ctypes.windll.user32.AttachThreadInput(
                            dwCurrentThread, dwFGThread, 0)

                except Exception as e:
                    print(e)
                    if e[0] == 0:
                        time.sleep(0.2)
                        try:
                            win32gui.SetForegroundWindow(hwnd)
                        except Exception as e:
                            time.sleep(0.2)
                            try:
                                win32gui.BringWindowToTop(hwnd)
                            except Exception as e:
                                pass
                    elif e[0] == 2:
                        pass
                break
        return hwnd
Exemplo n.º 27
0
    def OnTaskbarNotify(self, hwnd, msg, wparam, lparam):
        if lparam == win32con.WM_LBUTTONUP:
            pass
        elif lparam == win32con.WM_LBUTTONDBLCLK:
            self.OnCommand(hwnd, win32con.WM_COMMAND, self.MENU_OPEN_CLAM, 0)
        elif lparam == win32con.WM_RBUTTONUP:
            if self._nomenu:
                hwnd = win32gui.FindWindow('#32770', 'Blindata Update')
                if hwnd:
                    try:
                        win32gui.ShowWindow(hwnd, win32con.SW_SHOW)
                        win32gui.SetForegroundWindow(hwnd)
                        win32gui.SetFocus(hwnd)
                    except Exception, e:
                        print 'ShowWindow Error: %s' % str(e)
                return 1

            # create scheduler menu
            scheduler_popup = win32gui.CreatePopupMenu()
            win32gui.AppendMenu(scheduler_popup, win32con.MF_STRING,
                                self.MENU_CONFIGURESCHEDULER,
                                "&Configure Scheduler")

            if not self._processes:
                flags = win32con.MF_GRAYED
            else:
                flags = 0

            # create scheduled tasks menu
            tasks_popup = win32gui.CreatePopupMenu()
            i = 0
            for scan in self._scheduledScans:
                win32gui.AppendMenu(tasks_popup, win32con.MF_STRING,
                                    self.MENU_RUNSCHEDULE + i,
                                    scan.Description)
                i += 1
            if not i:
                flags2 = win32con.MF_GRAYED
            else:
                flags2 = 0
            win32gui.InsertMenu(
                scheduler_popup, self.MENU_CONFIGURESCHEDULER,
                win32con.MF_BYCOMMAND | win32con.MF_POPUP | flags2,
                tasks_popup, "&Run Scheduled Scan")

            win32gui.InsertMenu(
                scheduler_popup, flags,
                win32con.MF_BYCOMMAND | win32con.MF_STRING | flags,
                self.MENU_TERMINATESCHEDULE, "&Stop All Running Tasks Now")

            # create reports menu
            reports_popup = win32gui.CreatePopupMenu()
            if not len(self._config.Get('ClamAV', 'LogFile')):
                flags = win32con.MF_GRAYED
            else:
                flags = 0
            win32gui.InsertMenu(
                reports_popup, 0,
                win32con.MF_BYCOMMAND | win32con.MF_STRING | flags,
                self.MENU_SHOWSCANLOG, "&Virus Scan Report")
            if not len(self._config.Get('Updates', 'DBUpdateLogFile')):
                flags = win32con.MF_GRAYED
            else:
                flags = 0
            win32gui.InsertMenu(
                reports_popup, self.MENU_SHOWSCANLOG,
                win32con.MF_BYCOMMAND | win32con.MF_STRING | flags,
                self.MENU_SHOWUPDATELOG, "&Virus Database Update Report")

            # create main menu
            menu = win32gui.CreatePopupMenu()
            win32gui.AppendMenu(menu, win32con.MF_STRING, self.MENU_OPEN_CLAM,
                                "&Open Blindata")
            win32gui.AppendMenu(menu, win32con.MF_STRING, self.MENU_UPDATE_DB,
                                "&Download Virus Database Update")
            win32gui.AppendMenu(menu, win32con.MF_STRING, self.MENU_CONFIGURE,
                                "&Configure Blindata")
            win32gui.AppendMenu(menu, win32con.MF_POPUP, scheduler_popup,
                                "&Scheduler")
            win32gui.AppendMenu(menu, win32con.MF_POPUP, reports_popup,
                                "Display &Reports")
            win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, "")
            win32gui.AppendMenu(menu, win32con.MF_STRING,
                                self.MENU_CHECK_UPDATE,
                                "Check &Latest Version")
            win32gui.AppendMenu(menu, win32con.MF_STRING,
                                self.MENU_CLAMWIN_WEB,
                                "&Visit Blindata Website")
            win32gui.AppendMenu(menu, win32con.MF_SEPARATOR, 0, "")
            win32gui.AppendMenu(menu, win32con.MF_STRING, self.MENU_EXIT,
                                "&Exit")

            pos = win32gui.GetCursorPos()
            # See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/menus_0hdi.asp
            try:
                win32gui.SetForegroundWindow(self.hwnd)
            except:
                pass
            try:
                win32gui.SetMenuDefaultItem(menu, 0, 1)
            except NameError:
                pass

            win32gui.TrackPopupMenu(menu, win32con.TPM_LEFTALIGN, pos[0],
                                    pos[1], 0, self.hwnd, None)
            win32gui.SendMessage(self.hwnd, win32con.WM_NULL, 0, 0)
Exemplo n.º 28
0
 def OnShow(self, event):
     win32gui.ShowWindow(self.frame.Handle, 1)
     win32gui.SetFocus(self.frame.Handle)
Exemplo n.º 29
0
# the call has to be showTweditWindowInForeground has to be done from the twedit
 def Focus(self):
     win32gui.SetFocus(self.hwnd)