Home Download Buy Blog Forum Support

Retain focus on Sublime Text

Re: Retain focus on Sublime Text

Postby erinata on Mon Apr 16, 2012 2:46 pm

Thanks for you guys' reply!

I am on window 7 x64....and I tried the
Code: Select all
webbrowser.open(................)
sublime.set_timeout(partial(ctypes.windll.user32.SetForegroundWindow,sublime.active_window().hwnd(), 0), 500)

And it's not working

But for
Code: Select all
webbrowser.open(................)
sublime.set_timeout(partial(ctypes.windll.user32.SwitchToThisWindow,sublime.active_window().hwnd(), 0), 500)


After the webbrowser call, the sublime text editor become the foreground window...........but when I press up arrow or down arrow, I am still scrolling the browser output instead of move the caret on sublime text. How can this happen?
erinata
 
Posts: 29
Joined: Wed Jan 25, 2012 12:19 pm

Re: Retain focus on Sublime Text

Postby bizoo on Mon Apr 16, 2012 3:16 pm

Oops, you're right.
I thought it works because my cursor still blink in ST2 after web browser launch but actually the focus is still in the browser.

I tried everything I know, now I'm clueless... :roll:
bizoo
 
Posts: 888
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Retain focus on Sublime Text

Postby erinata on Wed Apr 18, 2012 4:34 pm

I also tried setfocus() .......etc. (in bizoo's commented code). They do not work....

Looks like I just need to press alt+tab to switch it then :(
erinata
 
Posts: 29
Joined: Wed Jan 25, 2012 12:19 pm

Re: Retain focus on Sublime Text

Postby agibsonsw on Wed Apr 18, 2012 6:31 pm

Just a thought ;) but perhaps switch these two lines:

Code: Select all
webbrowser.open(................)
sublime.set_timeout(partial(ctypes.windll.user32.SetForegroundWindow,sublime.active_window().hwnd(), 0), 500)

and possibly increase the delay.
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Previous

Return to Plugin Development

Who is online

Users browsing this forum: Majestic-12 [Bot] and 4 guests