mertk
mertk

Reputation: 47

switching between vscode editor tabs using python code

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?

Upvotes: 0

Views: 55

Answers (1)

x pie
x pie

Reputation: 592

In Vscode, we can use :

  1. Alt + number

  2. 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)

Upvotes: 2

Related Questions