AutoHotkey Community

It is currently May 27th, 2012, 3:48 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 84 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6
Author Message
 Post subject:
PostPosted: July 29th, 2010, 2:07 pm 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
That is strange, you should post a snippet of your script, and i'll try it out.
Is it a permissions issue? maybe the script cannot read the file you are giving it? are you running from an exe? (it can't parse exe files).


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

Joined: February 14th, 2006, 6:00 pm
Posts: 40
vixay wrote:
That is strange, you should post a snippet of your script, and i'll try it out.
Is it a permissions issue? maybe the script cannot read the file you are giving it? are you running from an exe? (it can't parse exe files).


No, I don't run it from an exe.

How can I call the script to see it?

(I put the include in the autoload section now)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 2:16 pm 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
rosto wrote:
vixay wrote:
That is strange, you should post a snippet of your script, and i'll try it out.
Is it a permissions issue? maybe the script cannot read the file you are giving it? are you running from an exe? (it can't parse exe files).


No, I don't run it from an exe.

How can I call the script to see it?

(I put the include in the autoload section now)


I am not sure I understand what you are saying. I was asking you to paste a copy of your script here, so that I can try to run it and see what the problem is. If you are uncomfortable doing that, then it's hard to figure out what could be wrong.
Are you using the latest version of AHK?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 29th, 2010, 2:55 pm 
Offline

Joined: February 14th, 2006, 6:00 pm
Posts: 40
Ah sorry,

My script I try to run is

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
; Modified by infogulch    on Mon September 21, 2009 08:30:00 PM
; Modified by infogulch    on Tue September 22, 2009 03:00:00 PM
; Modified by Bousch on 2010-02-09 18:13
;          changed view to listview
;          added sorting with ctrl-1 (name) and Ctrl-2 (text)
;          activate hotkey with enter or dblclick

;#SingleInstance force

keylist=

ShowListView:
   Gui, Destroy
   Gui, Add, ListView, xm r40 w450 Grid vMyListView gMyListView AltSubmit, Name|Text|key
   Gui, Add, Button, Hidden Default, OK

   split_chars := "¬"
   loop, parse, keylist, `n, `r
   {
      ; initialize vars because stringsplit doesn't
      key_array1 =
      key_array2 =
      key_array3 =
      StringSplit, key_array, A_LoopField, %split_chars%
      ; rows below remove spaces before and after
      Name = %key_array1%
      Desc = %key_array2%
      Hk = %key_array3%
      If (Name != "")
         LV_Add("", Name, Desc, Hk)
   }
   LV_ModifyCol()  ; Auto-size each column to fit its contents.
   LV_ModifyCol(1, "Sort")
   Gui, +Resize
   Gui, Show,,AHK-Help   
return

MyListView:
   if A_GuiEvent = DoubleClick
   {
      LV_GetText(hk_label, A_EventInfo, 3)
      RunHK(hk_label)
   }

   ; Sort with ^1 and ^2
   if A_GuiEvent = K
   {
      ControlState := GetKeyState("Ctrl")
      if (ControlState = 1)
      {
         if (A_EventInfo = 49)
         {
            ; 1 pressed
            if sorted = 1
            {
               LV_ModifyCol(1, "SortDesc")
               sorted := 0
            } else {
               LV_ModifyCol(1, "Sort")
               sorted := 1
            }
         } else {
            if (A_EventInfo = 50)
            {
               if sorted = 2
               {
                  LV_ModifyCol(2, "SortDesc")
                  sorted := 0
               } else {
                  LV_ModifyCol(2, "Sort")
                  sorted := 2
               }
            }
         }
      }
   }
return

GuiSize:  ; Expand or shrink the ListView in response to the user's resizing of the window.
   if A_EventInfo = 1  ; The window has been minimized.  No action needed.
      return
   ; Otherwise, the window has been resized or maximized. Resize the ListView to match.
   GuiControl, Move, MyListView, % "W" . (A_GuiWidth - 20) . " H" . (A_GuiHeight - 20) ;%
return

ButtonOK:
   GuiControlGet, FocusedControl, FocusV
   if FocusedControl <> MyListView
      return
   LV_GetText(hk_label, LV_GetNext(0, "Focused"), 3)
   RunHK(hk_label)
   Return

GuiEscape:
   Gui, Cancel
Return

RunHK(label) {
   if IsLabel(label)
   {
      Gui, Cancel
      Gosub, %label%
   }
   else
   {
      MsgBox %label%
   }
}
;===============================================================
ViewKeyListFromHK( scriptfile ) {
   global keylist
   keylist := FormatKeyListFile(scriptfile)
   Gosub ShowListView
}

FormatKeyListFile( scriptfile, force = False ) {
; this function reads scriptfile and returns a formatted string from FormatKeyList
; it automatically caches the most recent formatted result so it doesn't have to reparse it
; pass force = True to force it to reread and reparse the scriptfile
   static file, formatted
   if (file != scriptfile) && !Force
   {
      fileread, contents, %scriptfile%
      formatted := FormatKeyList( contents )
      file := scriptfile
   }
   return formatted
}

FormatKeyList( lines, srt = False ) {
; this does the actual formatting. Pass the text to be formatted
   loop, parse, lines, `n, `r
      if SubStr(A_LoopField, 1, 2) = ";;"
         KeyList .= SubStr(A_LoopField, 3) "`n"
      else if RegExMatch(A_LoopField, "^\s*(?<hk>[^:]+)::(?<cmd>.*?)(?:(?<=\s);;(?<desc>.*))?$", _)
         KeyList .= HumanReadableHK( _hk ) "¬" (_desc ? _desc : _cmd) "¬" _hk "`n"
      else if RegExMatch(A_LoopField, "^\s*:(?<opt>[^:]*):(?<hs>[^:]+)::(?<rep>.*?)(?:(?<=\s);;(?<desc>.*))?$", _)
         KeyList .= _hs "¬" (_desc ? _desc : _rep) "¬" ":" _opt ":" _hs "`n"
   if sort
      sort, KeyList, P16 ; sort the comments
   return KeyList
}

HumanReadableHK( key ) {
;a function to take care of replacing symbols in hotkeys with their words
  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, &, %A_Space%and%A_Space%
  StringReplace, key, key, $, hooked%A_Space%
  return key
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject: No
PostPosted: July 31st, 2010, 7:18 am 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
No i think you misunderstood what I was trying to say. Please post the script you wrote or are using from which you want to see the hotkey list. The script you posted is just the same as the previous ones. Because the error is related to the script where you have included this script, not keylist. Please delete your previous post (to remove unnecessary duplicate code) and post only your script.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 3rd, 2010, 2:56 pm 
Offline

Joined: February 14th, 2006, 6:00 pm
Posts: 40
Hi Vixay,

Hereby I send you the whole .ahk file I use to include the keylist script.

Code:
Menu,Tray,Add,View Hotkeys, KeyList ; is a label not a function
return

Keylist:
ViewKeyList(A_ScriptFullPath)
return




;-------------- ctrl-shift-2 --> Remove Line Feeds --------------
^+2:: ;;Remove LF
Send ^x
VerwijderLF = %clipboard%
StringReplace, VerwijderLF, VerwijderLF, `r`n, %A_SPACE%, All
clipboard = %VerwijderLF%
Send ^v
return


;-------------- ctrl-shift-3 --> remove empty lines --------------
^+3:: ;;Remove Empty Lines
Send ^x
VerwijderEL = %clipboard%
Loop
{
    StringReplace, VerwijderEL, VerwijderEL, `r`n`r`n, `r`n, UseErrorLevel
    if ErrorLevel = 0  ; No more replacements needed.
        break
}
clipboard = %VerwijderEL%
Send ^v
return


;-------------- ctrl-q --> search in browser current tab --------------
^q:: ;;Search in current tab
   Send ^c
   CopieTxt = %Clipboard%
   SetTitleMatchMode 2
     if !WinExist("Mozilla Firefox") AND !WinExist("Google Chrome") AND !WinExist("ahk_class IEFrame")
     {
     Run, C:\Program Files\Mozilla Firefox\firefox.exe
     WinWaitActive, Mozilla Firefox
    Sleep 1000
    }
     else if !WinActive("Mozilla Firefox") AND !WinActive("Google Chrome") AND !WinActive("ahk_class IEFrame") AND WinExist("Mozilla Firefox")
         {
         WinActivate, Mozilla Firefox
        }
            else if WinActive("Mozilla Firefox")
         {
         WinActivate, Mozilla Firefox
         }
            else if WinExist("Google Chrome") AND !WinActive("ahk_class IEFrame")
            {
            WinActivate, Google Chrome
            }
               else
               {
               WinActivate, ahk_class IEFrame
               }
   MijnTab = http://www.google.com/search?q=%Clipboard%
   clipboard = %MijnTab%
   Sleep 400
   Send {F6}
   Send ^v
   Send {Enter}
   Clipboard = %CopieTxt%
return


;-------------- ctrl-shift-q --> search in browser new foreground tab --------------
^+q:: ;;Search in new foreground tab
   Send ^c
   CopieTxt2 = %Clipboard%
   SetTitleMatchMode 2
     if !WinExist("Mozilla Firefox") AND !WinExist("Google Chrome") AND !WinExist("ahk_class IEFrame")
     {
     Run, C:\Program Files\Mozilla Firefox\firefox.exe
     WinWaitActive, Mozilla Firefox
    Sleep 1000
    }
     else if !WinActive("Mozilla Firefox") AND !WinActive("Google Chrome") AND !WinActive("ahk_class IEFrame") AND WinExist("Mozilla Firefox")
         {
         WinActivate, Mozilla Firefox
        }
            else if WinActive("Mozilla Firefox")
         {
         WinActivate, Mozilla Firefox
         }
            else if WinExist("Google Chrome") AND !WinActive("ahk_class IEFrame")
            {
            WinActivate, Google Chrome
            }
               else
               {
               WinActivate, ahk_class IEFrame
               }
   NieuwTab = http://www.google.com/search?q=%Clipboard%
   clipboard = %NieuwTab%
   Sleep 200
   Send ^t
   Sleep 600
   Send ^l
   Sleep 200
   Send ^v
   Send {Enter}
   Clipboard = %CopieTxt2%
return


;-------------- win-y --> yahoo search -------------- 
#y:: ;;Yahoo search
   Send ^c
   CopieTxtYHOO = %Clipboard%
   YHOOTab = http://search.yahoo.com/search?p=%Clipboard%
   clipboard = %YHOOTab%
   Sleep 400
   Send {F6}
   Send ^v
   Send {Enter}
   Clipboard = %CopieTxtYHOO%
return


;-------------- win-m --> google map search --------------
#m:: ;;Google Map search
   Send ^c
   CopieTxtMAP = %Clipboard%
   GoogleMAP = http://maps.google.com/maps?q=%Clipboard%
   clipboard = %GoogleMAP%
   Sleep 400
   Send {F6}
   Send ^v
   Send {Enter}
   Clipboard = %CopieTxtMAP%
return


;-------------- win-b --> amazon book search --------------
#b:: ;;Amazon search
   Send ^c
   CopieTxtBOOK = %Clipboard%
   Amazon = http://www.amazon.com/s/ref=nb_ss?url=search-alias`%3Dstripbooks&field-keywords=%ClipBoard%&x=0&y=0
   ;Amazon = http://www.domain.com/s/url=search`%2&keyword=test
   clipboard = %Amazon%
   Sleep 400
   Send {F6}
   Send ^v
   Send {Enter}
   Clipboard = %CopieTxtBOOK%
return


;;
;-------------- firefox ctrol/shift-scroll up-down --> END/HOME --------------
SetTitleMatchMode 2
#ifWinactive Firefox
^+WheelUp::Send {HOME}   ;;FF: Begin of Page
^+WheelDown::Send {END}  ;;FF: End of Page
return


#Include, D:\\KeyList2.ahk


KeyList2.ahk is the code in previous message

Thank you :)


Report this post
Top
 Profile  
Reply with quote  
 Post subject: works for me
PostPosted: August 4th, 2010, 5:43 am 
Offline

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

It works for me.
the only change i had to make was remove D:\\ from your include parameter. This is the output i get

Code:
Ctrl + Shift + 2 == Remove LF
Ctrl + Shift + 3 == Remove Empty Lines
Ctrl + q == Search in current tab
Ctrl + Shift + q == Search in new foreground tab
Win + y == Yahoo search
Win + m == Google Map search
Win + b == Amazon search

Ctrl + Shift + WheelUp == FF: Begin of Page
Ctrl + Shift + WheelDown == FF: End of Page

what version of autohotkey are you using?


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: works for me
PostPosted: January 14th, 2011, 6:43 pm 
Offline

Joined: September 2nd, 2008, 9:24 pm
Posts: 14
Location: Berkshire, England
vixay wrote:
It works for me.
the only change i had to make was remove D:\\ from your include parameter.


Sorry, keylist2 doesn't work for me (though the scripts may be out of date due to newer versions of the language). I get a "This line does not contain a recognized action" error message in
Code:
FormatKeyList


Code:
KeyList .= SubStr(A_LoopField, 3) "`n"
in line 139

It looks like a simple subroutine but the .= and the "`n" parts seem out of place?

Similar problems for line 141:

Code:
KeyList .= HumanReadableHK( _hk ) "¬" (_desc ? _desc : _cmd) "¬" _hk "`n"


With these edited out I then get a "Call to non-existent function" error for the SubStr call on line 138; also for RegExMatch nearby.

I'm running AHK 1.0.44.07 on Win XP

_________________
A prudent question is one-half of wisdom.
Francis Bacon


Report this post
Top
 Profile  
Reply with quote  
 Post subject: upgrade
PostPosted: April 25th, 2011, 5:10 am 
Offline

Joined: June 12th, 2008, 10:29 am
Posts: 52
upgrade to 1.0.48 (the latest version) and then try


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 23 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