Skip to content

Commit

Permalink
Use a powershell script to manage focus on Windows (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste authored Mar 13, 2023
1 parent 1675c87 commit 6a26540
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
11 changes: 8 additions & 3 deletions FocusSublimeWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class FocusSublimeWindowCommand(WindowCommand):
def run(self, **args):
if NATIVE_FOCUS_WINDOW:
self.window.bring_to_front()
return

platform = sublime.platform()
if platform == 'linux':
Expand All @@ -26,5 +25,11 @@ def run(self, **args):
end tell
""" # Brings ALL the windows forward
subprocess.Popen(["osascript", "-e", script])
elif platform == 'windows': # needs http://www.nirsoft.net/utils/nircmd.html to be installed in windows dir
subprocess.Popen('nircmd win activate process sublime_text.exe')
elif platform == 'windows':
startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
subprocess.Popen(
'powershell -Command (New-Object -ComObject WScript.Shell).AppActivate({})'
.format(os.getppid()),
startupinfo=startupinfo
)
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,4 @@ Use Sublime Text to write in your browser. Everything you type in the editor wil

* An improved markdown syntax [MarkdownEditing](https://sublime.wbond.net/packages/MarkdownEditing)

If you still have Sublime Text 3 then:

* On Linux, [xdotool](http://www.semicomplete.com/projects/xdotool/) lets GhostText focus your Sublime Text window on a new connection.
* On Windows, [nircmd](http://www.nirsoft.net/utils/nircmd.html) in `C:/Windows/`, lets GhostText focus your Sublime Text window on a new connection.

0 comments on commit 6a26540

Please sign in to comment.