AutoHotkey Community

It is currently May 26th, 2012, 2:02 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject:
PostPosted: September 23rd, 2008, 3:16 pm 
Thanks, hutch! Much appreciated!


Report this post
Top
  
Reply with quote  
 Post subject: Won't Compile Well
PostPosted: October 8th, 2008, 7:41 pm 
Offline

Joined: September 16th, 2008, 7:53 pm
Posts: 77
Greetings, Gurus.

Anybody know why the ^z menu won't show when I compile the script into an executable?

Any help would be appreciated.

Hutch


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Final Customized Version
PostPosted: October 11th, 2008, 1:31 pm 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
Hey all,

I have modified Hutch's script to fulfill my requirements and make it more complete i guess, as such i think everyone can safely add this script to their includes directory and use it easily now!
So this is the long awaited summary I've been waiting for, hehe :)

Quote:
Features :
- display hotstrings (and expansion if no ;; comment), allows :*: hotstrings and other variations (i.e. :o: ...etc)
- display Hotkey (only if comment ;;)
- ignore single comment lines
- include all other features from before (i.e. display hotstrings, hotkeys, ;; comments ...etc)
- standalone script can be included in file - see below

e.g. #include KeyList.AHK
#z:: ;;Show this list
KeyList(A_ScriptFullPath)
KeyWait, z
Progress, off
return



Save as KeyList.ahk
Code:
; http://www.autohotkey.com/forum/topic215.html
;*******************************************************************************
; Extract a list of Hotstrings and Hotkeys from this script and display them
;*******************************************************************************
; Modified by Vixay Xavier on Sat October 11, 2008 06:02:29 PM
;#SingleInstance force

KeyList(scriptfile)
{
  AutoTrim,off
  Loop,Read,%scriptfile%
  {
    Line=%A_LoopReadLine%
; Only show lines that contain double semicolons
    IfInString,Line,`;`;
    {
      StringLeft,First2Chars,Line,2
      StringLeft,FirstChar,Line,1
; Insert blank or comment lines (start with double semicolon)
      IfEqual,First2Chars,`;`;
      {
        StringTrimLeft,Desc,Line,2
        KeyList=%KeyList%%Desc%`n
        Continue
      }
; Insert Hotkeys and Hotstrings (must contain double colon)
      IfInString,Line,`:`:
      {
; Extract description (after last semicolon)
        StringSplit,Desc,Line,`;`:
        StringTrimLeft,Desc,Desc%Desc0%,0
; If description is blank, use command or hotstring text instead
        If Desc=
        {
          EnvSub,Desc0,2
          StringTrimLeft,Desc,Desc%Desc0%,0
        }
; Extract keys
        StringSplit,Keys,Line,`:
; Hotstrings (start with double colon)
        IfEqual,First2Chars,`:`:
        {
          Keys=%Keys3%
          IfEqual,Desc,,SetEnv,Desc,%Keys5%
        }
; Hotstrings (start with single colon) - i.e. those hotstrings with options given. e.g. :c:tt::ta ta
        Else IfEqual,FirstChar,`:
        {
          Keys=%Keys3%
          IfEqual,Desc,,SetEnv,Desc,%Keys5%
          ;MsgBox, 1st char = %FirstChar% 2 chars = %First2Chars% split = %Keys% line = %line% ;DEBUG
        }       
; Hotkeys (start with anything else)
        Else
        {
          StringReplace,Keys,Keys1,#,Win- ;Why the Keys1 here instead of Keys?
          StringReplace,Keys,Keys,!,Alt-
          StringReplace,Keys,Keys,^,Ctrl-
          StringReplace,Keys,Keys,+,Shift-
          StringReplace,Keys,Keys,`;,
        }
; Add to the list
; Make keys 15 long with trailing spaces to keep the list neatly formatted

        Keys=%Keys%               !
        StringLeft,Keys,Keys,15
        Desc=%Keys% %Desc%
        KeyList=%KeyList%%Desc%`n
; Keep track of longest line to set window width later
        StringLen,Len,Desc
        If Len > %MaxLen%
          MaxLen = %Len%
      }
    }
  }
; Now show the list
  EnvMult,MaxLen,8.0 ; pixel width of 1 character
  EnvAdd,MaxLen,20 ; + 2 x 10 pixel margins
  StringTrimRight,KeyList,KeyList,1
;  Sort, KeyList, P16 ; sort the comments
  Progress, M2 C00 ZH0 FS10 W%MaxLen%,%KeyList%,,Hotkeys and Hotstrings list,courier new
  KeyList=
  MaxLen=
Return
}

;a function to take care of replacing symbols in shortcut keys with their words
HumanReadableShortcut(key)
{
  StringReplace,Key,Key,+,Shift%A_Space%+%A_Space%
  StringReplace,Key,Key,#,Win%A_Space%+%A_Space%
  StringReplace,Key,Key,!,Alt%A_Space%+%A_Space%
  StringReplace,Key,Key,^,Ctrl%A_Space%+%A_Space%
  ;StringReplace,Key,Key,),String%A_Space%is%A_Space%
  Return %Key%
}

; FOR TESTING AS STANDALONE SCRIPT, if it is included in another script it will be safely ignored

; ;****************************************************
; ;Add Hotkeys and Hotstrings Below
; ;****************************************************
; ;;  HotKeys

; ^z::  ;;Show This List - use the following code in your function call for script
   KeyList(A_ScriptFullPath)
   Sleep 1000
   KeyWait, z
   Progress, off
 ExitApp

;add comments like these to your own script to make the
; output of this script easier to read
;;===Global Hotstrings===
::t1::tester! ;;
:c:t2::testmy! ;;
; ;****************************************************
; ;Add the List to the AHK Menu
; ;****************************************************
  ; Menu,Tray,Add,Hot&keys list,KeyList
  ; Menu,Tray,Default,Hot&keys list
; ;Run once
  ; KeyList(%A_ScriptFullPath%)
  ; KeyWait, z
  ; Progress, off


also hutch, it won't show when compiled, because when an exe, it can't read the source and show the summary! so you have to point it to the source file!!! that is if you want to use the feature in the executable :)

i.e.
myscript.exe
myscript.ahk - must be in same dir as executable
or you could hardcode it in

code in myscript.ahk should be
Quote:
#z:: ;;Show this list
If A_IsCompiled
{
StringTrimRight, script, A_ScriptFullPath, 3
script = %script%ahk
}
Else
{
script = %A_ScriptFullPath%
}
KeyList(script)
Sleep 1000
KeyWait, z
Progress, off


Report this post
Top
 Profile  
Reply with quote  
PostPosted: October 11th, 2008, 6:50 pm 
Offline

Joined: September 28th, 2006, 5:33 pm
Posts: 58
I was about try writing exactly such a script--I'm glad I found this thread. I'm having trouble integrating it though. I've added
Code:
#Include KeyList.ahk


#z:: ;;Show this list
KeyList(A_ScriptFullPath)
KeyWait, z
Progress, off
return

to the top of my main ahk script and created the KeyList.ahk file based on vixay's code. When I save and reload the script, the #z shortcut is displayed in a pop up window that disappears after a second, then the script also exits. I tried running the KeyList script directly: same result, though the demo hotkeys are displayed for that brief second. What am I missing here?

Thanks,
Mike


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2008, 6:54 pm 
Offline

Joined: September 28th, 2006, 5:33 pm
Posts: 58
Got it. In this section of the KeyList code:
Code:
; FOR TESTING AS STANDALONE SCRIPT, if it is included in another script it will be safely ignored

; ;****************************************************
; ;Add Hotkeys and Hotstrings Below
; ;****************************************************
; ;;  HotKeys

; ^z::  ;;Show This List - use the following code in your function call for script
   KeyList(A_ScriptFullPath)
   Sleep 2000
   KeyWait, z
   Progress, off
  ExitApp

I commented out the ExitApp line. Now the window pops up when I first run my main script, which isn't ideal, but otherwise seems to work correctly.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 11th, 2008, 7:56 pm 
Offline

Joined: September 28th, 2006, 5:33 pm
Posts: 58
OK, two other issues, which may be related to each other:
1. I'd prefer that the popup show until any key is pressed--I don't want to hold down the hotkey.

2. I'd like to reassign the hotkey to call KeyList to CapsLock & Space. Attempting to use CapsLock , either by itself or in combination with other keys, causes problems. The popup window appears but just as quickly disappears, "flickering" as long as the trigger is held down.

Thanks,
Mike


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2008, 5:40 am 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
mkny wrote:
OK, two other issues, which may be related to each other:
1. I'd prefer that the popup show until any key is pressed--I don't want to hold down the hotkey.

2. I'd like to reassign the hotkey to call KeyList to CapsLock & Space. Attempting to use CapsLock , either by itself or in combination with other keys, causes problems. The popup window appears but just as quickly disappears, "flickering" as long as the trigger is held down.

Thanks,
Mike


1. See the thread some of the previous incarnations do that, you have to use another method, rather than a PROGRESS window...
you can also comment out the "Progress OFF" line to leave it up... play around

2. That is a known issue and quite complicated to fix. I suggest you research that.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 20th, 2008, 9:57 pm 
Offline

Joined: September 28th, 2006, 5:33 pm
Posts: 58
Thanks, I'll do some digging.

I resolved the CapsLock issue by applying another script form the forum that calls for a double tap of CapsLock to toggle it. Now it works fine as a modifier.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 2nd, 2008, 4:36 pm 
Offline

Joined: September 28th, 2006, 5:33 pm
Posts: 58
Here another question for anyone: how would you edit AutoHotstring.ahk to append " ;;" to every hotstring it generates. I tried inserting that sequence into a couple of places in the script without success. I realize `; is the escape sequence, but how do you double them up? And where the best place to insert them?

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 4th, 2008, 5:35 am 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
mkny wrote:
Here another question for anyone: how would you edit AutoHotstring.ahk to append " ;;" to every hotstring it generates. I tried inserting that sequence into a couple of places in the script without success. I realize `; is the escape sequence, but how do you double them up? And where the best place to insert them?

Thanks.


Link to source?
`;`; should double it up.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: December 8th, 2008, 9:32 pm 
Offline

Joined: September 28th, 2006, 5:33 pm
Posts: 58
vixay wrote:
`;`; should double it up.

That works. For some stupid reason I had inserted a space between them. Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: January 12th, 2009, 3:47 am 
Offline

Joined: November 6th, 2007, 7:48 am
Posts: 26
Location: Sydney
I've used a older/earlier version of this script for quite some time so foregive me my ignorance ... but how the heck am I suppose to use this script? :?: :oops:
maybe I'm just not seeing the instruction...

I placed the 'KeyList.ahk' in C:\Program Files\AutoHotkey\Lib

As a next step I assume I have to add something to the actual script I want to equip with the hotkey list.

all my hotkeys have comments similar to
Code:
; hotkey WIN + 2
#2:: ;;initialise results display to Default


will I need to change the syntax or write a list of the hotkeys?

I tried to make some sense out of the last 20 lines but ... well it's a Monday here...


Report this post
Top
 Profile  
Reply with quote  
 Post subject: two column display
PostPosted: June 4th, 2009, 9:23 pm 
Offline

Joined: September 28th, 2006, 5:33 pm
Posts: 58
I've added so many hotkeys/strings that the popup window is getting chopped off by the bottom of my screen. Is it possible to make the popup split results into two columns (ideally hotkeys in one column, hotstrings in the other.) Thanks, Mike


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2009, 3:24 am 
Offline

Joined: March 27th, 2009, 12:46 pm
Posts: 76
Location: Dublin, IE
sebastian wrote:
...but how the heck am I suppose to use this script?

Just add ShowKeyList("[Hotkey]") function to your script. Also, you should rename "KeyList.ahk" to ShowKeyList.ahk

Code:
; hotkey WIN + 2
#2::ShowKeyList("2") ;;initialise results display to Default

_________________
My Scripts


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 21st, 2009, 3:27 am 
Offline

Joined: March 27th, 2009, 12:46 pm
Posts: 76
Location: Dublin, IE
I've modified the progress bar to look similar to Google's Gmail/Reader hotkey list with a black background and yellow font.
Code:
...
;  Sort, KeyList, P16 ; sort the comments
  Progress,CWBlack R20-20 CTYellow B C00 ZH0 FS12 WS1000 W%MaxLen%,%KeyList%,,Hotkeys and Hotstrings list,courier new
  WinSet, Transparent, 200, Hotkeys and Hotstrings list
...

_________________
My Scripts


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 17 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:
cron
Powered by phpBB® Forum Software © phpBB Group