AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

smartEdit

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
faerl



Joined: 05 May 2006
Posts: 2

PostPosted: Sun May 07, 2006 7:30 am    Post subject: smartEdit Reply with quote

Code:
;name: smartEdit.ahk
; Esc  : exit app
; Enter: send you type string
; Rwin : send you select string
;---------------------------------------------
ListName=acs.txt
;Gui, Show, Hide
CustomColor = FFFFD7  ; Can be any RGB color (it will be made transparent below).
Gui, +AlwaysOnTop +LastFound +Owner  ; +Owner prevents a taskbar button from appearing.
Gui, Color, %CustomColor%
;Gui, Font, s24
WinSet, TransColor, %CustomColor% 150
Gui, -Caption
; -------------------------- - Autoexecute -----------------------------
;Gui, Add, Text, x6 y264 w50 h20, Search`:
Gui, Add, ListBox, vChoice gListBoxClick x0 y0 w200 h250 VScroll HScroll
Gui, Add, Edit, x0 y237 w200 h20

Gosub RefreshListBox

search =

Loop
{
    Input, input, L1 V, {enter}{esc}{backspace}{up}{down}{pgup}{pgdn}{tab}{left}{right}{RWin}
      if ErrorLevel = EndKey:enter
      {
         search =
         ;send {enter}
      }
       if ErrorLevel = EndKey:escape
      {
         Gui, cancel
         Gosub GuiClose
      }
       if ErrorLevel = EndKey:RWin
      {
         Gui, Show, Hide
         GoSub, WordRetrieve
         search =

         ;continue
      }
       if ErrorLevel = EndKey:backspace
      {
         GoSub, DeleteSearchChar
         continue
      }
       if ErrorLevel = EndKey:up
      {
         Gui, Show
         ;Send, {up}
         continue
      }
       if ErrorLevel = EndKey:down
      {         
         SetTimer, WinCaretShow, Off
         Gui, Show
         ;Send, {down}
         continue
      }
      if ErrorLevel = EndKey:pgup
      {
         Send, {pgup}
         continue
      }
      if ErrorLevel = EndKey:pgdn
      {
         Send, {pgdn}
         continue
      }

    search = %search%%input%               ;Assembles the search string
    GuiControl,, Edit1, %search%            ;Displays the search string in the edit control
    StringLen,SearchLength,Search
    Gosub RefreshListBox
    continue
}
return
; --------------------------RefreshListBox-----------------------------
;Refreshes the listbox according to the search criteria:
RefreshListBox:
Wordlist=

Loop, read, %ListName%
{
   StringLeft, Fragment,A_LoopReadLine, %SearchLength%
   IfInString, Fragment,%Search%
      Wordlist=%Wordlist%|%A_LoopReadLine%
   Else
      continue
}
;=============================
if (A_CaretX and search)
{
Gosub WinCaretShow
SetTimer, WinCaretShow, 200
}
else
{
Gui, Hide
SetTimer, WinCaretShow, Off
}
;=============================
;Gui, Show, NoActivate, SmartGUI  ; NoActivate avoids deactivating the currently active window.

;WinSet, Style, -0xC00000, Title of Window
;WinSet, AlwaysOnTop, On, Title of Window ; Toggle the always-on-top status of Calculator.
GuiControl,, ListBox1, %wordlist%
GuiControl, Choose, ListBox1, 1
return
;-------------------------------WinCaretShow-----------------------------
WinCaretShow:
WinGetPos , X, Y, Width, Height, A
ix:=A_CaretX + X
iy:=A_CaretY + Y + 20
Gui, Show, NoActivate, SmartGUI  ; NoActivate avoids deactivating the currently active window.
WinMove, SmartGUI, , ix, iy
IfWinActive, SmartGUI
{
SetTimer, WinCaretShow, Off
}
return
;-------------------------------------WordRetrieve---------------------------------
;Assigns the chosen item to the variable "Choice".
WordRetrieve:
Gui, submit, noHide
GuiControlGet, Choice                    ; Retrieve the ListBox's current selection.
StringReplace, OutputVar, Choice, %search%
Send %OutputVar%
;msgBox, You choose:`n`n%Choice% `nsearch%search%
return
; -------------------------------------GuiClose--------------------------------
;Exits the script on closing the GUI
GuiClose:
GuiEscape:
   ExitApp
; -------------------------------------lbutton--------------------------------

~lbutton::
Gui, Hide
search =
SetTimer, WinCaretShow, Off
return
;--------------------------------------DeleteSearchChar-----------------------------------
;Delete the last character and update Listbox:
DeleteSearchChar:

if search =
    return

StringTrimRight, search, search, 1
GuiControl,, Edit1, %search%
GoSub, RefreshListBox

return
;------------------------------------ListBoxClick-------------------------------------

; Handle mouse click events on the list box:
ListBoxClick:

if A_GuiControlEvent = Normal ;DoubleClick
Gui, submit, noHide
GuiControlGet, Choice
;MsgBox Choice: %Choice%
ToolTip, Multiline`n%Choice%
    ;send, {enter}
sleep, 1000
ToolTip
return

===================================
acs.txt
show
enable
disable
exit
configure terminal
interface
no shutdown
encapsulation ppp
ppp authentication chap
ppp chap hostname routerB
ppp chap password 12345
Back to top
View user's profile Send private message
toralf



Joined: 31 Jan 2005
Posts: 3841
Location: Bremen, Germany

PostPosted: Mon May 08, 2006 7:04 am    Post subject: Reply with quote

Hi faerl

Thanks for sharing.

It would help other users, if you would write two/three sentences that describe the pupose of the script. The title or comment in the code do not give a hint. Thanks.
_________________
Ciao
toralf
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Guest






PostPosted: Tue May 09, 2006 6:17 am    Post subject: Reply with quote

SmartEdit's Code completion features help you write code faster and more accurately by presenting context-sensitive pick lists of possible values to insert into your code based on a few characters you have already typed. If a list has many choices, you can narrow them down by typing one or more additional characters. When you pick a value from a code completion list, the complete value is accurately inserted, and the caret intelligently positioned for the next edit.

The CodeCompletion feature allows you to quickly complete different kinds of statements in the code. For example, you may start typing a Commands name and press RWin to complete it. When multiple choices are available, they are shown in the lookup list.


this script have some problem.
eg: space bar can not input
narrow down follow Caret

usage
first open SmartEdit, It will visble when you type any key in a editor

Esc : exit app
Enter: send you type string without change
Rwin : send you select string

Take a look at the scripts if you like:
smartEdit.ahk main app, run smartEdit
acs.txt Code completion file, you can put any string in this file,they can appear completion list
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group