SciTE- Change hotkey for debug tools

The popular SciTE-based AutoHotkey Script Editor
LizardCobra
Posts: 30
Joined: 14 Feb 2020, 10:57

SciTE- Change hotkey for debug tools

15 Apr 2022, 08:56

I'm using SciTE4AutoHotKey to develop and test my scripts. How can I change the hotkeys for the debug commands (Run script, Stop script, Run current line of code, Run until next line of code, Run until next function)?

I was assuming that I can change this using the SciTEUser.properties file. But when I check this documentation https://www.scintilla.org/SciTEDoc.html I'm not finding any properties that look like they set this. I haven't found anything that is currently set to F5, F10, F11, or Shift F11, so I don't know what to change.
This is a frustrating question to search for, since the search keyword "hotkey" and "debug" show up in just about every page😥
gregster
Posts: 9095
Joined: 30 Sep 2013, 06:48

Re: SciTE- Change hotkey for debug tools

15 Apr 2022, 09:03

Since we are using AHK, this is an alternative to changing it in Scite4AHK:

Code: Select all

#IfWinactive ahk_exe SciTE.exe
F4::F5		; press F4 to run script
; ...
#If
LizardCobra
Posts: 30
Joined: 14 Feb 2020, 10:57

Re: SciTE- Change hotkey for debug tools

15 Apr 2022, 09:30

I would really prefer not to have to resort to that method. I want to disable the default hotkeys. For example, I don't want F5 to still cause the script to run.
I also need to avoid actually sending F5 key, since that will interfere with other applications that are hooked to that key.

Also, Stop script doesn't currently have any hotkey associated with it. Is there any way to assign one?
Last edited by LizardCobra on 15 Apr 2022, 09:36, edited 1 time in total.
gregster
Posts: 9095
Joined: 30 Sep 2013, 06:48

Re: SciTE- Change hotkey for debug tools

15 Apr 2022, 09:50

LizardCobra wrote:
15 Apr 2022, 09:30
I would really prefer not to have to resort to that method. I want to disable the default hotkeys. For example, I don't want F5 to still cause the script to run.
Well, you can disable F5, or assign whatever you want to it.

Code: Select all

#IfWinactive ahk_exe SciTE.exe
F4::F5		; press F4 to run script
F5::return
; ...
#If
The line #IfWinactive ahk_exe SciTE.exe would limit these hotkeys to the active Scite window, and would guarantee that F5 will still work the usual way in other applications (when Scite is not the active window).
I also need to avoid actually sending F5 key, since that will interfere with other applications that are hooked to that key.
So, these applications use global hotkeys that are even active if their windows aren't active, and you need them while Scite is the active window? But did you actually try that code above?
gregster
Posts: 9095
Joined: 30 Sep 2013, 06:48

Re: SciTE- Change hotkey for debug tools

15 Apr 2022, 09:55

LizardCobra wrote:
15 Apr 2022, 09:30
Also, Stop script doesn't currently have any hotkey associated with it. Is there any way to assign one?
Ctrl+Break is already assigned to it (it might "force abrupt termination"). It's also available in the 'Tools' menu. But I have never used it so far.
I prefer to add a hotkey to the script (at least while testing, which I might remove later), like ^Esc::ExitApp. Seems more organic.

While debugging, pressing F5 (or whatever you assigned) a sceond time will at least pause the script.
LizardCobra
Posts: 30
Joined: 14 Feb 2020, 10:57

Re: SciTE- Change hotkey for debug tools

15 Apr 2022, 10:04

Unfortunately yes, I often have to run applications that use keyhooking to use global hotkeys. It's evil, I don't like it, but I have to use it. So F5 will interfere even if I disable it using AutoHotKey, I've tested that.

I did try the suggested workaround, but it is not working to start the script. By setting a breakpoint, I see that F5 is being sent when SciTE is active and the assigned new hotkey is pressed. But the corresponding debug controls are never getting activated. For some reason it seems to work fine if I use F4 as the new hotkey. But if I assign the hotkey that I actually want Alt [, nothing happens.

Code: Select all

#IfWinactive ahk_exe SciTE.exe
![::F5
!/::F10
!<::F11
!>::+F11
#If
gregster
Posts: 9095
Joined: 30 Sep 2013, 06:48

Re: SciTE- Change hotkey for debug tools

15 Apr 2022, 10:07

If you are using modifiers, you should use send instead of a pure remapping, because only Send will release the modifier:

Code: Select all

![::send {F5}
![::F5 would send !{F5}

PS: Scite's hotkeys could be hardcoded. Did you look into the source code ? SciTEDebug.ahk in the Tools directory looks like a good suspect.
Last edited by gregster on 15 Apr 2022, 10:15, edited 1 time in total.
Reason: edit
gregster
Posts: 9095
Joined: 30 Sep 2013, 06:48

Re: SciTE- Change hotkey for debug tools

15 Apr 2022, 11:16

Okay, I found a way to add general shortcuts via Options > Open User Properties, but the original hotkeys like F5 don't get disabled. 🤷‍♂️ (Perhaps disabling them via AHK will still help you...)

I added this to the opened file SciTEUser.properties:

Code: Select all

user.shortcuts=\
Ctrl+I|IDM_STOPEXECUTE|\
Ctrl+,|IDM_GO|
After saving that file, I restarted Scite4AHK.

This will run the script when I press Ctrl and ,, and terminate it forcefully, when I press Ctrl and i (I would still prefer a (temporary) hotkey in the script).
I got the command IDs and information from here: https://www.scintilla.org/CommandValues.html and here https://www.scintilla.org/SciTEDoc.html (user.shortcuts)


To change the hardcoded shortcuts of the debugger - which is a custom plugin for AHK, afaics - you probably need to separately edit SciTEDebug.ahk file in the Tools directory.
There you can find F5:: and other hotkeys. But please note that this file is probably write-protected and needs admin rights to edit. I made a copy (better anyway), edited that copy in a directory of my computer that allows it, and copied it back to the Scite subdirectory (after renaming and keeping the original file). Then restarted Scite4AHK. Now my ä key starts and pauses debugging (only while the debugging toolbar is visible).


But please edit anything at your own risk (SciTEUser.properties should be low-risk, though) and create backups. I did just a quick test; there could be side-effects.
If Scite4AHK suddenly acts strangely, make sure that the process InternalAHK.exe really exits when clsoing Scite, and before restarting it (check taskmanager).
Last edited by gregster on 15 Apr 2022, 11:23, edited 1 time in total.

Return to “SciTE4AutoHotkey”

Who is online

Users browsing this forum: No registered users and 3 guests