Mac AppleScript 自动登录3个QQ

更新,最近又得登3个QQ了,修改了代码,更快了一些,主要之前用的delay 1,现在升级为keystroe tab,不用等待,输入完账号或者密码时,按tab,就是来切换到,账号输入框按tab到密码输入框按tab到登录按钮


tell application "QQ"
    
    
    activate
    
    tell application "System Events"
        
        tell application process "QQ"
            
            activate
            delay 1
            set frontmost to true
            --get entire contents of window 1
            set value of text field 1 of window "Window" of application process "QQ" of application "System Events" to "QQ1账号"
            keystroke tab
            set value of text field 2 of window "Window" of application process "QQ" of application "System Events" to "QQ1密码"
            keystroke tab
            click checkbox 3 of window "Window" of application process "QQ" of application "System Events"
            keystroke return
            
            delay 1
            -- command n 再新建一个QQ
            keystroke "n" using command down
            set frontmost to true
            -- command tab 把准备用于登录第二个QQ的窗口放前面来
            
            keystroke tab using {command down}
            delay 1
            key code {48, 51}
            keystroke "QQ2账号"
            keystroke tab
            keystroke "QQ2密码"
            keystroke tab
            keystroke return
            
            
            
            -- command n 再新建一个QQ
            keystroke "n" using command down
            set frontmost to true
            -- command tab 把准备用于登录第二个QQ的窗口放前面来
            
            keystroke tab using {command down}
            delay 1
            key code {48, 51}
            keystroke "QQ3账号"
            keystroke tab
            
            keystroke "QQ3密码"
            keystroke tab
            
            keystroke return
            
        end tell
    end tell
end tell


反复实践,最终成果如下

无图无真相

qq.gif
tell application "QQ"
    
    activate
    
    tell application "System Events"
        
        tell application process "QQ"
            
            activate
            delay 1
            set frontmost to true
            --get entire contents of window 1
            set value of text field 1 of window "Window" of application process "QQ" of application "System Events" to "QQ1号码"
            set value of text field 2 of window "Window" of application process "QQ" of application "System Events" to "QQ1密码"
            click checkbox 3 of window "Window" of application process "QQ" of application "System Events"
            
            delay 1
            -- command n 再新建一个QQ
            keystroke "n" using command down
            set frontmost to true
            -- command tab 把准备用于登录第二个QQ的窗口放前面来
            
            keystroke tab using {command down}
            delay 1
            key code {48, 51}
            keystroke "QQ2号码"
            --delay 1
            keystroke return
            delay 1
            keystroke "QQ2密码"
            delay 1
            
            keystroke return
            
            
        end tell
    end tell
end tell

你可能感兴趣的:(Mac AppleScript 自动登录3个QQ)