AutoHotkey Community

It is currently May 27th, 2012, 2:33 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: February 12th, 2010, 7:07 am 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
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/autohotke ... k-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 :(

Thanks very much


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 8:33 am 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
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>


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 9:02 am 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 9:47 am 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 12:16 pm 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
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 :P
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 2:12 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
Found the link --> HERE


Report this post
Top
 Profile  
Reply with quote  
PostPosted: February 12th, 2010, 2:43 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 12th, 2010, 2:55 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 1:56 am 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 13th, 2010, 4:13 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 14th, 2010, 4:32 am 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
Ah okay thanks for that. I wasn't sure how to integrate that into:
http://cache.gawker.com/assets/images/l ... ey.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 :)

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/l ... ey.all.ahk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 15th, 2010, 7:04 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
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...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 16th, 2010, 7:16 am 
Offline

Joined: November 21st, 2009, 11:06 am
Posts: 63
Yeh I suppose it could :)
And wow thank you very much I am sure everyone at lifehacker would like that too :)
Will watch closely


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: February 19th, 2010, 3:25 pm 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
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 March 11th, 2010, 10:57 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 11th, 2010, 10:51 am 
Offline

Joined: February 2nd, 2008, 4:35 am
Posts: 643
Here's the first basic working version :D ---> 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 March 14th, 2010, 5:38 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Alpha Bravo, Google [Bot], LazyMan, rbrtryn and 19 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group