[Script] CodeQuickTester - Write and run code without saving to a temporary file

Post your working scripts, libraries and tools
User avatar
derz00
Posts: 495
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: CodeQuickTester - Write and run code without touching the file system

18 Mar 2018, 16:58

For me, the syntax tips only work until I make changes to the code--so starting a new CQT, I can select the words in the default text, but when I start typing anything, I cannot get syntax tips for anything.
try it and see
...
User avatar
derz00
Posts: 495
Joined: 02 Feb 2016, 17:54
GitHub: derz00
Location: Middle of the round cube

Re: CodeQuickTester - Write and run code without touching the file system

19 Mar 2018, 09:45

Sorry that was not my main PC and AHK was still at 1.22. After updating, it looks like it works again, but ran out of time to test thoroughly :)
try it and see
...
StefOnSteroids
Posts: 39
Joined: 08 Aug 2015, 10:22

Re: CodeQuickTester - Write and run code without touching the file system

09 May 2018, 09:50

Great tool, thank you so much! :clap:
How do I make it remember the location of my AutoHotkeyU64.exe?
Or asked another way, where does the script expect to find AutoHotkeyU64.exe? Where would I have to put it -relative to AutoHotkeyU64.exe, so it can find the exe by itself?

It won't remember my setting in Edit > Script Options, so I guess I have to hard-code the path somewhere in the script itself?

Maybe I should mention that I run the script compiled, because running the ahk-file brings up this error:

---------------------------
QuickCodeTester.ahk
---------------------------
Error: 0x80020006 - Unbekannter Name.

Specifically: querySelectorAll

Line#
2232: Return,this.Lookup
2235: this.Commands := {}
2236: Try
2237: Page := this.GetPage("commands/index.htm")
2238: Try
2239: rows := Page.querySelectorAll(".info td:first-child a")
2240: Catch
---> 2241: rows := Page.body.querySelectorAll(".info td:first-child a")
2242: Loop,rows.length
2243: For i,text in StrSplit((row := rows.Item(A_Index-1)).innerText, "/")
2244: if RegExMatch(text, "^[\w#]+", Match) && !this.Commands.HasKey(Match)
2245: this.Commands[Match] := "commands/" RegExReplace(row.getAttribute("href"), "^about:")
2248: this.Variables := {}
2249: Try
2250: Page := this.GetPage("Variables.htm")

Continue running the script?
---------------------------
Ja Nein
---------------------------
GeekDude
Posts: 836
Joined: 02 Oct 2013, 22:13

Re: CodeQuickTester - Write and run code without touching the file system

09 May 2018, 21:54

StefOnSteroids wrote:Great tool, thank you so much! :clap:
How do I make it remember the location of my AutoHotkeyU64.exe?
Or asked another way, where does the script expect to find AutoHotkeyU64.exe? Where would I have to put it -relative to AutoHotkeyU64.exe, so it can find the exe by itself?

It won't remember my setting in Edit > Script Options, so I guess I have to hard-code the path somewhere in the script itself?

The default location to find AHK is specified in the Settings array at the top of the script. You could change it there, or if you have AHK installed to your system you could re-run the installer and change the system-wide default AHK version to be the 64 bit one.

Code: [Select all] [Download] GeSHi © Codebox Plus

Settings :=
( LTrim Join Comments
{
; When True, this setting may conflict with other instances of CQT
"GlobalRun": False,

; Script options
"AhkPath": A_AhkPath, ; <-------------------- DEFINED HERE --------------------
"Params": "",

____________________________________________________________________________________________________

StefOnSteroids wrote:Maybe I should mention that I run the script compiled, because running the ahk-file brings up this error:

That error is very strange. Compiling the script makes the error go away? That is not what I would have expected. Could you please run this and copy the output into a forum post?

Code: [Select all] [Download] GeSHi © Codebox Plus

MsgBox,
(
AHK Version: %A_AhkVersion%
OS Version: %A_OSVersion%
Pointer Size: %A_PtrSize%
Unicode: %A_IsUnicode%
Language: %A_Language%
Admin: %A_IsAdmin%
WinDir: %A_WinDir%
)

Also, have you made any nonstandard changes to your OS's configuration such as disabling Internet Explorer or making extensive modifications to the registry? Are you running your script with some software such as WINE, CrossOver, PlayOnLinux, or ReactOS?
StefOnSteroids
Posts: 39
Joined: 08 Aug 2015, 10:22

Re: CodeQuickTester - Write and run code without touching the file system

09 May 2018, 22:33

Thanks for checking into this.
In earlier attempts I had already tried to fiddle with the entries in the script section
"AhkPath": A_AhkPath,
but only managed to trigger an error in line 10 when I tried to compile the script.
Thanks to your confirmation that this is indeed the place to set the path to ahk.exe, I now managed to make it work by providing a fully specified path with drive letter. :idea:
Before that, I had probably made syntax errors in my trials to keep things portable.


GeekDude wrote:That error is very strange. Compiling the script makes the error go away? That is not what I would have expected. Could you please run this and copy the output into a forum post?

Yes, compiling the script makes the error go away. Here's the output from your code snippet.
---------------------------
AHK_CQT_226706799
---------------------------
AHK Version: 1.1.28.01
OS Version: WIN_7
Pointer Size: 8
Unicode: 1
Language: 0407
Admin: 0
WinDir: C:\windows
---------------------------
OK
---------------------------

GeekDude wrote:Also, have you made any nonstandard changes to your OS's configuration such as disabling Internet Explorer or making extensive modifications to the registry? Are you running your script with some software such as WINE, CrossOver, PlayOnLinux, or ReactOS?

Nothing of the sort. Standard Win7 Home Edition, no registry changes or other system changes I am aware of, No WINE or ReactOS etc, these terms I only know from hearsay.

Anyway, I don't mind compiling the script. Really glad I no longer have to specify the ahk-exe-path each and every time. Hoever, if I could make it portable (independent from drive letter) - that would be totally awesome. But I don't want to over-extend your helpfulness. Thanks for a fantastic tool.
GeekDude
Posts: 836
Joined: 02 Oct 2013, 22:13

Re: CodeQuickTester - Write and run code without touching the file system

10 May 2018, 11:14

StefOnSteroids wrote:Thanks for checking into this.

Thanks for being patient with my checking :).


StefOnSteroids wrote:
GeekDude wrote:That error is very strange. Compiling the script makes the error go away? That is not what I would have expected. Could you please run this and copy the output into a forum post?

Yes, compiling the script makes the error go away. Here's the output from your code snippet.
---------------------------
AHK_CQT_226706799
---------------------------
AHK Version: 1.1.28.01
OS Version: WIN_7
Pointer Size: 8
Unicode: 1
Language: 0407
Admin: 0
WinDir: C:\windows
---------------------------
OK
---------------------------

GeekDude wrote:Also, have you made any nonstandard changes to your OS's configuration such as disabling Internet Explorer or making extensive modifications to the registry? Are you running your script with some software such as WINE, CrossOver, PlayOnLinux, or ReactOS?

Nothing of the sort. Standard Win7 Home Edition, no registry changes or other system changes I am aware of, No WINE or ReactOS etc, these terms I only know from hearsay.

I set up a Windows 7 Home Premium machine and downloaded AHK Portable and CodeQuickTester v2.6 to test your issue. I was able to reproduce it by downgrading from Internet Explorer 11 to 8. The functionality that triggers the error is the integration with the help file (basically an offline website), which relies on certain features that appear to be unavailable in IE8.

When CodeQuickTester is launched it uses Internet Explorer's API to load the help file in the background and pull out information about commands to be displayed in the status bar. By default it looks for the help file at %A_AhkPath%\..\AutoHotkey.chm. When you compile a script and AutoHotkey is not installed (running in a portable environment), A_AhkPath will be blank. This makes CodeQuickTester unable to find and load the help file, which is why it doesn't trigger the error.

I'll release a fix in the next update that either suppresses the error and disables the functionality, or uses some other method of reading the help file that works with IE8. Until then, I have a few solutions that you could use to get rid of the error:

  1. Update Internet Explorer to version 11 (best solution, as then the integration will work)
  2. Put HelpFile:="" at the top of the script to disable the help file integration
  3. Move or rename the help file so that CodeQuickTester can not find it (effectively disables the integration)

StefOnSteroids wrote:Anyway, I don't mind compiling the script. Really glad I no longer have to specify the ahk-exe-path each and every time. Hoever, if I could make it portable (independent from drive letter) - that would be totally awesome. But I don't want to over-extend your helpfulness.

I believe in being as helpful as the situation permits :) . The AHK Path is a relative path from the specified working directory, so assuming that AHK is in the same working directory (generally the same folder) as CodeQuickTester you should be able to specify "AhkPath": "AutoHotkeyU64.exe", and it will just work. If you aren't using the same working directory but still want to pull from the script's directory, you can use "AhkPath": A_ScriptDir "\AutoHotkeyU64.exe",


StefOnSteroids wrote:Thanks for a fantastic tool.

You're welcome! :thumbup:
StefOnSteroids
Posts: 39
Joined: 08 Aug 2015, 10:22

Re: [Script] CodeQuickTester - Write and run code without touching the file system

10 May 2018, 12:07

:o I am very impressed by the thorough analysis you applied to tackle this issue.
Didn't mean to cause so much aggravation, this seems quite an ordeal you had to go through to track it down. :shock:
Thanks a ton!

Despite being the best option, updating Internet Explorer is only feasible for my own machine. I rather remain portable (flexible) to work on other hosts without touching their system.

Moving or renaming the help file is also out of the question, this would open a can of worms with other tools I have set up with portable paths in editors and in my file manager, to open specific help pages from various places and menus. This structure has grown over the years, I wouldn't want to mess it up.

So I'll go with solution 2 - HelpFile:=""
I don't really need the help functionality, anyway, I already have enough links to help file pages as mentioned above.

I am still struggling with the relative path thingie, though.
- My script-dir = \Toolbox\ahk\Tools\QuickCodeTester
- My ahk.exe resides here: \Toolbox\ahk\AutoHotkeyU64.exe

Would you do me a favor and figure out the portable syntax I need? I have tried all kinds of variations along the lines of
"AhkPath": A_ScriptDir "\..\..\..\AutoHotkeyU64.exe",
but nothing really works out so far.

Many thanks.
GeekDude
Posts: 836
Joined: 02 Oct 2013, 22:13

Re: [Script] CodeQuickTester - Write and run code without touching the file system

10 May 2018, 12:25

This code will get the relative path between any two given directories. My example assumes that the path is \Toolbox\ahk\Tools\QuickCodeTester\Tester.exe, rather than \Toolbox\ahk\Tools\QuickCodeTester.exe (your post was a little ambiguous)

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


When I ran it the output I received was "AhkPath": A_ScriptDir "\..\..\AutoHotkeyU64.exe",
StefOnSteroids
Posts: 39
Joined: 08 Aug 2015, 10:22

Re: [Script] CodeQuickTester - Write and run code without touching the file system

10 May 2018, 13:02

Sorry for the ambiguity. Based on your hint with
"AhkPath": A_ScriptDir "\AutoHotkeyU64.exe"
I expected something involving A_ScriptDir and a bunch of \..\.. the way I am used to from other programs. So I went ahead and read out A_ScriptDir and the MsgBox specified it without the exe, only the path component alone.

Meanwhile I had been tinkering with
SplitPath, A_ScriptDir,,,,,DriveLetter (after some extensive reading in the help file) but then failed again when constructing the whole enchilada for "AhkPath": ...

So anyway, I am really glad your reply came in and put an end to my agonizing.
Your function is WAY over my head :oops: , but it works perfectly fine. There is no way I would have ever figured out how to make it portable.
Thanks again. I really appreciate it. :thumbup:
brutus_skywalker
Posts: 179
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: [Script] CodeQuickTester - Write and run code without touching the file system

10 May 2018, 23:33

If i may make a suggestion that would make it tons better. Could you consider adding np++ like functionality where all text in current window is used as a wordlist to autocomplete text, this function i reckon should make it a breeze to implement.... https://autohotkey.com/board/topic/96129-ahk-l-custom-autocompletion-for-edit-control-with-drop-down-list.

Great tool regardless...
Outsourcing Clicks & Presses Since 2004.
brutus_skywalker
Posts: 179
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: [Script] CodeQuickTester - Write and run code without touching the file system

13 May 2018, 04:22

On the subject of my suggestion above(which i opted out of editing), check THIS out, it basically does what i asked for above,just across multiple editors.

Here's the code 'snippet' is used to retrieve the alphabetically ranked word-list from the active editor, just thought it would save you sometime if you chose to do it...



Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Outsourcing Clicks & Presses Since 2004.
GeekDude
Posts: 836
Joined: 02 Oct 2013, 22:13

Re: [Script] CodeQuickTester - Write and run code without touching the file system

13 May 2018, 08:39

StefOnSteroids wrote:Thanks again. I really appreciate it. :thumbup:

Glad I could help! :)

brutus_skywalker wrote:If i may make a suggestion that would make it tons better. Could you consider adding np++ like functionality where all text in current window is used as a wordlist to autocomplete text, this function i reckon should make it a breeze to implement.... https://autohotkey.com/board/topic/96129-ahk-l-custom-autocompletion-for-edit-control-with-drop-down-list.

Unfortunately that function cannot be applied to what is being done with CodeQuickTester. It appears to be more for navigation bars or search menus.

brutus_skywalker wrote:On the subject of my suggestion above(which i opted out of editing), check THIS out, it basically does what i asked for above,just across multiple editors.

Check THIS out ;)

Image
brutus_skywalker
Posts: 179
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: [Script] CodeQuickTester - Write and run code without touching the file system

14 May 2018, 00:03

GeekDude wrote:Unfortunately that function cannot be applied to what is being done with CodeQuickTester. It appears to be more for navigation bars or search menus.


It actually works on edit controls as well,here:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus





GeekDude wrote:Check THIS out ;)
Image


THAT'S WHAT I WAS SAYIN' :superhappy: , is it going to be an update?
Outsourcing Clicks & Presses Since 2004.
GeekDude
Posts: 836
Joined: 02 Oct 2013, 22:13

Re: [Script] CodeQuickTester - Write and run code without touching the file system

15 May 2018, 09:32

brutus_skywalker wrote:THAT'S WHAT I WAS SAYIN' :superhappy: , is it going to be an update?


It's not quite ready for prime time, but here's a copy of my current test https://p.ahkscript.org/?p=9937466b

Let me know what you think! I'm sure there's some aspects of it that I haven't considered but as far as functionality goes I think it's almost there.
brutus_skywalker
Posts: 179
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: [Script] CodeQuickTester - Write and run code without touching the file system

16 May 2018, 13:42

GeekDude wrote:
brutus_skywalker wrote:THAT'S WHAT I WAS SAYIN' :superhappy: , is it going to be an update?


It's not quite ready for prime time, but here's a copy of my current test https://p.ahkscript.org/?p=9937466b

Let me know what you think! I'm sure there's some aspects of it that I haven't considered but as far as functionality goes I think it's almost there.


Objectively speaking, RADDD!. Text completion is basically instantaneous,so it doesn't slow you down & you also included ahk commands in addition to auto-completing text in the editor,which is just icing on the cake. If possible tooltips would be nice for the commands,i imagine it's easy enough given rajat's intellisense script uses the commands.txt included with ahk.

BTW, notepad++ doesn't even have case corrective auto-completion(i.e case of typed string must match a suggestion) which was a freaking pain,guess i have a new default ahk editor. :salute:

Love it, and thanks for this dude.



EDIT:
One more thing i noticed,if a string contains a integer it's split into multiple strings instead of being one,i.e Unicode2Ascii is only autocompleted as 'Unicode' and 'Ascii' not as one string, i understand the reasons for this, especially symbols but i think exceptions should be made for integers & certain symbols such as '_' which are often used to define variables & functions.
Outsourcing Clicks & Presses Since 2004.
GeekDude
Posts: 836
Joined: 02 Oct 2013, 22:13

Re: [Script] CodeQuickTester - Write and run code without touching the file system

18 May 2018, 19:39

brutus_skywalker wrote:One more thing i noticed,if a string contains a integer it's split into multiple strings instead of being one,i.e Unicode2Ascii is only autocompleted as 'Unicode' and 'Ascii' not as one string, i understand the reasons for this, especially symbols but i think exceptions should be made for integers & certain symbols such as '_' which are often used to define variables & functions.


What do you think about allowing keywords containing numbers as long as the keyword does not start with the number? Right now the rule is alpha characters and underscore only.
brutus_skywalker
Posts: 179
Joined: 24 Dec 2016, 13:16
Location: Antarctica

Re: [Script] CodeQuickTester - Write and run code without touching the file system

19 May 2018, 08:28

GeekDude wrote:What do you think about allowing keywords containing numbers as long as the keyword does not start with the number? Right now the rule is alpha characters and underscore only.



I think that should cover an absolute majority of use cases. I've never seen code where a function/var name starts with an integer.



Edit:
On another note, Just realized that command usage is shown on the status bar for command on caret position,never looked there before despite using for ages...till now... I think you might consider using a different font face and/or making it bold+italic or even a different color to make it standout,that's at least how i modified it for my use. All aside sweet usage of the status bar,lest we miss it.
Outsourcing Clicks & Presses Since 2004.
GeekDude
Posts: 836
Joined: 02 Oct 2013, 22:13

Re: [Script] CodeQuickTester - Write and run code without touching the file system

02 Jun 2018, 21:54

CodeQuickTester v2.7 has been released

Please see the original post for a link to the release and revision history pages.



Changes

  • Improved script options menu file selector default folders/files
  • Fixed help file integration when only IE8 is available
  • Various improvements to Wine compatibility
  • Reorganized the menu bar
  • Made the default pastebin dialog values more generic

Additions

  • Dynamic keyword autocompletion
  • Menu for inserting includes
  • Menu button/hotkey for exiting (Ctrl+W)
  • Menu button to open the working directory
  • Support for an external Settings.ini file
  • Support for compiling into a portable exe via AutoHotkey_H


The original post has been updated

It now includes a lot of information about steps you can optionally take to integrate CodeQuickTester into your system. Please go back and re-read it!
StefOnSteroids
Posts: 39
Joined: 08 Aug 2015, 10:22

Re: [Script] CodeQuickTester - Write and run code without saving to a temporary file

04 Jun 2018, 04:21

Great idea to allow a settings file - so users can keep their custom font sizes, colors etc from version to version.
Would you please provide a sample settings.ini or give a few guidelines what the ini-file must look like?

Return to “Scripts and Functions”

Who is online

Users browsing this forum: binghez, cocobanana and 17 guests