Python win32con 模块,KEYEVENTF_KEYUP 实例源码

我们从Python开源项目中,提取了以下32个代码示例,用于说明如何使用win32con.KEYEVENTF_KEYUP

项目:chat-robot    作者:wdc63    | 项目源码 | 文件源码
def main_thread():
    F6 = 0x75
    while True:        
        win32api.keybd_event(F6,0,0,0)
        time.sleep(0.05)
        win32api.keybd_event(F6,0 ,win32con.KEYEVENTF_KEYUP ,0)

        input_words = ""
        for line in iter(input,"~~~~~????????~~~~~~"):
            input_words += line
            if " " in input_words or "?" in input_words:
                break
        print("???"+input_words)

        win32api.keybd_event(F6,0,0,0)
        time.sleep(0.05)
        win32api.keybd_event(F6,0 ,win32con.KEYEVENTF_KEYUP ,0)

        if "??" in input_words or "??" in input_words or "??" in input_words or "??" in input_words or "?" in input_words:
            play(input_words)
        else:  
            chat(input_words)

##????
项目:chat-robot    作者:wdc63    | 项目源码 | 文件源码
def hawk_enter():
    appname = "?????"
    enter = 0x0D
    count = 0
    while True:
        if count % 10 == 0:
            window = win32gui.FindWindow(None, appname)
            try:
                win32gui.SetForegroundWindow(window)
            except:
                pass
        if window != 0:
            win32api.keybd_event(enter,0,0,0)
            time.sleep(0.05)
            win32api.keybd_event(enter,0 ,win32con.KEYEVENTF_KEYUP ,0)
        time.sleep(1)
        count += 1
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def pressHoldRelease(*args):
    '''
    press and hold passed in strings. Once held, release
    accepts as many arguments as you want.
    e.g. pressAndHold('left_arrow', 'a','b').

    this is useful for issuing shortcut command or shift commands.
    e.g. pressHoldRelease('ctrl', 'alt', 'del'), pressHoldRelease('shift','a')
    '''
    for i in args:
        win32api.keybd_event(VK_CODE[i], 0, 0, 0)
        time.sleep(.05)

    for i in args:
        win32api.keybd_event(VK_CODE[i], 0, win32con.KEYEVENTF_KEYUP, 0)
        time.sleep(.1)
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_AtPerson(name):
    win32api.keybd_event(win32con.VK_SHIFT, 0, 0, 0);
    win32api.keybd_event(ord('2'), 0, 0, 0);
    win32api.keybd_event(ord('2'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_SHIFT, 0, win32con.KEYEVENTF_KEYUP, 0);

    time.sleep(0.5)

    QQ_PrintText(user_list[name]['spell'])

    time.sleep(0.8)

    win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0);
    win32api.keybd_event(win32con.VK_RETURN, 0, win32con.KEYEVENTF_KEYUP, 0);

# Parse out the AT directives.
项目:Smart-Trex    作者:yugrocks    | 项目源码 | 文件源码
def key_up(self):
        win32api.keybd_event(0x20,0,win32con.KEYEVENTF_EXTENDEDKEY | win32con.KEYEVENTF_KEYUP,0)
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
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

#??????????
项目:PyF9    作者:Saren-Arterius    | 项目源码 | 文件源码
def type_char_worker():
    while True:
        char = type_char_queue.get()
        if char is None:
            break
        if platform.system() == 'Linux':
            if LINUX_USE_CLIPBOARD:
                was = None
                try:
                    was = root.clipboard_get()
                except:
                    pass
                root.clipboard_clear()
                root.clipboard_append(char)
                # call(["xdotool", "key", "CTRL+V"], False)
                linux_paste()
                if was is not None:
                    sleep(CLIPBOARD_WAIT_DELAY)
                    root.clipboard_clear()
                    root.clipboard_append(was)
            else:
                call(["xdotool", "key", "U" + hex(ord(char))[2:]], True)
        else:
            was = None
            try:
                was = win_get_clipboard_text()
            except:
                pass
            win_set_clipboard_text(char)
            win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0)
            win32api.keybd_event(0x56, 0, 0, 0)
            win32api.keybd_event(win32con.VK_CONTROL, 0,
                                 win32con.KEYEVENTF_KEYUP, 0)
            win32api.keybd_event(0x56, 0, win32con.KEYEVENTF_KEYUP, 0)
            if was is not None:
                sleep(CLIPBOARD_WAIT_DELAY)
                win_set_clipboard_text(was)
        type_char_queue.task_done()
项目:pikaRL    作者:kooock    | 项目源码 | 文件源码
def game_start(self):
        #enter 3?
        win32api.keybd_event(self.keyMap[4], 0, 0, 0) # enter down
        time.sleep(0.1)
        win32api.keybd_event(self.keyMap[4], 0, win32con.KEYEVENTF_KEYUP, 0) # enter up
        time.sleep(0.1)
        win32api.keybd_event(self.keyMap[4], 0, 0, 0) # enter down
        time.sleep(0.1)
        win32api.keybd_event(self.keyMap[4], 0, win32con.KEYEVENTF_KEYUP, 0) # enter up
        time.sleep(0.1)
        win32api.keybd_event(self.keyMap[4], 0, 0, 0)  # enter down
        time.sleep(0.1)
        win32api.keybd_event(self.keyMap[4], 0, win32con.KEYEVENTF_KEYUP, 0)  # enter up
        time.sleep(4)
项目:pikaRL    作者:kooock    | 项目源码 | 文件源码
def game_reset(self):
        #?? ?? ???????? ? ????
        win32api.keybd_event(win32con.VK_MENU, 0, 0, 0) #alt down
        time.sleep(self.interval_time)
        win32api.keybd_event(win32con.VK_MENU, 0, win32con.KEYEVENTF_KEYUP, 0) #alt up
        win32api.keybd_event(0x47, 0, 0, 0) # key'G' down
        time.sleep(0.01)
        win32api.keybd_event(0x47, 0, win32con.KEYEVENTF_KEYUP, 0) # key 'G' up
        win32api.keybd_event(0x52, 0, 0, 0) # key 'R' down
        time.sleep(0.01)
        win32api.keybd_event(0x52, 0, win32con.KEYEVENTF_KEYUP, 0) # key 'R' up
        self.game_start()
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def press(*args):
    '''
    one press, one release.
    accepts as many arguments as you want. e.g. press('left_arrow', 'a','b').
    '''
    for i in args:
        win32api.keybd_event(VK_CODE[i], 0, 0, 0)
        time.sleep(.05)
        win32api.keybd_event(VK_CODE[i], 0, win32con.KEYEVENTF_KEYUP, 0)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def release(*args):
    '''
    release depressed keys
    accepts as many arguments as you want.
    e.g. release('left_arrow', 'a','b').
    '''
    for i in args:
        win32api.keybd_event(VK_CODE[i], 0, win32con.KEYEVENTF_KEYUP, 0)
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_PrintText(str):
    print "Send text = " + str.decode('gbk')
    QQ_setClipboardText(str)
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);

# AT a name.
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_Enter():
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(win32con.VK_RETURN, 0, 0, 0);
    win32api.keybd_event(win32con.VK_RETURN, 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);

# The interface function to send QQ a message.
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_ToggleMessageRecord():
    win32api.keybd_event(win32con.VK_MENU, 0, 0, 0);
    win32api.keybd_event(ord('H'), 0, 0, 0);
    win32api.keybd_event(ord('H'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_MENU, 0, win32con.KEYEVENTF_KEYUP, 0);

# Copy the last message.
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_CopyText():
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(ord('C'), 0, 0, 0);
    win32api.keybd_event(ord('C'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);

# Close the window.
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_PasteFile():
    win32api.keybd_event(win32con.VK_CONTROL, 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, 0, 0);
    win32api.keybd_event(ord('V'), 0, win32con.KEYEVENTF_KEYUP, 0);
    win32api.keybd_event(win32con.VK_CONTROL, 0, win32con.KEYEVENTF_KEYUP, 0);
项目:CNKI-QQFriend    作者:hsluoyz    | 项目源码 | 文件源码
def QQ_SendOffline():
    QQ_Enter()
    time.sleep(0.2)
    for i in range(0, 10):
        print "tab = " + str(i)
        win32api.keybd_event(win32con.VK_TAB, 0, 0, 0);
        win32api.keybd_event(win32con.VK_TAB, 0, win32con.KEYEVENTF_KEYUP, 0);
        time.sleep(0.2)
    QQ_Enter()
项目:easytrader    作者:yuzhucu    | 项目源码 | 文件源码
def _read_clipboard(self):
        for _ in range(15):
            try:
                win32api.keybd_event(17, 0, 0, 0)
                win32api.keybd_event(67, 0, 0, 0)
                win32api.keybd_event(67, 0, win32con.KEYEVENTF_KEYUP, 0)
                win32api.keybd_event(17, 0, win32con.KEYEVENTF_KEYUP, 0)
                time.sleep(0.2)
                return pyperclip.paste()
            except Exception as e:
                log.error('open clipboard failed: {}, retry...'.format(e))
                time.sleep(1)
        else:
            raise Exception('read clipbord failed')
项目:WifiPPT    作者:sharpdeep    | 项目源码 | 文件源码
def click(self):
        win32api.keybd_event(VK_CODE['spacebar'],0,0,0)
        win32api.keybd_event(VK_CODE['spacebar'],0,win32con.KEYEVENTF_KEYUP,0)
        return self.getActivePresentationSlideIndex()
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def shortcut_keys(self,list_key=[]):
        for x in list_key:
            tmp = self.dic_keycode(x)
            win32api.keybd_event(tmp,0,0,0)
        for x in reversed(list_key):
            tmp = self.dic_keycode(x)
            win32api.keybd_event(tmp,0,win32con.KEYEVENTF_KEYUP,0)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def shortcut_keys(self,list_key=[],time=5):

        for x in list_key:
            tmp = self.dic_keycode(x)
            win32api.keybd_event(tmp,0,0,0)
            win32api.Sleep(time)
        for x in list_key:
            tmp = self.dic_keycode(x)
            win32api.keybd_event(tmp,0,win32con.KEYEVENTF_KEYUP,0)
            win32api.Sleep(time)
        return True

    #Click Current Place
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def shortcut_keys(self,list_key=[]):
        for x in list_key:
            tmp = self.dic_keycode(x)
            try:
                win32api.keybd_event(tmp,0,0,0)
            except Exception ,excet_str:
                log_print( excet_str)
        for x in list_key:
            tmp = self.dic_keycode(x)
            try:
                win32api.keybd_event(tmp,0,win32con.KEYEVENTF_KEYUP,0)
            except Exception ,excet_str:
                log_print( excet_str)
项目:PyUIA    作者:xiaoxiayu    | 项目源码 | 文件源码
def FX_KeybdRelease(virtual_key_code):
    win32api.keybd_event(virtual_key_code, 0, win32con.KEYEVENTF_KEYUP, 0)
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Onu_login(self,FlowName):
        print 'onu_login fuction'
        if self.Onu_login_Flag == 1 :
            return True
        ap_name = FlowName.split('_')[-1]
        if ap_name =='ONU':
            login_username = LOGIN_USERNAME_GONGJIN
            login_password = LOGIN_PASSWORD_GONGJIN
            print 'GONGJIN:login_username--',login_username
            print 'GONGJIN:login_password--',login_password
        test_win = win_gui()

        hwnd = win32gui.FindWindow('#32770',None)
        print 'hwnd is ',hwnd
        if hwnd < 1:
            log_public(WEB_ERR_NO_0020)
            self.m_ERROR_MSG = WEB_ERR_NO_0020
            return False
        else:
            win32api.Sleep(100)
            win32api.keybd_event(18,0,0,0);
            win32api.keybd_event(85,0,0,0);
            win32api.Sleep(100)
            win32api.keybd_event(85,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(100)
            shell = win32com.client.Dispatch("WScript.Shell")
            shell.SendKeys(login_username)

            win32api.Sleep(100)
            win32api.keybd_event(18,0,0,0);
            win32api.keybd_event(80,0,0,0);
            win32api.Sleep(100)
            win32api.keybd_event(80,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(300)
            shell.SendKeys(login_password)
            win32api.Sleep(100)
            win32api.keybd_event(13,0,0,0);   
            win32api.Sleep(100)
            win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(100)
            return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def choose_conf_file(self):
        #get control of waveQoE window.    
        hwnd3 = win32gui.FindWindow(WAVEQOE_CLASS,None)
        print 'hwnd3',hwnd3
        time.sleep(0.5)

        #set waveQoE window to top.
        win32gui.SetForegroundWindow(hwnd3)
        time.sleep(0.5)

        #move waveQoE window to top left corner.
        win32gui.MoveWindow(hwnd3,0,0,1448,878,1)

        #send Alt+F to open 'File' in menu bar.
        win32api.Sleep(1000)
        win32api.keybd_event(18,0,0,0);   #18Alt?
        win32api.keybd_event(70,0,0,0);   #70F?
        win32api.Sleep(1000)
        win32api.keybd_event(70,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        #send O to open 'open' window.
        win32api.keybd_event(79,0,0,0);  #79O?
        win32api.Sleep(1000)
        win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        #choose config file and open it.
        self.myobj.Find_Gui_edit(str_app = 'Open',control_class = 'ComboBox',filename = self.conf_file_dir,control_name = '',stop_flag = '0')
        self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '(&O)')   
        time.sleep(0.5) 

        hwnd4 = win32gui.FindWindow('#32770','Open')
        print 'hwnd4: ',hwnd4

        if hwnd4 > 0:
            log_public(ERR_NO_0006)            
            self.m_ERROR_MSG = ERR_NO_0006
            self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
            time.sleep(0.5)
            self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
            time.sleep(0.5)
            self.close_waveQoE()
            print 'close_waveqoe'
            return False
        else:
            print 'conf_file is correct.'
            return True

    #-----------------------------------------------------------------------------
    # Name:         Mouse_LB_click
    # purpose:      click the mouse's left butten.
    # explain:     
    # Author:       yuanwen
    #
    # Created:      2013/07/5
    #-----------------------------------------------------------------------------
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def close_waveQoE(self):
        #get the handle of waveQoE window.
        try:
            hwnd6 = win32gui.FindWindow(WAVEQOE_CLASS,None)
            print 'hwnd6:',hwnd6 
            time.sleep(1)

            #set the waveQoE window to the top.
            win32gui.SetForegroundWindow(hwnd6)
            time.sleep(1)
        except:
            print 'close error'
            log_public(ERR_NO_0009)            
            self.m_ERROR_MSG = ERR_NO_0009
            return False

        #click the title bar.
        self.myobj.Mouse_LB_D(str_app = WAVEQOE_CLASS,lb_dx = '75',lb_dy = '10',Flag = '1')

        #send Alt+F to open 'File' in menu bar.
        win32api.Sleep(1000)
        win32api.keybd_event(18,0,0,0);   #18Alt?
        win32api.keybd_event(70,0,0,0);   #70F?
        win32api.Sleep(1000)
        win32api.keybd_event(70,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        #send X to close waveQoE window.
        win32api.keybd_event(88,0,0,0);  #88X?
        win32api.Sleep(1000)
        win32api.keybd_event(88,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        if self.timeout == 1:
            #send Alt+Y to exit waveQoE without save.
            win32api.keybd_event(18,0,0,0);   #18Alt?
            win32api.keybd_event(89,0,0,0);   #89Y?
            win32api.Sleep(1000)
            win32api.keybd_event(89,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(1000)
        else:
            #send Alt+N to exit waveQoE without save.
            win32api.keybd_event(18,0,0,0);   #18Alt?
            win32api.keybd_event(78,0,0,0);   #78N?
            win32api.Sleep(1000)
            win32api.keybd_event(78,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(1000)           
        return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def Onu_login(self,FlowName):
        print 'onu_login fuction'
        if self.Onu_login_Flag == 1 :
            return True
        ap_name = FlowName.split('_')[-1]
        if ap_name =='ONU':
            login_username = LOGIN_USERNAME_GONGJIN
            login_password = LOGIN_PASSWORD_GONGJIN
            print 'GONGJIN:login_username--',login_username
            print 'GONGJIN:login_password--',login_password
        test_win = win_gui()

        hwnd = win32gui.FindWindow('#32770',None)
        print 'hwnd is ',hwnd
        if hwnd < 1:
            log_public(WEB_ERR_NO_0020)
            self.m_ERROR_MSG = WEB_ERR_NO_0020
            return False
        else:
            win32api.Sleep(100)
            win32api.keybd_event(18,0,0,0);
            win32api.keybd_event(85,0,0,0);
            win32api.Sleep(100)
            win32api.keybd_event(85,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(100)
            shell = win32com.client.Dispatch("WScript.Shell")
            shell.SendKeys(login_username)

            win32api.Sleep(100)
            win32api.keybd_event(18,0,0,0);
            win32api.keybd_event(80,0,0,0);
            win32api.Sleep(100)
            win32api.keybd_event(80,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(300)
            shell.SendKeys(login_password)
            win32api.Sleep(100)
            win32api.keybd_event(13,0,0,0);   
            win32api.Sleep(100)
            win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(100)
            return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def first_test_case(self,test_case = r"E:\UFTTestCase\EMS_Test\EMS_FUN_000012\DemoTest\DemoTest"):

        WINDOW_TITLE = u'HP Unified Functional Testing'
        self.app[WINDOW_TITLE].TypeKeys(u'^O')
        time.sleep(2)
        try:
            shell = win32com.client.Dispatch("WScript.Shell")
            shell.SendKeys(test_case)
        except Exception,e:
            print e
        time.sleep(2)
        self.app[u'Open Test'][u'Open'].Click()
        test_win = win_gui()
        cnt = 0
        while cnt<60:
            try:
                hwnd = 0
                hwnd = test_win.find_main_window_end(test_case)
                #print '12 = ',hwnd 
                if hwnd>0:
                    break
            except Exception,e:
                cnt = cnt + 1
                time.sleep(1)
                pass       
        win32api.keybd_event(116,0,0,0)
        win32api.Sleep(2)
        win32api.keybd_event(116,0,win32con.KEYEVENTF_KEYUP,0)
        time.sleep(2)
        win32api.keybd_event(13,0,0,0)
        win32api.Sleep(2)
        win32api.keybd_event(13,0,win32con.KEYEVENTF_KEYUP,0)
        cnt = 0
        result = False
        while cnt<60:
            try:

                hwnd = 0
                hwnd = test_win.find_main_window_end('HP Run Results Viewer')
                if hwnd>0:
                    result = True
                    break
            except Exception,e:
                print e
                cnt = cnt + 1
                time.sleep(1)                                    
                pass
        return result
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def loadrunner_Scenario(self,app = 'D:\\Program Files\\HP\\LoadRunner\\bin\\Wlrun.exe',scriptname ='Scenario1.lrs'):
        count = '2'
        #app = 'D:\\Program Files\\HP\\LoadRunner\\bin\\Wlrun.exe'
        self.startapp(app)
        self.sleep(count)
        str_app = 'New Scenario'
        list = [] 
        result = False
        try:
            list = self.Find_Gui_window(str_app)
        except Exception ,exc_str:
            log_print(exc_str)
            return False
        if len(list)>0:
            print list
            control_name = 'Cancel'
            control_class = 'Button'
            self.Find_Gui_button(str_app,control_class,control_name)
        str_app = 'HP LoadRunner Controller'
        self.app_first(str_app)
        self.shortcut_keys(['Ctrl','O'])

        str_app = 'Open Scenario'
        self.Find_Gui_edit(str_app,control_class='Edit',filename=scriptname,stop_flag='1')
        time.sleep(2)
        self.app_first(str_app)
        control_name = '´ò¿ª(&O)'
        control_class = 'Button'
        self.Find_Gui_button(str_app,control_class,control_name)

        time.sleep(10)
        str_app = 'HP LoadRunner Controller'
        self.app_first(str_app)
        self.shortcut_keys(['F5'])

        time.sleep(1)
        list_a = self.Find_Gui_window()
        if len(list_a)>0:
            control_class = 'Button'
            control_name = 'ÊÇ(&Y)'
            try:
                result = self.Find_Gui_button(list_a[0],control_class,control_name)
            except:
                return False
        else:
            result = True
        return result



        #self.shortcut_keys(['Ctrl','O'])

        '''
        win32api.keybd_event(17,0,0,0)   #ctrl¼üλÂëÊÇ17
        win32api.keybd_event(79,0,0,0)  #o¼üλÂëÊÇ86
        win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0) #ÊÍ·Å°´¼ü
        win32api.keybd_event(17,0,win32con.KEYEVENTF_KEYUP,0)
        '''
        #str_app = 'New Scenario'
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def choose_conf_file(self):
        #get control of waveApps window.    
        hwnd3 = win32gui.FindWindow(WAVEApps_CLASS,None)
        print 'hwnd3',hwnd3
        time.sleep(0.5)

        #set waveApps window to top.
        win32gui.SetForegroundWindow(hwnd3)
        time.sleep(0.5)

        #move waveApps window to top left corner.
        win32gui.MoveWindow(hwnd3,0,0,1448,878,1)

        #send Alt+F to open 'File' in menu bar.
        win32api.Sleep(1000)
        win32api.keybd_event(18,0,0,0);   #18Alt?
        win32api.keybd_event(70,0,0,0);   #70F?
        win32api.Sleep(1000)
        win32api.keybd_event(70,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        #send O to open 'open' window.
        win32api.keybd_event(79,0,0,0);  #79O?
        win32api.Sleep(1000)
        win32api.keybd_event(79,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        #choose config file and open it.
        self.myobj.Find_Gui_edit(str_app = 'Open',control_class = 'ComboBox',filename = self.conf_file_dir,control_name = '',stop_flag = '0')
        self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '(&O)')   
        time.sleep(0.5) 

        hwnd4 = win32gui.FindWindow('#32770','Open')
        print 'hwnd4: ',hwnd4

        if hwnd4 > 0:
            log_public(ERR_NO_0006)            
            self.m_ERROR_MSG = ERR_NO_0006
            self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
            time.sleep(0.5)
            self.myobj.Find_Gui_button(str_app = 'Open',control_class = 'Button',control_name = '?')
            time.sleep(0.5)
            self.close_waveApps()
            print 'close_waveApps'
            return False
        else:
            print 'conf_file is correct.'
            return True

    #-----------------------------------------------------------------------------
    # Name:         Mouse_LB_click
    # purpose:      click the mouse's left butten.
    # explain:     
    # Author:       yuanwen
    #
    # Created:      2013/07/5
    #-----------------------------------------------------------------------------
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def close_waveApps(self):
        #get the handle of waveApps window.
        try:
            hwnd6 = win32gui.FindWindow(WAVEApps_CLASS,None)
            print 'hwnd6:',hwnd6 
            time.sleep(1)

            #set the waveApps window to the top.
            win32gui.SetForegroundWindow(hwnd6)
            time.sleep(1)
        except:
            print 'close error'
            log_public(ERR_NO_0009)            
            self.m_ERROR_MSG = ERR_NO_0009
            return False

        #click the title bar.
        #self.myobj.Mouse_LB_D(str_app = WAVEApps_CLASS,lb_dx = '75',lb_dy = '10',Flag = '1')

        #send Alt+F to open 'File' in menu bar.
        win32api.Sleep(1000)
        win32api.keybd_event(18,0,0,0);   #18Alt?
        win32api.keybd_event(70,0,0,0);   #70F?
        win32api.Sleep(1000)
        win32api.keybd_event(70,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        #send X to close waveApps window.
        win32api.keybd_event(88,0,0,0);  #88X?
        win32api.Sleep(1000)
        win32api.keybd_event(88,0,win32con.KEYEVENTF_KEYUP,0);
        win32api.Sleep(1000)

        if self.timeout == 1:
            #send Alt+Y to exit waveApps without save.
            win32api.keybd_event(18,0,0,0);   #18Alt?
            win32api.keybd_event(89,0,0,0);   #89Y?
            win32api.Sleep(1000)
            win32api.keybd_event(89,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(1000)
        else:
            #send Alt+N to exit waveApps without save.
            win32api.keybd_event(18,0,0,0);   #18Alt?
            win32api.keybd_event(78,0,0,0);   #78N?
            win32api.Sleep(1000)
            win32api.keybd_event(78,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0);
            win32api.Sleep(1000)           
        return True
项目:Automation-Framework-for-devices    作者:tok-gogogo    | 项目源码 | 文件源码
def OpenWiressResourse(self):
        log_print( ">>OpenWiressResourse" )          
        app = None      
        LstIDX =[0] 
        RET = None
        app = self.OpenNetDialogAndSelectIcon(LstIDX)
        time.sleep(1)
        print 'OpenWiressResourse  OpenNetDialogAndSelectIcon',LstIDX

        try:
            #Open "resorse" dialog
            #-app[KEY_NETDIALOG].TypeKeys(KEY_NETDIALOG_FILE,pause=KEY_PAUSH_SLEEP_TIEM)
            #-app[KEY_NETDIALOG].TypeKeys(KEY_NETDIALOG_FILE_RESOSE,pause=KEY_PAUSH_SLEEP_TIEM)
            print 'OpenWiressResourse here'
            RET =app[KEY_NETDIALOG].ListViewWrapper.GetItemRect(LstIDX[0])  
            print  'RET',RET
            #myMenu = [KEY_POP_MENU_RSE]
            #self.PopMenuClick(app,KEY_NETDIALOG,myMenu,RET)   
            #self.wingui.shortcut_keys(['Alt','F'])
            time.sleep(1)

            win32api.keybd_event(18,0,0,0)
            win32api.keybd_event(70,0,0,0)
            win32api.keybd_event(70,0,win32con.KEYEVENTF_KEYUP,0)
            win32api.keybd_event(18,0,win32con.KEYEVENTF_KEYUP,0)

            time.sleep(1)
            #self.wingui.shortcut_keys(['R'])

            win32api.keybd_event(82,0,0,0)
            win32api.keybd_event(82,0,win32con.KEYEVENTF_KEYUP,0)

            time.sleep(3)
            #close "net connect" dialog
            #-app[KEY_NETDIALOG].TypeKeys(KEY_NETDIALOG_FILE,pause=KEY_PAUSH_SLEEP_TIEM)
            #-app[KEY_NETDIALOG].TypeKeys(KEY_NETDIALOG_FILE_CLOSE,pause=KEY_PAUSH_SLEEP_TIEM) 
            #self.closeExistDialog()  
            #connect to "resorse" dialog

            app=application.Application().connect_(title_re=KEY_FIND_WIRESS_NAME_PROPERTY ) 
            print 'OpenWiressResourse here 23'
            time.sleep(1)
        except Exception ,excet_str:
            log_print( excet_str)
            #self.m_ERROR_MSG = ERR_024 
            app = None
        return app


    #014