Line based Parser for AHK Code v1.2

Post your working scripts, libraries and tools for AHK v1.1 and older
ahklearner
Posts: 313
Joined: 23 Jan 2015, 01:49

Re: Line based Parser for AHK Code v1.2

05 May 2015, 11:37

Thanks toralf :superhappy: , decreasing rows fixed it. :dance:

One more thing, I had an older version of ahk at home, that also prevented me from launching
the script, it produced some error msg. :oops:

I am no where to suggest you, but a humble request :)
Could you please add something like check ahk version and screen resolution and according to that
assign rows and give a msg that you need to update your ahk application.

and sorry I forgot something!
You guys :superhappy: ROCK :superhappy:
Truly Brilliant Code !

I always wanted to have something like this.
Could you show me a way where I can assign default path to my main script.


toralf wrote:
ahklearner wrote:Scroll View Issue - Plz Fix
Dear ahklearner,

I do not understand what the issue is. Could you please explain.
What I see:
The picture does show the upper part of the GUI.
The scroll bar is moved all the way to the bottom.
So where is the issue?

The Treeview is set up to have 50 rows r50. Is that too much for your screen and the Gui is too high so it is hiding the lower portion? Then please change in line 596 the number of rows Gui, Add, TreeView, w400 r50 hwndHTV to fit your screen.
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Line based Parser for AHK Code v1.2

05 May 2015, 13:00

Sorry but this is currently only a proof of concept. And to test the parser. I will not put more effort into the GUI or other environment checks. I currently try to translate it to the PSPad parser.
Once I'm done I will focus on generalizing the function.
ciao
toralf
ahklearner
Posts: 313
Joined: 23 Jan 2015, 01:49

Re: Line based Parser for AHK Code v1.2

06 May 2015, 06:36

Could you please guide me, Is it possible to export TreeView to Text file.
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Line based Parser for AHK Code v1.2

06 May 2015, 08:03

You could add a FileAppend to the ParseAndAddNode() function. But that will create a file that contains unsorted entries.
Or you could e.g. add a hotkey to the script that loops through the treeview and exports the information in the tree in a structured way to a file.
ciao
toralf
ahklearner
Posts: 313
Joined: 23 Jan 2015, 01:49

Re: Line based Parser for AHK Code v1.2

07 May 2015, 05:04

Sorry to bother you again :crazy:

I am a newbie and dont know much about programming.

I tried everything i could but count not achieve exporting the treeview to text file OR atleast a listbox.

My ultimate aim is to have a list box where i can search a function and execute from there rather than remembering hotkeys OR creating a gui with full of buttons for each label and function.

Thanks in advance for your help and support. :xmas:

toralf wrote:You could add a FileAppend to the ParseAndAddNode() function. But that will create a file that contains unsorted entries.
Or you could e.g. add a hotkey to the script that loops through the treeview and exports the information in the tree in a structured way to a file.
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Line based Parser for AHK Code v1.2

07 May 2015, 05:30

I'm really sorry again, but your aim is not mine and this thread is about the parser. If you want to use the parser for your own project and need help on your code please start a new thread. This will also attract more users to help you.

If you find issues in the parser or want other features of the script to be recognized by the parser please post here and I will look into it.
ciao
toralf
IMEime
Posts: 750
Joined: 20 Sep 2014, 06:15

Re: Line based Parser for AHK Code v1.2

28 May 2016, 06:08

Nice. It works fine.
I like it.

I've tried with a script (3,000 lines).
It was OK.
But, I've tried with another script (10 times longer than former).
It spent lots of time, and gained nothing.

Bye.
User avatar
joedf
Posts: 8937
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: Line based Parser for AHK Code v1.2

14 Jul 2016, 14:17

Sooooo much potential here... O_O
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Line based Parser for AHK Code v1.2

14 Jul 2016, 15:56

IMEime wrote: But, I've tried with another script (10 times longer than former).
It spent lots of time, and gained nothing..
What was the problem? What did you spend time on? What did you want to gain?
ciao
toralf
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Line based Parser for AHK Code v1.2

14 Jul 2016, 15:58

joedf wrote:Sooooo much potential here... O_O
I hope. But I do not find the time to continue with it at the moment.... :(
ciao
toralf
User avatar
jmeneses
Posts: 524
Joined: 28 Oct 2014, 11:09
Location: Catalan Republic

Re: Line based Parser for AHK Code v1.2

15 Jul 2016, 06:24

Very good script toralf, i added a label to the TreeView control to send a GoTo line to the editor UEStudio

Code: Select all

EventsTV:          
 If (WinExist("ahk_exe UEStudio.exe"))
 	If (A_GuiEvent=="DoubleClick") {
     TV_GetText(SelectedItemText, A_EventInfo)
     If (Instr(SelectedItemText,"Line")){
        nLine := RegExReplace(SelectedItemText, "(.*\(Line\s)|(\)$)")
        If nLine is number
           {         
               PostMessage , 0x111 , 32801, , , ahk_exe UEStudio.exe 
               Sleep 100
               ControlSetText, Edit2, % nLine , ahk_exe UEStudio.exe 
               ControlSend, Button4, {ENTER} ,  ahk_exe UEStudio.exe 
           }
     }
  }  
 Return
Donec Perficiam
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Line based Parser for AHK Code v1.2

15 Jul 2016, 10:23

Great extension. Thanks for sharing
ciao
toralf
User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: Line based Parser for AHK Code v1.2

16 Jul 2016, 07:00

Here the same for SciTE4AutoHotkey:

Code: Select all

;>>> Gui ---------------------------------------------------------------------------------------------------------------
BuildGui:
  CurrentFile:=""
  Gui, Add, TreeView, w400 r50 hwndHTV gEventsTV
  FillTreeView(A_ScriptFullPath)
  Gui, Show, , ParseAHK - Code Explorer - Drop your AHK files here
Return
Test:
Esc::
GuiClose:
ExitApp
GuiDropFiles:       ;only take first file
  Loop, parse, A_GuiEvent, `n
  {   
    CurrentFile:=A_LoopField 
    FillTreeView(A_LoopField)
      Break
  }
Return


FillTreeView(File){
  global HTV
  GuiControl, -Redraw, %HTV%
  TV_Delete()
  FileRead, Script, %File%
  Lines := StrSplit(Script, "`n", "`r")
  ParseAHK(Lines, HTV, DocComment := ">>>")
  GuiControl, +Redraw, %HTV%
  TV_Modify(TV_GetNext(), "VisFirst")
}

EventsTV:   
 try  {
   oSci := ComObjActive("SciTE4AHK.Application") 
   if (oSci.CurrentFile = CurrentFile)
 	  If (A_GuiEvent=="DoubleClick") {
       TV_GetText(SelectedItemText, A_EventInfo)
       If (Instr(SelectedItemText,"Line")){
          nLine := RegExReplace(SelectedItemText, "(.*\(Line\s)|(\)$)")
          If nLine is number 
              {
                winactivate, ahk_class SciTEWindow
                oSci.SendDirectorMsg("goto:" nline)
            }
       }
    }
  }  
 Return
 
;>>> Test Section for different Syntax =================================================================================
I changed the Sub and added a Var for the dropped file. So it only works if the correct EditorTab is activ.
Last edited by haichen on 17 Jul 2016, 09:16, edited 1 time in total.
toralf
Posts: 868
Joined: 27 Apr 2014, 21:08
Location: Germany

Re: Line based Parser for AHK Code v1.2

16 Jul 2016, 16:35

Thanks for sharing
ciao
toralf
User avatar
haichen
Posts: 631
Joined: 09 Feb 2014, 08:24

Re: Line based Parser for AHK Code v1.2

17 Jul 2016, 08:35

And from SciTE4AutoHotkey to the Parser ..

To get the active file from SciTE4AutoHotkey into the Parser you only need add something like this:

Code: Select all

 
ActiveFileFromS4A:
try {
  oSci := ComObjActive("SciTE4AHK.Application") 
  CurrentFile:=oSci.CurrentFile
  FillTreeView(CurrentFile)
}
return
Here is it all together:

Code: Select all

Hotkey, ^!t, ActiveFileFromS4A
;...
;>>> Gui ---------------------------------------------------------------------------------------------------------------
BuildGui:
CurrentFile:=""
  Gui, Add, TreeView, w400 r50 hwndHTV gEventsTV
  FillTreeView(A_ScriptFullPath)
  Gui, Show, , ParseAHK - Code Explorer - Drop your AHK files here
Return
Test:
Esc::
GuiClose:
ExitApp
GuiDropFiles:       ;only take first file
  Loop, parse, A_GuiEvent, `n
  {   
    CurrentFile:=A_LoopField 
    FillTreeView(A_LoopField)
      Break
  }
Return


FillTreeView(File){
  global HTV
  GuiControl, -Redraw, %HTV%
  TV_Delete()
  FileRead, Script, %File%
  Lines := StrSplit(Script, "`n", "`r")
  ParseAHK(Lines, HTV, DocComment := ">>>")
  GuiControl, +Redraw, %HTV%
  TV_Modify(TV_GetNext(), "VisFirst")
}

EventsTV:   
 try  {
   oSci := ComObjActive("SciTE4AHK.Application") 
   if (oSci.CurrentFile = CurrentFile)
 	  If (A_GuiEvent=="DoubleClick") {
       TV_GetText(SelectedItemText, A_EventInfo)
       If (Instr(SelectedItemText,"Line")){
          nLine := RegExReplace(SelectedItemText, "(.*\(Line\s)|(\)$)")
          If nLine is number 
              {
                winactivate, ahk_class SciTEWindow
                oSci.SendDirectorMsg("goto:" nline)
            }
       }
    }
  }  
 Return
 
 ActiveFileFromS4A:
try {
oSci := ComObjActive("SciTE4AHK.Application") 
CurrentFile:=oSci.CurrentFile
FillTreeView(CurrentFile)
}
return

;>>> Test Section for different Syntax =================================================================================
*Edit Ooops and Sorry: I changed droppedFile to currentFile and added 1 line.
Now both doubbleclick and Hotkey work together.
So here is the whole thing

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 86 guests