I want to take screenshot of the screen while one vscode tab is open(for example on the screen there is a text file) and when I'm done, I want to switch to a different tab and take screenshot of the screen. How can I switch between vscode editor tabs using python code if possible?
CodePudding user response:
In Vscode, we can use :
Alt number
Ctrl Tab
to switch to different tabs. When running the following code, Ctrl key will keep pressed until finish, and using Tab and Enter key, we can switch to different tabs.
from pykeyboard import PyKeyboard
import time
k = PyKeyboard()
num = 5 # num of tabs
k.press_key(k.control_key)
for i in range(num):
k.tap_key(k.tab_key, n=i 1, interval=1)
k.tap_key(k.enter_key)
time.sleep(10)
k.release_key(k.control_key)