Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Active GoTo v4


  • Please log in to reply
85 replies to this topic
toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Thanks Rajat,
This is getting better and better

Some comments:

- I would set the hotkeys context sensitive. e.g. after line 100
Hotkey, IfWinActive, ahk_id %EWID% 
  Hotkey, %HK_ShowGUI%, ShowGUI
  Hotkey, %HK_LastSection%, LastSection
  Hotkey, IfWinActive 
and remove them from the top.

- When I change between tabs, the GUI steals the focus. The focus should stay with the editor.

- The hotkey Win+Tab should toggle the gui hide/show. It only shows the gui.

- Could you add a button or context menu to the gui to change the sort between sort/occurence?

- Could you add a nice tray menu?

- Could you give a option (only code) in which direction it minimizes?

- Could you show a small window frame instead of nothing when the gui is hidden? Then it would be possible to capture mouse over, and then show the gui also when the mouse on it, so users so not have to use a hotkey. E.g. like this
RollUpDownGui1(wParam, lParam, msg, hwnd) {
    global Gui1UniqueID, GuiRolledUp, ScriptName
    WM_NCMouseMove = 0xA0
    If ( GuiRolledUp and msg = WM_NCMouseMove) {
        OnMessage(WM_NCMouseMove , "")
        DllCall("AnimateWindow","UInt",Gui1UniqueID,"Int",200,"UInt","0x20005")
        Gui, 2:Destroy 
    }Else If ( !GuiRolledUp and msg = "0x204"){
        OnMessage(WM_NCMouseMove , "RollUpDownGui1")
        WinGetPos, X, Y, , , ahk_id %Gui1UniqueID%
        Gui, 2: +ToolWindow -SysMenu +AlwaysOnTop 
        Gui, 2:Show, w0 h100 x%X% y%Y% NoActivate, %ScriptName%   ;vertical bar
        DllCall("AnimateWindow","UInt",Gui1UniqueID,"Int",200,"UInt","0x3000a")
    }Else
        Return
    GuiRolledUp := not GuiRolledUp
  }
(taken from scriplet library v3 which isn't posted yet, i think) It shows a small bar when the main gui is closed. When WM_NCMouseMove gets issued on the bar, the bar gui closes and the main gui appears. When the main window hides it is vice versus.

Just some ideas.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

rajat as guest
  • Guests
  • Last active:
  • Joined: --

But that class has to be specified by the user for each editor. I guess it is more complicated then using title. At the same time it should be more robust.


Its set for PSPad but you can change it to whatever editor you like, it has just 2 reqmts:
- Editor must have a Goto Line cmd
- Editor window's title shows file path

actually the class name i used now is just a replacement for the earlier method, so that your installation of PSPad is also supported. Its still only pre-configured for PSPad and other editors will have to be configured, just like earlier.

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I dived into the code a bit more. Four suggestions/questions:

- Only add the GUI ID once to the group, e.g.
If !HotkeysSet {
      WinGet, MWID, ID, %MainWnd%
      GroupAdd, MWGrp, ahk_id %MWID%
      HotkeysSet = 1
    }

- move this part ouit of EWCheck into the auto-exec area, since it only needs to be called once:
;______Extracting Filename
StringLen, StartLen, TitleStart
StringLen, EndLen, TitleEnd

If !WinExist(TitleStart){
    CoordMode, ToolTip, Screen
    TrayTip,, Editor window doesn't exist!
    Sleep, 2000
    ExitApp
  }

WinGetTitle, WinTitle, %TitleStart%
WinGet, EWID, ID, %WinTitle%

Hotkey, IfWinActive, ahk_id %EWID% 
Hotkey, %HK_ShowGUI%, ShowGUI 
Hotkey, %HK_LastSection%, LastSection
Hotkey, IfWinActive 
That simplifies EWCheck.

- could the code capture "^s" to update the list?
or could teh code look for the "*" in the title, and when that disappears update? I know that then the list will be updated too many times then needed, but I rather have the list uptodate then to press F5 once i realize it is not. :)

- When the Gui opens, can the last jumped label be selected? Currently it is always the first.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Tekl
  • Members
  • 814 posts
  • Last active: May 03 2009 03:28 PM
  • Joined: 24 Sep 2004
Great Script,

I modified the search-routine to search inside words:

Search:
   Gui, Submit, NoHide
   Loop, Parse, List, |
   {
      IfInString, A_LoopField, %Search%
      {
         GuiControl, Choose, SelItem, %A_Index%
         Break
      }
   }
Return

I also added this Hotkey to ahk_group MWGrp

^BackSpace:: Send,^+{Left}{Del}

Tekl

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
I played with the code and added some of my requests plus some nice new features. Before I go to play beachvolleyball here is the code for YOU to optimize further:
TitleStart = PSPad - [

TitleEnd = ]



;Go To Settings (Name of GoTo window and Editor's related key)

GotoWin = ahk_class TfGotoLine

GotoKey = ^g



;Sort Section List Alphabetically?

ASort = 1



;Hotkeys for showing GUI and going to last section

HK_ShowGUI = #Tab

HK_LastSection = #Left

HK_Refresh = F5



;checks if the currently open file in the editor is a .ahk or .au3 file

ScriptCheck = Y 



;___________________________________________



#SingleInstance Force

MainWnd = Active GoTo



StringLen, StartLen, TitleStart

StringLen, EndLen, TitleEnd



If !WinExist(TitleStart){

    CoordMode, ToolTip, Screen

    TrayTip,, Editor window doesn't exist!

    Sleep, 2000

    ExitApp

  }



WinGetTitle, WinTitle, %TitleStart%

WinGet, EWID, ID, %WinTitle%



GroupAdd, HtkGrp, ahk_id %EWID% 

Hotkey, IfWinActive, ahk_group HtkGrp

Hotkey, %HK_ShowGUI%, ShowGUI 

Hotkey, %HK_LastSection%, LastSection

Hotkey, IfWinActive 



;check for editor window

SetTimer, EWCheck, 500

Return



EWCheck:

  IfWinNotExist, ahk_id %EWID%

      ExitApp

  If GetKeyState("Ctrl", "P")  ;wait for ctrl key to be up again while changing tabs 

      Return



  IfWinNotActive ahk_id %MWID% 

      IfWinNotActive ahk_id %EWID% 

        {

          DllCall( "AnimateWindow", "Int", MWID, "Int", 200, "Int", 0x00050002 )

          GuiVisible := False

        }  



  WinGetTitle, WinTitle, ahk_id %EWID%

  StringTrimLeft, FileName, WinTitle, %StartLen%

  StringTrimRight, FileName, FileName, %EndLen%

  

  StringRight, Test, FileName, 1

  IfEqual, Test, *, StringTrimRight, FileName, FileName, 1

  FileName = %FileName%



  IfNotInString, FileName, .ahk

    Return



  If ( FileName <> LastFileName) {

      Gosub, GenerateBM

      LastFileName = %FileName%

    }

Return  



GenerateBM:

  ;_______Reading file and creating bookmarks



  FileRead, FileData, %FileName%

  

  List =

  Count =

  Loop, Parse, FileData, `n, `r

    {

      SectionLine =

      CurrLine = %A_LoopField%

      CurrLine = %CurrLine%

      CurrLineN = %A_Index%

  

      StringLeft, Check, CurrLine, 1

      IfEqual, Check, `;, Continue

      

      ;function line

      IfInString, CurrLine, `(

      IfInString, CurrLine, `)

        {

          ;non OTB function

          IfNotInString, CurrLine, `{

            {

              FileReadLine, CheckF, %FileName%, % A_Index + 1

              CheckF = %CheckF%

              IfNotEqual, CheckF, `{

                Continue

            }

          

          ;OTB function

          IfInString, CurrLine, `{

            {

              StringRight, CheckF, CurrLine, 1

              IfNotEqual, CheckF, `{  

                Continue

            }

      

          StringGetPos, CPos, CurrLine, `(

          StringLeft, CurrLine, CurrLine, %CPos%

          CurrLine = %CurrLine%`(`)

          SectionLine = Y

        }

    

      ;hotkey line

      IfInString, CurrLine, `:`:

        {

          StringGetPos, CPos, CurrLine, `:

          CPos += 2

          StringLeft, CurrLine, CurrLine, %CPos%

          SectionLine = Y

        }

    

      IfNotInString, CurrLine, `:`:

        {

          IfInString, CurrLine, `,, Continue

          IfInString, CurrLine, %A_Space%, Continue

          IfInString, CurrLine, %A_Tab%, Continue

        }

    

      StringRight, Check2, CurrLine, 1

      StringRight, Check3, CurrLine, 2

      StringLeft, Check3, Check3, 1

      

      IfEqual, Check2, `:

      IfNotEqual, Check3, ``

        SectionLine = Y



      IfEqual, SectionLine, Y

        {

          Count ++

          Text%Count% = %CurrLine%

          Pos%Count% = %CurrLineN%

          List = %List%|%CurrLine%

        }

    }

      

  StringTrimLeft, List, List, 1

  If ASort

    Sort, List, D|



  If !GuiMade {

      Gui, +AlwaysOnTop -Caption +Border +ToolWindow

      Gui, Add, Edit, x6 y6 w200 h20 vSearch gSearch AltSubmit,

      Gui, Add, ListBox, x6 y30 w200 h440 vSelItem gMSelect,

      Gui, Add, Button, x-10 y-10 w1 h1 gSelect Default,

      GuiMade = 1

    }

    

  GuiControl,, SelItem, |%List%

  IfNotEqual, List,

    {

      Gui, Show, x0 y44 h471 w212 Hide, %MainWnd%

      If LastItem

          GuiControl, ChooseString, SelItem, %LastItem% 

      DetectHiddenWindows, On

      WinGet, MWID, ID, %MainWnd%

      DetectHiddenWindows, Off

      DllCall( "AnimateWindow", "Int", MWID, "Int", 200, "Int", 0x00040001 )

      GuiVisible := True

    }



  If !HotkeysSet {

      GroupAdd, MWGrp, ahk_id %MWID%

      GroupAdd, HtkGrp, ahk_id %MWID% 

      HotkeysSet = 1

    }

Return



GuiClose:

  ExitApp



GuiEscape:

  WinActivate, ahk_id %EWID%

  DllCall( "AnimateWindow", "Int", MWID, "Int", 200, "Int", 0x00050002 )

  GuiVisible := False

Return



ShowGUI:

  If GuiVisible

      Gosub, GuiEscape

  Else {

      DllCall( "AnimateWindow", "Int", MWID, "Int", 200, "Int", 0x00040001 )

      GuiVisible := True

      WinActivate, ahk_id %MWID%

    }

Return



MSelect:

  IfNotEqual, A_GuiControlEvent, DoubleClick, Return



Select:

  ;selects the search text

  ControlGetFocus, ACtrl, ahk_id %MWID%

  IfEqual, ACtrl, Edit1

    Send, +{Home}



  Gui, Submit, NoHide

  

  Loop, %Count% {

    IfEqual, Text%A_Index%, %SelItem%

    {

      LastLine = %GotoLine%

      LastItem = %SelItem%



      GotoLine := Pos%A_Index%

      WinActivate, ahk_id %EWID%

      WinWaitActive, ahk_id %EWID%

      Send, %GotoKey%

      WinWaitActive, %GotoWin%

      Send, %GotoLine%{Enter}

      

      IfEqual, LastLine,

        {

          LastLine = %GotoLine%

          LastItem = %SelItem%

        }



      If !ASort {

          ;moving selected item to top

          TmpList = |%List%|

          StringReplace, TmpList, TmpList, |%SelItem%|, |, A

          StringTrimLeft, TmpList, TmpList, 1

          StringTrimRight, TmpList, TmpList, 1

          List = %SelItem%|%TmpList%

          GuiControl,, SelItem, ||

          GuiControl,, SelItem, |%List%

          GuiControl, ChooseString, SelItem, %SelItem%

        }

      

      Break

    }

  }

  DllCall( "AnimateWindow", "Int", MWID, "Int", 200, "Int", 0x00050002 )

  GuiVisible := False

Return



Search: 

   Gui, Submit, NoHide 

   Loop, Parse, List, | 

      IfInString, A_LoopField, %Search% 

        { 

           GuiControl, Choose, SelItem, %A_Index% 

           Break 

        } 

Return



LastSection:

  IfEqual, LastLine,, Return



  WinActivate, ahk_id %EWID%

  WinWaitActive, ahk_id %EWID%

  Send, %GotoKey%

  WinWaitActive, %GotoWin%

  Send, %LastLine%{Enter}

  Swp = %LastLine%

  LastLine = %GotoLine%

  GotoLine = %Swp%

Return



#IfWinActive, ahk_group MWGrp 

Up::  ControlSend, ListBox1, {Up}, %MainWnd% 

Down::  ControlSend, ListBox1, {Down}, %MainWnd%

WheelUp::  ControlSend, 30.08.2006 17:45:12ListBox1, {Up}, %MainWnd% 

WheelDown::  ControlSend, ListBox1, {Down}, %MainWnd%

MButton:: GoSub, Select 

F5::  LastFileName =

!D:: ASort := not ASort

^BackSpace:: Send,^+{Left}{Del}

^Esc:: ExitApp

#IfWinActive


Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

rajat as guest
  • Guests
  • Last active:
  • Joined: --
actually on my personal system i've an updated version of this script than what i've posted here. it supports hotstrings as well now and a couple more changes. as i don't have access to it currently, i can't post it right now. also i don't have pspad here so can't check your latest offering. i'll do all this a couple of hours later.

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004

When the Gui opens, can the last jumped label be selected? Currently it is always the first.

actually the last jumped label is moved to top AND selected (this is documented in main post). so your last couple of browsed sections are now most easily accessible (being at top of list).

Only add the GUI ID once to the group,

at one point i'd been using 'Gui, destroy' for refreshing the gui for new file... this code is a leftover from that.

could the code capture "^s" to update the list?
or could teh code look for the "*" in the title, and when that disappears update? I know that then the list will be updated too many times then needed, but I rather have the list uptodate then to press F5 once i realize it is not.

this sounds good!

move this part ouit of EWCheck into the auto-exec area, since it only needs to be called once:

you're right! (as usual) :)

and could you please list the changes that you've done in the code that you've posted?

by the way, in your code, whenever the active file in editor is changed, and ActiveGoto pops up, its not always active.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005

by the way could you please list the changes that you've done in the code that you've posted?

Sorry, I can't. I started to midify without itention to post it. But then the changes became so many, that I thought that it would be enough to post. But you could do a TextDiff on the files.
From memory:
- I have removed au3 support. It should be outside of the loop anyway. Even if that means two loops (one for au3 and a second for ahk) At the end we could have another loop for INI files too.
- Changed some if statements to shorter ones, to save lines
- added some more hotkeys
- added Tekl's suggestions
- added fade in for GUI
- added toggle hide/show with Win+Tab
- simplified EWCheck
- Made hotkeys case sensitive
- added toggle for sort (Alt+D), needs F5 to update
- when sort is active, labels are not moved to top
- when sort is active, last label used is selected


by the way, in your code, whenever the active file in editor is changed, and ActiveGoto pops up, its not always active.

I haven't finish my modifications. But I'm currently working of SGUI and Scriptlet Library, so I will not get back on this till tomorrow.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

Spike
  • Members
  • 19 posts
  • Last active: Dec 13 2011 12:12 AM
  • Joined: 24 Jun 2005
Hi Toralf , Rajat.
Thanks for your replies , the problem seems to be that the main PSPad window only shows PSPad and
the loaded text in a tabbed window shows the filename and path.
So how do I get PSPad to show the filename in the window title ??.

Thanks,
Jan

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
@Spike
there must be some option you might've inadvertently set which is causing this. please download the latest installation of PSPad and install it in a new location and see if that cures it.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
v4 Changes:
- List Auto-Updates if there is a change in the sections (or their positions) in the script.
- The auto-update changes the order of the list ONLY if there is a change in the sections in the script,
and not if the change is only in their positions
- Support for hotstrings added
- Support for same line comments on section line added/improved
- If there are no sections in a file (eg. a new script), the ActiveGoTo window doesn't pop up.
- The hotkey Win+Tab toggles the gui hide/show. (Thanks toralf)
- The GUI only shows up when its hotkey is pressed, and not automatically (Thanks toralf)
- All Hotkeys context sensitive (Thanks toralf)
- The refresh hotkey (F5) is gone
- Removed support for .au3 scripts (Don't even know why I added that in the first place!)


Now just set it up to run with your favourite editor and you won't even know its there untill you press Win+Tab, when it'll show itself always updated!

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Thanks Rajat,

I tried it. The only thing I found is that when i have the gui open and then switch between tabs in PSPad it doesn't change the list.

Of cause there are still some open suggestion (see above) but I do not want to bug you too much.
Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

MsgBox
  • Members
  • 204 posts
  • Last active: Jan 05 2011 01:40 AM
  • Joined: 17 Nov 2005
Hello Rajat

I have just tried v4 and have come across a bug/oversight.

The hotkey Win+Tab toggles the gui hide/show.

When pressing the hotkey twice ie showing the gui and then hiding it without making a selection, the focus goes to the taskbar and not back to PSPad.

MsgBox
  • Members
  • 204 posts
  • Last active: Jan 05 2011 01:40 AM
  • Joined: 17 Nov 2005
Mmm... toralf is too fast. :)

Spike
  • Members
  • 19 posts
  • Last active: Dec 13 2011 12:12 AM
  • Joined: 24 Jun 2005
Hi Rajat,
>@Spike
>there must be some option you might've inadvertently set which is causing this. please download the latest installation of PSPad and install it in a new location and see if that cures it.

Thanks for the pointer ..somehow
the the pspad.ini file was corrupt!.

Keep up the good work.
Jan