AutoHotkey Community

It is currently May 27th, 2012, 9:32 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: PSPad searchNgoto
PostPosted: August 29th, 2006, 10:43 pm 
Offline

Joined: October 20th, 2005, 11:56 am
Posts: 23
Hi all.

Rajat recently released
'Active GoTo'
And he has actually had the script for a while, so this is not new.
I was starting on this a few days before Active GoTo got a little kick along. And with some parts of Rajats code included, I managed to get mine off the ground

They both work similar, with searchNgoto as follows
-incremental search of text in lines
-listview of results
-Only made for PSPad as that is what I use.
-Auto update when changing Tabs
-Search for anything, '=' 'lv_' '(' 'Var'
-Just handy for a newbie like me.
-
Comments, Suggestions and Improvements all welcome.
(please, as still learning)

Thanks
dB

Code:
#Persistent
Version=PSPad searchNgoto v1c
; Use Win+TAB to start or refresh
; Escape to minimise
; Enter Key to Goto Line Number
; Double click to Goto
; Created by DoubleBogey, with some parts from Rajat
Process ,Priority,,High
SetBatchLines -1                                                                ;Run forrest, Run
SetKeyDelay -1
SetTimer Update, 1000                                                           ;refresh list every 1 Second
posiGui:=A_Screenwidth-285                                                      ;position Search box on Right side of Screen
Return
#Tab::                                                                          ;win + Tab is hotkey
  Gui, Destroy                                                                  ;Destroy any Existing Gui
  Gui, +AlwaysOnTop -Caption +Border +ToolWindow                                ;keep window ontop, take away Border, title bar thin
  Gui, Add, Text,     x4    y4    , Search for `:                               ;add text
  Gui, Add, Edit,     x+5  y2  w80  vSearchstring gSearchItems                  ;add edit box with Gosub
  Gui, Add, Text,   x+5  , Goto line
  Gui, Add, Edit, x+5 w40 Number vLineNumberedit ,
  Gui, Add, ListView, x2   y+5  w250 r30  vchoice gListBoxClick -Multi grid AltSubmit,  #|Line Text
  Gui, Add, Button, w0 h0 Default gHitEnter, OK
  Gui, add, StatusBar,,There are %CountLines% matching Lines. Escape to Exit    ;add Status bar to window
  Gosub SearchItems                                                             ;initial fill ListView
  Gui, Show, y120 x%posiGui%,   %Version%                                         ;show the Gui
Return

Update:
  WinGetTitle, WinTitle, PSPad - [                                              ;get the title of the current active window
  IfNotEqual, Wintitle, %titleold%                                              ;If the window title has changed, then
    {
      Titleold=%wintitle%                                                       ;make the window titles the same
      Gosub, SearchItems                                                        ;refresh the ListView
    }
Return                                                                          ;do not refresh the ListView
SearchItems:
  WinGetTitle, WinTitle, PSPad - [                                              ;get the title of the current active PSPad window
  WinGet, ThisWindowID, ID, %WinTitle%                                          ;Retrieves the specified window's unique ID
  StringTrimLeft, FileName, WinTitle, 9                                         ;trim 9 Spaces from the left
  StringTrimRight, FileName, FileName, 1                                        ;trim 1 Spaces from the Right
  StringRight, TheFileExt, FileName, 1                                          ;get the last letter of the File extension
  IfEqual, TheFileExt, *, StringTrimRight, FileName, FileName, 1                ;if the last letter is *, trim 1 from Right
  Gui Submit, NoHide                                                            ;dont hide Gui
  LV_Delete()                                                                   ;Destroys the current list in the ListView
  Loop, Read, %filename%                                                        ;Read the file
      IfInString, A_LoopReadline,%Searchstring%                                 ;if search =
        {
          x1=%A_LoopReadline%
          x1=%x1%                                                               ;remove whiteSpaces
          LV_Add("",A_Index,x1)                                                 ;add the line to list view
        }
  CountLines:=LV_GetCount()                                                     ;Count Lines in ListView
  LV_ModifyCol()                                       ;auto width columns
  SB_SetText("There are " . CountLines . " matching Lines.    Escape to Exit")  ;update the Status bar
  GuiControlGet, lastss, , searchstring                                         ;get the current value from the Input box
  If  searchstring <> %lastss%                                                  ;compare the current value against the end of loop
    {                                                                           ;- for any keypresses whilst loop running
      Goto, searchitems                                                         ;recompile search results if search string different
    }

Return
ListBoxClick:                                                                   ;if mouse clicked
  Gui Submit, NoHide
  If A_GuiEvent = DoubleClick                                                   ;doubleclick in Listview
    {
      LV_GetText(LineNumber,A_EventInfo,1)                                      ;Line Number = value of column1
      WinActivate, ahk_id %ThisWindowID%
      WinWaitActive, ahk_id %ThisWindowID%
      Send, ^g                                                                  ;the PSPad shortcut to Goto line window
      WinWaitActive, Goto Line                                                  ;wait until the Goto window is active
      Send, %LineNumber%{Enter}                                                 ;Send the lineNumber followed by Enter
    }
If A_GuiEvent = Normal                                                          ;singleclick in Listview
{
      LV_GetText(LineNumber,A_EventInfo,1)                                      ;Line Number = value of column1
      GuiControl, , LineNumberedit, %LineNumber%                                ;update the Number edit box
}

Return
Hitenter:                                                                       ;if the enter key is hit whilst search active
  Gui Submit, NoHide                                                            ;get all the values from the Gui
  WinActivate, ahk_id %ThisWindowID%
  WinWaitActive, ahk_id %ThisWindowID%
  Send, ^g                                                                      ;Send the lineNumber followed by Enter
  WinWaitActive, Goto Line                                                      ;wait until the Goto window is active
  Send, %LineNumberedit%{Enter}                                                 ;Send the lineNumber followed by Enter
Return


GuiEscape:
Gui,destroy                                                                     ;kill the GUI
return
GuiClose:                                                                       ;shut me down
  ExitApp





_________________
Everyone makes mistakes, that's why they put erasers on pencils. Milhouse, The Simpsons


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 6:55 am 
Offline

Joined: April 17th, 2005, 7:47 pm
Posts: 289
Location: Sauerland
Nice idea! 8)
A hint: Change lines 71 and 86 in
Code:
      WinWaitActive, ahk_class TfGotoLine                                       ;wait until the Goto window is active
to make it international.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 8:31 am 
Offline

Joined: March 28th, 2004, 3:53 pm
Posts: 1870
full script searching!... nice thing! :)

Rabiator wrote:
A hint: Change lines 71 and 86 in
Code:
      WinWaitActive, ahk_class TfGotoLine                                       ;wait until the Goto window is active
to make it international.

that's a cool trick Rabiator! thanks!

_________________
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 30th, 2006, 10:03 am 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
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.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: PSPad searchNgoto
PostPosted: August 30th, 2006, 11:58 am 
Offline

Joined: April 17th, 2005, 7:47 pm
Posts: 289
Location: Sauerland
doublebogey wrote:
-Only made for PSPad as that is what I use.


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: PSPad searchNgoto
PostPosted: August 30th, 2006, 12:07 pm 
Offline

Joined: January 31st, 2005, 9:50 am
Posts: 3910
Location: Bremen, Germany
Rabiator wrote:
doublebogey wrote:
-Only made for PSPad as that is what I use.
I know, it was not against your comment, it was in direction of Rajat, because he added it to activegoto. Which was up to now more or less independent of the editor. And it was only ment as a remark not to offend.

_________________
Ciao
toralf
Image


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: PSPad searchNgoto
PostPosted: August 30th, 2006, 3:12 pm 
Offline

Joined: April 17th, 2005, 7:47 pm
Posts: 289
Location: Sauerland
I don't feel offended at all ^^, I just didn't realize that your answer belonged to another thread, "Active GoTo v3". :wink:


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google Feedfetcher, nomissenrojb, SKAN, Stigg and 18 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