python类MOUSEEVENTF_LEFTDOWN的实例源码

ctrl_waveQoE.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def click_CurrentPlace(self,lb_dx,lb_dy):

        tmp=(string.atoi(lb_dx),string.atoi(lb_dy))

        win32api.SetCursorPos(tmp)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])

    #-----------------------------------------------------------------------------
    # Name:         select_ssid
    # purpose:      select ssid.
    # explain:     
    # Author:       yuanwen
    #
    # Created:      2013/07/5
    #-----------------------------------------------------------------------------
win_GUI.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def selectComboboxItemThird(hwnd, item):
    try: # item is an index Use this to select
        0 + item
        win32gui.SendMessage(hwnd, win32con.CB_SHOWDROPDOWN, 1, 0)
        win32gui.SendMessage(hwnd, win32con.CB_SETCURSEL, item, 0)
        win32gui.SendMessage(hwnd, win32con.WM_SETFOCUS, 0, 0 )
        time.sleep(1)
        tmp=win32gui.GetWindowRect(hwnd)
        #print 'selectComboboxItemThird',tmp
        '''
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0]+1, tmp[1]+1) 
        time.sleep(0.1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0]+1, tmp[1]+1)
        '''
        win32gui.SendMessage(hwnd, win32con.WM_KEYDOWN, 13, 0 )
        time.sleep(0.1)
        win32gui.SendMessage(hwnd, win32con.WM_KEYUP, 13, 0 )
        time.sleep(0.1)
        #_sendNotifyMessage(hwnd, win32con.CBN_SELCHANGE)
    except TypeError: # Item is a string - find the index, and use that

        items = getComboboxItems(hwnd)
        itemIndex = items.index(item)
        selectComboboxItem(hwnd, itemIndex)
win_GUI.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def Mouse_LB_Double(self,str_app,lb_dx,lb_dy,Flag='1'):
        time.sleep(1)
        tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
        hwnd = win32gui.FindWindow(None, str_app)
        print 'Mouse_RB str_app,hwnd ',str_app,hwnd
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)

        win32api.SetCursorPos(tmp)

        time.sleep(1)
        #win32api.SetDoubleCIckTime()
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1]) 
        time.sleep(0.005)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
        time.sleep(0.005)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1]) 
        time.sleep(0.005)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
        time.sleep(0.005)
        return True
win_GUI.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def Mouse_LB_D(self,str_app,lb_dx,lb_dy,Flag='1'):
        time.sleep(1)
        tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
        hwnd = win32gui.FindWindow(None, str_app)
        print 'Mouse_RB str_app,hwnd ',str_app,hwnd
        if hwnd < 1:
            hwnd = self.find_main_window(str_app)

        win32api.SetCursorPos(tmp)

        time.sleep(1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1]) 
        time.sleep(0.05)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
        time.sleep(0.05)
        return True
ctrl_waveApps.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def click_CurrentPlace(self,lb_dx,lb_dy):

        tmp=(string.atoi(lb_dx),string.atoi(lb_dy))

        win32api.SetCursorPos(tmp)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])

    #-----------------------------------------------------------------------------
    # Name:         select_ssid
    # purpose:      select ssid.
    # explain:     
    # Author:       yuanwen
    #
    # Created:      2013/07/5
    #-----------------------------------------------------------------------------
Email My PC.py 文件源码 项目:Email_My_PC 作者: Jackeriss 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def button_event(content):
    key_table = {'BACKSPACE':8, 'TAB':9, 'TABLE':9, 'CLEAR':12, 'ENTER':13, 'SHIFT':16, 'CTRL':17, 
        'CONTROL':17, 'ALT':18, 'ALTER':18, 'PAUSE':19, 'BREAK':19, 'CAPSLK':20, 'CAPSLOCK':20, 'ESC':27, 
        'SPACE':32, 'SPACEBAR':32, 'PGUP':33, 'PAGEUP':33, 'PGDN':34, 'PAGEDOWN':34, 'END':35, 'HOME':36, 
        'LEFT':37, 'UP':38, 'RIGHT':39, 'DOWN':40, 'SELECT':41, 'PRTSC':42, 'PRINTSCREEN':42, 'SYSRQ':42, 
        'SYSTEMREQUEST':42, 'EXECUTE':43, 'SNAPSHOT':44, 'INSERT':45, 'DELETE':46, 'HELP':47, 'WIN':91, 
        'WINDOWS':91, 'F1':112, 'F2':113, 'F3':114, 'F4':115, 'F5':116, 'F6':117, 'F7':118, 'F8':119, 
        'F9':120, 'F10':121, 'F11':122, 'F12':123, 'F13':124, 'F14':125, 'F15':126, 'F16':127, 'NMLK':144, 
        'NUMLK':144, 'NUMLOCK':144, 'SCRLK':145, 'SCROLLLOCK':145, 'LEFTCLICK':999, 'RIGHTCLICK':1000}
    unrecognized = ''
    key_values = []
    keys = content.split('+')
    for key in keys:
        raw_key = key
        key = key.strip().replace(' ','').upper()
        if key in key_table:
            key_values.append(key_table.get(key))
        elif len(key) == 1:
            key_values.append(ord(key))
        else:
            if key != '':
                unrecognized = raw_key
    for key_value in key_values:
        if key_value == 999:
            win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        elif key_value == 1000:
            win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0)
        else:
            win32api.keybd_event(key_value, 0, 0, 0)
        time.sleep(1)
    for i in range(len(key_values)-1, -1, -1):
        if key_value == 999:
            win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
        elif key_value == 1000:
            win32api.mouse_event(win32con.MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0)
        else:
            win32api.keybd_event(key_values[i], 0, win32con.KEYEVENTF_KEYUP, 0)
        time.sleep(1)
    return unrecognized

#??????????
mouse_state.py 文件源码 项目:dfly_edit 作者: Monospark 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __toggle_marking(self):
        if self.__is_marking:
            self.stop_marking()
        else:
            self.__is_marking = True
            win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
windows.py 文件源码 项目:ATX 作者: NetEaseGame 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def _input_left_mouse(self, x, y):
        left, top, right, bottom = self.rect
        width, height = right - left, bottom - top
        if x < 0 or x > width or y < 0 or y > height:
            return

        win32gui.SetForegroundWindow(self.hwnd)
        pos = win32gui.GetCursorPos()
        win32api.SetCursorPos((left+x, top+y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
        win32api.Sleep(100) #ms
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
        win32api.Sleep(100) #ms
        # win32api.SetCursorPos(pos)
windows.py 文件源码 项目:AutomatorX 作者: xiaoyaojjian 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def _input_left_mouse(self, x, y):
        left, top, right, bottom = self.rect
        width, height = right - left, bottom - top
        if x < 0 or x > width or y < 0 or y > height:
            return

        win32gui.SetForegroundWindow(self.hwnd)
        pos = win32gui.GetCursorPos()
        win32api.SetCursorPos((left+x, top+y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
        win32api.Sleep(100) #ms
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0)
        win32api.Sleep(100) #ms
        # win32api.SetCursorPos(pos)
test.py 文件源码 项目:FindColor 作者: JarenChow 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def mouse_click():
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
winguiauto.py 文件源码 项目:pyAutoTrading 作者: drongh 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def clickWindow(hwnd, offset):
    left, top, right, bottom = win32gui.GetWindowRect(hwnd)
    # print('left, top, right, bottom', left, top, right, bottom)
    win32api.SetCursorPos([left + offset, (bottom - top) // 2 + top])
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
    time.sleep(0.2)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
    time.sleep(0.2)
utils.py 文件源码 项目:autoops_for_win 作者: qiueer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def MouseLDown(cls):
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        time.sleep(GLB_SLEEP_TIME)
utils.py 文件源码 项目:autoops_for_win 作者: qiueer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def LClick(cls):
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN|win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
        time.sleep(GLB_SLEEP_TIME)
yh_clienttrader.py 文件源码 项目:easytrader 作者: yuzhucu 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def _mouse_click(x, y):
        win32api.SetCursorPos((x, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, x, y, 0, 0)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, x, y, 0, 0)
TestExample.py 文件源码 项目:chessboard_Chinese-chess 作者: JiNianLuo 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def click(self, x, y):
        win32api.SetCursorPos((x, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
TestExample.py 文件源码 项目:chessboard_Chinese-chess 作者: JiNianLuo 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def click(self, x, y):
        win32api.SetCursorPos((x, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
TestExample.py 文件源码 项目:chessboard_Chinese-chess 作者: JiNianLuo 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def click(self, x, y):
        win32api.SetCursorPos((x, y))
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
win_GUI.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def Mouseclick_lb(self,tmp=(220,230)):
        win32api.SetCursorPos(tmp)
        print 'Mouseclick_lb tmp:',tmp
        time.sleep(1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1]) 
        time.sleep(0.1)
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
        time.sleep(0.1)
        return True
ctrl_omnipeek.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def click_CurrentPlace(self,tmp=(259, 178)):

        win32api.SetCursorPos(tmp)
        self.sleep('1')
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1])
        self.sleep('0.05')
        win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
        self.sleep('0.05')
rssid.py 文件源码 项目:Automation-Framework-for-devices 作者: tok-gogogo 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def Mouse_LB_D(self,str_app,lb_dx,lb_dy,Flag='1'):
        time.sleep(1)
        tmp=(string.atoi(lb_dx),string.atoi(lb_dy))
        hwnd = win32gui.FindWindow(None, str_app)
        #msg = 'Mouse_LB str_app,hwnd '+str_app+' '+ str(hwnd)
        #log_print(msg)
        if hwnd > 0:
            win32api.SetCursorPos(tmp)
            time.sleep(1)
            win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,tmp[0], tmp[1]) 
            time.sleep(0.05)
            win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,tmp[0], tmp[1])
            time.sleep(0.05)
            return True
        return False
FX_WindowsAutomation.py 文件源码 项目:PyUIA 作者: xiaoxiayu 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def FX_MouseLClick(x, y):
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
FX_WindowsAutomation.py 文件源码 项目:PyUIA 作者: xiaoxiayu 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def FX_MouseLDown(x, y):
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, int(x), int(y), 0, 0)
dota2_lumbering_challenge.py 文件源码 项目:py3_scripts 作者: bioinformatist 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def mouse_click(x=None, y=None):
    if not x is None and not y is None:
        mouse_move(x, y)
        time.sleep(random.random())
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
NETAutomation_old.py 文件源码 项目:Zeuz_Python_Node 作者: AutomationSolutionz 项目源码 文件源码 阅读 18 收藏 0 点赞 0 评论 0
def Click_Element_None_Mouse(Element,Expand=None,Invoke=None,Select=None,Toggle=None):
    try:
        x = (int)(Element.Current.BoundingRectangle.Right - Element.Current.BoundingRectangle.Width / 2);
        y = (int)(Element.Current.BoundingRectangle.Bottom - Element.Current.BoundingRectangle.Height / 2);
        win32api.SetCursorPos((x,y))

        print "clicking your element"
        patter_list = Element.GetSupportedPatterns()
        for each in patter_list:
            pattern_name = Automation.PatternName(each)
            if pattern_name == "ExpandCollapse":
                if Expand==True:
                    #check to see if its expanded, if expanded, then do nothing... if not, expand it
                    status = Element.GetCurrentPattern(ExpandCollapsePattern.Pattern).Current.ExpandCollapseState
                    if status == 0:
                        Element.GetCurrentPattern(ExpandCollapsePattern.Pattern).Expand()
                    elif status == 1:
                        print "Already Expanded"
                elif Expand == False:
                    #check to see if its Collapsed, if Collapsed, then do nothing... if not, Collapse it
                    status = Element.GetCurrentPattern(ExpandCollapsePattern.Pattern).Current.ExpandCollapseState
                    if status == 1:
                        Element.GetCurrentPattern(ExpandCollapsePattern.Pattern).Collapse()  
                    elif status == 0:
                        print "Already Collapsed"                    



            elif pattern_name == "Invoke":
                if Invoke==True:
                    print "invoking the button: %s" %Element.Current.Name
                    time.sleep(2)
                    Element.GetCurrentPattern(InvokePattern.Pattern).Invoke()



            elif pattern_name == "SelectionItem":
                Element.GetCurrentPattern(SelectionItemPattern.Pattern).Select()
            elif pattern_name == "Toggle":
                Element.GetCurrentPattern(TogglePattern.Pattern).Toggle()
            else:
                #x = int (Element.Current.BoundingRectangle.X)
                #y = int (Element.Current.BoundingRectangle.Y)

                x = (int)(Element.Current.BoundingRectangle.Right - Element.Current.BoundingRectangle.Width / 2);
                y = (int)(Element.Current.BoundingRectangle.Bottom - Element.Current.BoundingRectangle.Height / 2);
                win32api.SetCursorPos((x,y))
                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
                time.sleep(0.1)
                win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)

    except Exception, e:
        exc_type, exc_obj, exc_tb = sys.exc_info()
        fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1]
        print ((str(exc_type).replace("type ", "Error Type: ")) + ";" +  "Error Message: " + str(exc_obj) +";" + "File Name: " + fname + ";" + "Line: "+ str(exc_tb.tb_lineno))


问题


面经


文章

微信
公众号

扫码关注公众号