Came across Visual Studio Code the other day

Discuss features, issues, about Editors for AHK
JasperJoran
Posts: 1
Joined: 18 Jun 2019, 02:22

Came across Visual Studio Code the other day

18 Jun 2019, 02:32

So, I came across Visual Studio Code the other day at work while researching alternatives to Visual Studio 2015. It's a free, fully functional code editor from Microsoft that is designed to be used as a lightweight alternative to Visual Studio for single programmers or non-enterprise environment programmers.

Curious about it, I installed it and started looking around. I found out that there is an AHK extension for it that allows it to edit AHK code and provide syntax highlighting for AHK code. It's a fantastic editor from what I can tell and has insane functionality built into it

Just wanted to recommend anyone that is currently using another editor such as AHK Studio, AHK4SciTE, etc. to check it out and see what you think.
Last edited by JasperJoran on 19 Jun 2019, 14:01, edited 2 times in total.
Kobaltauge
Posts: 260
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: Came across Visual Studio Code the other day

18 Jun 2019, 23:45

I'm using VSC for years with Python. Love this editor mainly because ofnthe integrated debugger. As I started intensively with AHK was my first thought to use VSC, too. But my biggest issue is the missing debugger. I found something with a "neutral" code runner, but it didn't feel smooth. So I switched to AHK Studio for all my AHK coding.
need4speed
Posts: 132
Joined: 22 Apr 2016, 06:50

Re: Came across Visual Studio Code the other day

19 Jun 2019, 06:05

VSCode looks great. How to duplicate a line of code?
Kobaltauge
Posts: 260
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: Came across Visual Studio Code the other day

19 Jun 2019, 06:54

@need4speed Shift+Alt+Up and Shift+Alt+Down
need4speed
Posts: 132
Joined: 22 Apr 2016, 06:50

Re: Came across Visual Studio Code the other day

19 Jun 2019, 08:39

Thanks, got that changed now. There are plenty of shortcuts, all customizable; nice.
need4speed
Posts: 132
Joined: 22 Apr 2016, 06:50

Re: Came across Visual Studio Code the other day

19 Jun 2019, 11:04

@Kobaltauge How to open contextual AHK Help file of a selected command? Cheers.
Kobaltauge
Posts: 260
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: Came across Visual Studio Code the other day

19 Jun 2019, 11:48

Sorry. I don't understand what you want.
But try this links. They helped me a lot.

https://github.com/ahkscript/awesome-AutoHotkey/issues/154
https://www.autohotkey.com/boards/viewtopic.php?t=12525 from @haichen
need4speed
Posts: 132
Joined: 22 Apr 2016, 06:50

Re: Came across Visual Studio Code the other day

19 Jun 2019, 15:24

Kobaltauge wrote:
19 Jun 2019, 11:48
Sorry. I don't understand what you want.
in AHK Studio select a command e.g. ToolTip then press F1 -> AHK Help file is opened, and navigates to the ToolTip Help Section. How to achieve that in VSC?
User avatar
boiler
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Came across Visual Studio Code the other day

21 Jun 2019, 05:58

need4speed wrote:
19 Jun 2019, 15:24
in AHK Studio select a command e.g. ToolTip then press F1 -> AHK Help file is opened, and navigates to the ToolTip Help Section. How to achieve that in VSC?
Try Rajat's Context Sensitive Help in any Editor.
Kobaltauge
Posts: 260
Joined: 09 Mar 2019, 01:52
GitHub: MassimoCastell
Location: Germany
Contact:

Re: Came across Visual Studio Code the other day

21 Jun 2019, 06:02

need4speed wrote:
19 Jun 2019, 15:24
Kobaltauge wrote:
19 Jun 2019, 11:48
Sorry. I don't understand what you want.
in AHK Studio select a command e.g. ToolTip then press F1 -> AHK Help file is opened, and navigates to the ToolTip Help Section. How to achieve that in VSC?
Oh. I didn't know that. Sorry, can't help you.
need4speed
Posts: 132
Joined: 22 Apr 2016, 06:50

Re: Came across Visual Studio Code the other day

22 Jun 2019, 04:37

Thanks guys, I'll try that.

Edit: In fact the help files gets opened but the navigation to the selected text is missing. Only after selecting some content from the help index, then re-pressing ^2 the script works, the correct help section is displayed.
Probably Rajat's script needs an update, maybe due to help file structure changes?
User avatar
boiler
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Came across Visual Studio Code the other day

22 Jun 2019, 05:39

I don't think it is a problem with the file structure (in terms of content). I noticed that it doesn't work as well as it used to, but I think it has to do with timing. I think it tries stuffing the search text into the search box before it's ready to accept it because the help file opens slower than it used to or something (the help file is different in some ways than it used to be). I noticed that if I try again from inside VSC, it usually works, probably because the help file is already open and ready.

There is probably just some timing that needs to be updated, either by adding a Sleep in the right place or perhaps by more intelligently sensing when the help file is ready to accept a search term. I have been meaning to look at tweaking it but haven't gotten around to it yet. I might try some stuff later today.
need4speed
Posts: 132
Joined: 22 Apr 2016, 06:50

Re: Came across Visual Studio Code the other day

22 Jun 2019, 07:36

boiler wrote:
22 Jun 2019, 05:39
I have been meaning to look at tweaking it but haven't gotten around to it yet. I might try some stuff later today.
I look forward to seeing your implementation. I've tested different solutions, so far AutoGUI code works best/most reliable for me (have not found out how to extract the code, an external tool based on Alguimist code would be great). AHK Studio has issues with whitespaces and Rajat's seems to use a different approach via Send.
User avatar
boiler
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Came across Visual Studio Code the other day

24 Jun 2019, 14:10

I'm finding the original script is working fine for me. I had made some mods to my version of the script including returning focus to the editor after the correct help page is selected, and the issues I was having was returning too fast to the editor which didn't give it time to finish entering the text into the search field. By increasing the sleep time a bit before returning focus, it now works fine (and this has nothing to do with the original script).

When you first press ^2, is it navigating to the search field correctly but just doesn't fill it with the desired text?
need4speed
Posts: 132
Joined: 22 Apr 2016, 06:50

Re: Came across Visual Studio Code the other day

25 Jun 2019, 15:16

boiler, thank you for asking. in the meantime i solved the issue by changing the Help File Settings (Selected Tab). The script works now, the selected text is pasted in the Index tab and the corresponding command shows up.
As you wrote pasting the selected command in the search field is pretty slow, I failed to make it faster by using other send commands. I noticed AutoGUI's implementation is faster, also the Content tab is active not the index tab.
I you don't mind post your "return focus" code. thanks.
User avatar
boiler
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Came across Visual Studio Code the other day

26 Jun 2019, 11:26

Here's the version I modified for returning focus to the editor. It also returns the cursor to the end of the line since that's how I usually have it when I press the hotkey rather than highlighting the keyword (as you may know, the script automatically selects the keyword in the case where it's not already highlighted).

Also, I changed the hotkey to PrintScreen, but you can obviously change it to ^2 or whatever.

Code: Select all

; The hotkey below uses the clipboard to provide compatibility with the maximum
; number of editors (since ControlGet doesn't work with most advanced editors).
; It restores the original clipboard contents afterward, but as plain text,
; which seems better than nothing.

PrintScreen::
; The following values are in effect only for the duration of this hotkey thread.
; Therefore, there is no need to change them back to their original values
; because that is done automatically when the thread ends:
SetWinDelay 10
SetKeyDelay 0
AutoTrim, On

WinGet, CurrentID, ID, A

if A_OSType = WIN32_WINDOWS  ; Windows 9x
    Sleep, 500  ; Give time for the user to release the key.

C_ClipboardPrev = %clipboard%
clipboard =
; Use the highlighted word if there is one (since sometimes the user might
; intentionally highlight something that isn't a command):
Send, ^c
ClipWait, 0.1
if ErrorLevel <> 0
{
    ; Get the entire line because editors treat cursor navigation keys differently:
    Send, {home}+{end}^c
    ClipWait, 0.2
    if ErrorLevel <> 0  ; Rare, so no error is reported.
    {
        clipboard = %C_ClipboardPrev%
        return
    }
}
C_Cmd = %clipboard%  ; This will trim leading and trailing tabs & spaces.
clipboard = %C_ClipboardPrev%  ; Restore the original clipboard for the user.
Loop, parse, C_Cmd, %A_Space%`,  ; The first space or comma is the end of the command.
{
    C_Cmd = %A_LoopField%
    break ; i.e. we only need one interation.
}
IfWinNotExist, AutoHotkey Help
{
    ; Determine AutoHotkey's location:
    RegRead, ahk_dir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir
    if ErrorLevel  ; Not found, so look for it in some other common locations.
    {
        if A_AhkPath
            SplitPath, A_AhkPath,, ahk_dir
        else IfExist ..\..\AutoHotkey.chm
            ahk_dir = ..\..
        else IfExist %A_ProgramFiles%\AutoHotkey\AutoHotkey.chm
            ahk_dir = %A_ProgramFiles%\AutoHotkey
        else
        {
            MsgBox Could not find the AutoHotkey folder.
            return
        }
    }
    Run %ahk_dir%\AutoHotkey.chm
    WinWait AutoHotkey Help
}
; The above has set the "last found" window which we use below:
WinActivate
WinWaitActive
Sleep, 200
StringReplace, C_Cmd, C_Cmd, #, {#}
send, !n{home}+{end}%C_Cmd%{enter}
Sleep, 800
WinActivate, ahk_id %CurrentID%
WinWaitActive, ahk_id %CurrentID%
ControlFocus, Scintilla1, ahk_id %CurrentID%
Send, {End}
return
vinnyjames
Posts: 2
Joined: 03 Jan 2019, 11:14

Re: Came across Visual Studio Code the other day

17 Jul 2019, 01:10

I improved upon cweijan's Visual Studio Code plugin to improve the symbol finder for functions. Also added support to "goto definition" and picking up user-defined method signatures. Let me know what you guys think:

https://marketplace.visualstudio.com/items?itemName=vinnyjames.vscode-autohotkey-vj
User avatar
tank
Posts: 2853
Joined: 28 Sep 2013, 22:15
Facebook: charlie.simmons.7334
Google: ttnnkkrr
GitHub: ttnnkkrr
Location: Irving TX
Contact:

Re: Came across Visual Studio Code the other day

17 Jul 2019, 09:01

I would really appreciate instructions on things like goto definition
We are troubled on every side‚ yet not distressed; we are perplexed‚
but not in despair; Persecuted‚ but not forsaken; cast down‚ but not destroyed;
https://www.facebook.com/ahkscript.org
If you have forum suggestions please submit a pull request
Check Out WebWriter
Thanks Tank :thumbup:
User avatar
boiler
Posts: 6631
Joined: 21 Dec 2014, 02:44

Re: Came across Visual Studio Code the other day

17 Jul 2019, 17:34

Yeah, I've been using the original version by slevesque, but I never knew about cweijan's added features, let alone vinnyjames. There are no instructions on cweijan's version either, so I'd like to hear more about method symbol, code format, etc. The instructions for the extension called AutoHotkey Manager by Denis.net are a good example to follow. (that extension looks promising, although I haven't tried it yet; future updates mention a debugger among other things)

Return to “Editors”

Who is online

Users browsing this forum: No registered users and 2 guests