AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Reading commented data from multitude of files? possible?
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
unknowingly



Joined: 21 Nov 2009
Posts: 63

PostPosted: Fri Feb 12, 2010 6:07 am    Post subject: Reading commented data from multitude of files? possible? Reply with quote

Hi,
I currently have this script
Code:
!F1:: ;Alt-F1: Display all hotkeys
;jethrow
data:=
needle = ["=:].*?::|;;   ;excludes hotstrings
;needle = ["=].*?::|;;   ;doesn't exclude hotstrings
Loop, Read, %A_ScriptFullPath%
If InStr(A_LoopReadLine,"::") && Not RegExMatch(A_LoopReadLine,needle)
   data .= RegExReplace(A_LoopReadLine,".*?:: `;") "`n"
StringTrimRight, data, data, 1
MsgBox %data%
Return
mostly thanks to jethrow


which is designed to open up my ahk file, and look for all the hotkeys that have comments like:
#1: ;Win-1: This is the comment
and then display it in a messagebox.
That way, i have an easy way of making my own reminder of my hotkeys, as I don't need to update any code I just need to comment each of my new hotkeys.

However - after looking on lifehacker I came across this:
http://lifehacker.com/5457619/autohotkey-autoinclude-organizes-consolidates-your-ahk-workflow
which I would really like to use - however I am not sure how I could go about combining the two items so that I can still have my Alt-F1 hotkey.
Is it possible? If not I will probably not use the autoinclude file Sad

Thanks very much
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Fri Feb 12, 2010 7:33 am    Post subject: Reply with quote

Interesting idea..
You could modify your script to detect just the "<hotkey>::" part ---> Use it to detect all hotkeys in all the scripts you want to use
Also, modify it to also detect "Hotkey, <hotkey>" commands, in case they are used
Then if another "!F1::" is found then can either change that one, or change your script's one, into another <hotkey>
Back to top
View user's profile Send private message Visit poster's website
unknowingly



Joined: 21 Nov 2009
Posts: 63

PostPosted: Fri Feb 12, 2010 8:02 am    Post subject: Reply with quote

a_h_k wrote:
Interesting idea..
You could modify your script to detect just the "<hotkey>::" part ---> Use it to detect all hotkeys in all the scripts you want to use
Also, modify it to also detect "Hotkey, <hotkey>" commands, in case they are used
Then if another "!F1::" is found then can either change that one, or change your script's one, into another <hotkey>

Hm I am not exactly sure what you are saying.
The f1 part of my script works great, i am just not sure how to make it work after i split up my script into many files with the 'autoinclude' thing I mentioned - so it will be reading hotkeys from multiple files - at the moment it is set up to just read from one
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Fri Feb 12, 2010 8:47 am    Post subject: Reply with quote

chris96 wrote:
Hm I am not exactly sure what you are saying.
The f1 part of my script works great, i am just not sure how to make it work after i split up my script into many files with the 'autoinclude' thing I mentioned - so it will be reading hotkeys from multiple files - at the moment it is set up to just read from one

Oh .. i thought you meant that there was >1 !F1:: conflicting hotkeys in the included scripts
I get it now: The trouble is with the hotkeys ending the auto-execute section, so that any code "after" the 1st hotkey is not getting executed
I recall reading a thread about this very issue just recently, and i think the solution was to use Gosub (or a local function call) which allows each #Included file to have it's own auto-execute (or something like that) .. i'll have to try and find that thread again
Back to top
View user's profile Send private message Visit poster's website
unknowingly



Joined: 21 Nov 2009
Posts: 63

PostPosted: Fri Feb 12, 2010 11:16 am    Post subject: Reply with quote

a_h_k wrote:
chris96 wrote:
Hm I am not exactly sure what you are saying.
The f1 part of my script works great, i am just not sure how to make it work after i split up my script into many files with the 'autoinclude' thing I mentioned - so it will be reading hotkeys from multiple files - at the moment it is set up to just read from one

Oh .. i thought you meant that there was >1 !F1:: conflicting hotkeys in the included scripts
I get it now: The trouble is with the hotkeys ending the auto-execute section, so that any code "after" the 1st hotkey is not getting executed
I recall reading a thread about this very issue just recently, and i think the solution was to use Gosub (or a local function call) which allows each #Included file to have it's own auto-execute (or something like that) .. i'll have to try and find that thread again

Yeh lol that isn't the issue either there is a fix outlined in the lifehacker post for that Razz
The issue is:
So that the F1 hotkey can read the hotkeys from more than one file - currently it works by reading the hotkey information from only one file
If you want i can make a video to show it a bit more
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Fri Feb 12, 2010 1:12 pm    Post subject: Reply with quote

Found the link --> HERE
Back to top
View user's profile Send private message Visit poster's website
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Fri Feb 12, 2010 1:43 pm    Post subject: Re: Reading commented data from multitude of files? possible Reply with quote

Try something like this...
Code:
; Specifiy folder where you will put files to be included
A_WorkingDir = %A_ScriptDir%\SubFolder

; The file pathnames
MainFile := A_ScriptFullPath
IncludeFile1 = %A_WorkingDir%\IncludeFile1.ahk
IncludeFile2 = %A_WorkingDir%\IncludeFile1.ahk
IncludeFile3 = %A_WorkingDir%\IncludeFile1.ahk

; The includes
#Include %IncludeFile1%
#Include %IncludeFile2%
#Include %IncludeFile3%

; The hotkey
!F1:: ;Alt-F1: Display all hotkeys
  data:=
  needle = ["=:].*?::|;;   ;excludes hotstrings
  ;needle = ["=].*?::|;;   ;doesn't exclude hotstrings

  Loop, Read, %MainFile%
    Gosub RepeatThis
  Loop, Read, %IncludeFile1%
    Gosub RepeatThis
  Loop, Read, %IncludeFile2%
    Gosub RepeatThis
  Loop, Read, %IncludeFile3%
    Gosub RepeatThis
  Goto after

  RepeatThis:
    If InStr(A_LoopReadLine,"::") && Not RegExMatch(A_LoopReadLine,needle)
      data .= RegExReplace(A_LoopReadLine,".*?:: `;") "`n"
  Return

  after:
  StringTrimRight, data, data, 1

  MsgBox %data%
Return
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Fri Feb 12, 2010 1:55 pm    Post subject: Reply with quote

Note:
#Include Documentation wrote:
The file/directory name must not contain variable references (except %A_ScriptDir%, %A_AppData%, and %A_AppDataCommon%), double quotes, or wildcards.
Back to top
unknowingly



Joined: 21 Nov 2009
Posts: 63

PostPosted: Sat Feb 13, 2010 12:56 am    Post subject: Reply with quote

Thanks very much for the help - however that isn't actually what I am asking
My solution for running multiple scripts is fine - I just want it so the F1 hotkey mentioned in the first post can read the hotkeys from more than one file - currently it works by reading the hotkey information from only one file
If you want i can make a video to show it a bit more
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Sat Feb 13, 2010 3:13 pm    Post subject: Reply with quote

Code:
; The file pathnames
MainFile := A_ScriptFullPath
IncludeFile1 = %A_ScriptDir%\SubFolder\IncludeFile1.ahk
IncludeFile2 = %A_ScriptDir%\SubFolder\IncludeFile1.ahk
IncludeFile3 = %A_ScriptDir%\SubFolder\IncludeFile3.ahk

; The includes
#Include %A_ScriptDir%\SubFolder\IncludeFile1.ahk
#Include %A_ScriptDir%\SubFolder\IncludeFile2.ahk
#Include %A_ScriptDir%\SubFolder\IncludeFile3.ahk

; The hotkey
!F1:: ;Alt-F1: Display all hotkeys
  data:=
  needle = ["=:].*?::|;;   ;excludes hotstrings
  ;needle = ["=].*?::|;;   ;doesn't exclude hotstrings

  Loop, Read, %MainFile%
    Gosub RepeatThis
  Loop, Read, %IncludeFile1%
    Gosub RepeatThis
  Loop, Read, %IncludeFile2%
    Gosub RepeatThis
  Loop, Read, %IncludeFile3%
    Gosub RepeatThis
  Goto after

  RepeatThis:
    If InStr(A_LoopReadLine,"::") && Not RegExMatch(A_LoopReadLine,needle)
      data .= RegExReplace(A_LoopReadLine,".*?:: `;") "`n"
  Return

  after:
  StringTrimRight, data, data, 1

  MsgBox %data%
Return
Back to top
View user's profile Send private message Visit poster's website
unknowingly



Joined: 21 Nov 2009
Posts: 63

PostPosted: Sun Feb 14, 2010 3:32 am    Post subject: Reply with quote

Ah okay thanks for that. I wasn't sure how to integrate that into:
http://cache.gawker.com/assets/images/lifehacker/2010/01/autohotkey.all.ahk

So what I did was change the autoinclude script so it made a file and combined it all so I am not looking at separate files - however I discovered another problem that In the autoinclude thing It gave me an error, I believe because my main script is saved as unicode, however i dont know how to change the autoinclude file so that it will same the remporary combined script in unicode :/

So
a) not sure how to integrate that into the autoinclude.ahk file as the variable is %A_LoopFileFullPath%
b) need the autoinclude.ahk file to save the temp file as unicode - HOWever, that is not an issue if I can fix problem a Smile

Sorry for my lack of coding experience, the only coding i have done is some vb6, but I would really appricate it if you could help me integrate that (post above) into this:
http://cache.gawker.com/assets/images/lifehacker/2010/01/autohotkey.all.ahk
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Mon Feb 15, 2010 6:04 pm    Post subject: Reply with quote

I have looked at the AutoInclude script, and it is really not that user friendly .. it could be better
So i am modifying it "slightly"
Watch this space...
Back to top
View user's profile Send private message Visit poster's website
unknowingly



Joined: 21 Nov 2009
Posts: 63

PostPosted: Tue Feb 16, 2010 6:16 am    Post subject: Reply with quote

Yeh I suppose it could Smile
And wow thank you very much I am sure everyone at lifehacker would like that too Smile
Will watch closely
Back to top
View user's profile Send private message
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Fri Feb 19, 2010 2:25 pm    Post subject: Reply with quote

Detect the end of auto-execute section in the include files . . . . . . . . . . completed (16/2)

Added the Gosub's/labels for the #Includes . . . . . . . . . . completed (19/2)

Allow >1 include folders (& writes correctly to file) . . . . . . . . . . completed (27/2)

GUI for selecting Include folders . . . . . . . . . . working on

Have Include folder Set files . . . . . . . . . . completed (11/3)

Display all hotkeys that script uses (in main & its includes) . . . . . . . . . . yet to to


Last edited by a_h_k on Thu Mar 11, 2010 9:57 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
a_h_k



Joined: 02 Feb 2008
Posts: 627

PostPosted: Thu Mar 11, 2010 9:51 am    Post subject: Reply with quote

Here's the first basic working version Very Happy ---> AutoIncludes.exe

Edit: Latest version here ---> AutoIncludes

Compiled for WinXP

You need to manually (possibly will put into gui later) create your "Include Set" file, which is a .txt file containing the full path(s) to the include folders to be included

I will post the code here at some point


Last edited by a_h_k on Sun Mar 14, 2010 4:38 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group