Sublime Forum

No cursor/document active when opening a new document

#1

Hi,

Been searching the forum for a solution to there being no cursor when opening a new document,
I have to click to make the document active.

Apologies if I have missed (in my endeavors) to find a solution.

Thanks
Ashley

0 Likes

#2

How are you opening the file?

0 Likes

#3

I use it to edit a autohotkey script, the keyboard shortcut to edit a script is cntrl+alt+e, I’ve set sublime as the default editor as it’s faster, syntax highlighting is better than anything else, so I open the file by keyboard shortcut, cntrl+alt+e, I have to click in the window to place a cursor there and start typing or searching, it’s annoying and distracting as I love everything else in terms of speed and testing sublime text offers

0 Likes

#4

It sounds like perhaps AutoHotKey is running Sublime but not giving it the input focus?

0 Likes

#5

The script is an entity and exists separately AutoHotkey only reads the file, which is text based and you can use any editor to edit the file, the default being notepad, as I mentioned earlier I prefer to use Sublime but since it’s not allowing input focus I’m gonna switch to Visual, thanks for the help

0 Likes

#6

How is AutoHotKey opening Sublime Text? Through the command line? If so what arguments is it using? Just to confirm, does the Sublime Text window receive focus but the text input doesn’t, or does Sublime Text not receive any input focus?

0 Likes

#7

AutoHotkey > AHK uses scripts to run, the application is installed via an .exe, thereafter you have to create a script which is a text file saved with the extension .ahk in your Documents folder e.g. myscript.ahk. AHK on it’s own won’t do anything without a script file, AHK searches for a script file (myscript.ahk can be named anything as long as it has .ahk extension)

Within this script file you add the Keyboard shortcuts, macros, hotstrings or generally programming you’d want to do and in this case the keyboard shortcut to edit a script file is cntrl+alt+e. By default AHK defaults to windows notepad to open the script file for editing. Through a registry entry change located in “\HKEY_CLASSES_ROOT\AutoHotkeyScript\Shell\Edit\Command” by editing the string and specifying “C:\Program Files\Sublime Text\sublime_text.exe” “%1” as the default editor. This will allow you through the keyboard shortcut (system wide) to open the myscript.ahk in Sublime Text.

That’s when sublime text fails to enable input focus by placing the cursor at the top of the document, I have to manually click into the document and scroll to the beginning. At the moment I’ve switched it to VS Code and it’s working perfectly.

I will miss some things in sublime but i’m sure there’s a workaround in VS Code, just have to go retrain the brain and muscle memory to new habits.

thanks again

0 Likes

#8

oh forgot for further info https://en.wikipedia.org/wiki/AutoHotkey

0 Likes

#9

If you replace sublime_text.exe with subl.exe in the registry entry does that fix your issue?

1 Like

#10

That did the trick but it keeps flashing a cmd prompt window before launching, is there anyway around that? thanks might not have to switch for now… then again right tools for the right job. thanks again

0 Likes