最近不知道怎么回事【后來看郵件才知道,是因為git版本太老了,更新就好了】,vscode github插件不能自動登錄了,總是出現登錄窗口:
設置了以下自動登錄的代碼,但是不起作用。
git config --global user.name "我的用戶名" git config --global user.email "我的郵箱" git config --global credential.helper store
主要代碼如下:
from ctypes import * from random import * from inc.FormAPI import * from inc.kmAPI import * import autopy import pyautogui as auto from inc.change_keyboard_layout import * def auto_login(username, password): win_title = "GitHub Login" while True: form = FormControl() form.bindWindowByName(None, win_title) form.WindowActive() time.sleep(0.5) if form is not None: if form.getWinTitle() != win_title: continue else: try: windll.user32.BlockInput(1) # 禁用鼠標鍵盤 change_keyboard(Lan.EN) # 切換為英文輸入法 auto.typewrite(username) auto.press('tab') auto.typewrite(password) auto.press('enter') change_keyboard(Lan.ZH) finally: windll.user32.BlockInput(0) # 啟用鼠標鍵盤 if __name__ == "__main__": print("在管理員權限下運行才可以禁止鍵盤鼠標干擾") import argparse parser = argparse.ArgumentParser(description='VS插件GitHub自動登錄') parser.add_argument('-u', '--username', default="812256@qq.com", help="帳號") parser.add_argument('-p', '--password', default="", help='密碼', required=True) args = parser.parse_args() print(args) print("程序運行中...") auto_login(args.username, args.password)