[quote=âerinataâ]Iâve tried exactly the same thing but it didnât work.
I also try to import win32com âŚand it says that there is no module named win32com
I donât mind if it only works on windowsâŚif there is a way to do it.[/quote]
Bringing a window in front is tricky in Windows, and look worst in Win7:
[quote]MS Documentation for SetForegroundWindow reads as follows:
âWindows NT 5.0 and later: An application cannot force a window to the foreground while the user is working with another window. Instead, SetForegroundWindow will activate the window (see SetActiveWindow) and call the FlashWindowEx function to notify the user.â[/quote]
So the only way I found is this, however I cannot put the focus back to ST2:
[code]import sublime, sublime_plugin
import ctypes, time
class ExampleCommand(sublime_plugin.WindowCommand):
def run(self):
time.sleep(5)
# ctypes.windll.user32.BringWindowToTop(self.window.hwnd())
ctypes.windll.user32.SwitchToThisWindow(self.window.hwnd(), 0)
# ctypes.windll.user32.SetForegroundWindow(self.window.hwnd())
# ctypes.windll.user32.SetActiveWindow(self.window.hwnd())
# ctypes.windll.user32.SetFocus(self.window.hwnd())
# ctypes.windll.user32.ShowWindow(self.window.hwnd(), 5)[/code]
Hope it help.