简体   繁体   中英

How to programmatically raise-to-top Visual Studio from Python

How do you programatically raise the VisualStudio environment from python?

You get a handle to Visual Studio as follows:

import win32com.client
>>> b = win32com.client.Dispatch('VisualStudio.DTE')

but what method of b needs to be called to make VisualStudio environment focused and raised-to-top?

First you can get Visual Studio's main window:

w = b.MainWindow

Then you can get main window's handle (HWND):

h = w.Hwnd

Then using win32gui module you can move this window on top:

import win32gui
win32gui.SetForegroundWindow(h)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM