Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- AutoHotkey Version: 1.0.48.05
- Language: English
- Platform: Win9x/NT
- Author: Leo Xiong <leoxiong@txttext.com>
- Script Function:
- Intelisense, auto-suggests words as you type with custom wordlist
- */
- /*
- AutoHotkey Version: 1.0.48.05
- Language: English
- Platform: Win9x/NT
- Author: Leo Xiong <leoxiong@txttext.com>
- Script Function:
- Intelisense, auto-suggests words as you type with custom wordlist
- */
- #SingleInstance Force
- #IfWinExist, Intelisense Suggestion Box
- SetBatchLines, -1
- CoordMode, Mouse, Screen
- CoordMode, Caret, Screen
- ;[Settings]
- ;RegRead, AutoHotkeyDir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir
- WordListDir = WordList.txt ;%AutoHotkeyDir%\Extras\Editors\Syntax\CommandNames.txt
- EndChr = ~!@#$`%^&*()_+{}|:"<>?`-=[]\;',./" " ;State the characters which will terminate suggestions
- ;[/Settings]
- ;[Assigning keyboard hotkeys]
- Loop, 113
- Hotkey, % "~" Chr(A_Index+9), KeyDown
- ;[/Assigning keyboard hotkeys]
- ;[Loading Gui]
- Gui, Font, Verdana Bold
- Gui, +Resize -Caption +LastFound +AlwaysOnTop +ToolWindow +MinSize150x30 +MaxSize150x160
- Gui, Margin, 0, 0
- Gui, Add, ListBox, x0 y0 w150 h80 vListBoxSuggestions gListBoxSuggestions
- Gui, Show, -Hide, Intelisense Suggestion Box
- ;[/Loading Gui]
- FileRead, WordList, %WordListDir%
- SetTimer, CheckInput, 0
- SetTimer, SetTimer, 0
- Return
- ;[Body]
- CheckInput:
- Input, InputChr, L1 V
- Word .= InputChr
- Suggest:
- If InStr(EndChr,InputChr) Or (Word = "")
- Goto GuiClear
- GuiControl,, ListBoxSuggestions, |
- StringSplit, Word, Word
- ;--[Match score]
- Loop, Parse, WordList, `n
- {
- ToolTip, Word: %Word%`nA_Indxe: %A_Index%
- If (Word = SubStr(A_LoopField,1,StrLen(Word))) And (Word <> A_LoopField) And (A_LoopField <> ""){
- GuiControl,, ListBoxSuggestions, %A_LoopField%|
- IfWinNotExist, Intelisense Suggestion Box
- Gui, Show, x%A_CaretX% y%A_CaretY% NoActivate
- }
- Continue
- KeyDown:
- StringRight, InputChr, A_ThisHotKey, 1
- Word .= InputChr
- Goto, Suggest
- Return
- }
- ;--[/Match score]
- GuiControl, Choose, ListBoxSuggestions, 1
- ;[/Body]
- Return
- ;[Hotkeys]
- ;--[Backspace - delete last character]
- ~BackSpace::
- StringTrimRight, Word, Word, 1
- Goto, Suggest
- ;--[/Backspace]
- Return
- ;--[Left, Space, Enter - close 'Intelisense Suggestion Box']
- ~Left::
- ~Space::
- ~Enter::
- Goto, GuiClear
- ;--[Left, Space, Enter]
- Return
- ;--[Up, PgUp - choose suggestion]
- PGUP::
- Up::
- ControlSend,, {Up}, Intelisense Suggestion Box
- Return
- ;--[Down, PgDown - choose suggestion]
- PGDN::
- Down::
- ControlSend,, {Down}, Intelisense Suggestion Box
- Return
- ;--[DoubleClick, Enter, Right, Insert - choose and complete entered suggestion]
- ListBoxSuggestions:
- If (A_GuiEvent <> "DoubleClick")
- Return
- Right::
- Insert::
- Tab::
- GuiControlGet, SelectedSuggestion,, ListBoxSuggestions
- ControlSend,, % SubStr(SelectedSuggestion,StrLen(Word),StrLen(SelectedSuggestion)-StrLen(Word)), %ActiveWinTitleOld%
- ;--[/DoubleClick, Enter, Right, Insert]
- ;[/Hotkeys]
- ;--[GuiClear - Clear 'ListBoxSuggestions', hides Gui and clear variable]]
- GuiClear:
- GuiControl,, ListBoxSuggestions, |
- Gui, Hide
- Word =
- ;--[/GuiClear]
- Return
- ;[SetTimer - Commands and settings to be checked regularly]
- SetTimer:
- WinGetActiveTitle, ActiveWinTitle
- MouseGetPos, MouseX, MouseY,, MouseControl
- WinGetPos, WinX, WinY,,, Intelisense Suggestion Box
- MouseDistance := (Abs(MouseX - WinX))+(Abs(MouseY - WinY))
- TransVar := 255 - ((MouseDistance / 5) / (A_ScreenWidth / A_ScreenHeight))
- If (TransVar > 200)
- TransVar = 200
- Else If (TransVar < 120)
- TransVar = 120
- If (MouseControl = "ListBox1")
- TransVar = 255
- WinSet, Trans, %TransVar%, Intelisense Suggestion Box
- If (ActiveWinTitle <> "Intelisense Suggestion Box") And (ActiveWinTitle <> ActiveWinTitleOld){
- ActiveWinTitleOld := ActiveWinTitle
- Goto, GuiClear
- }
- ;[/SetTimer]
- Return
- ;[GuiSize - Changes control and Gui size]
- GuiSize:
- GuiControl, Move, ListBoxSuggestions, h%A_GuiHeight%
- IfWinExist, Intelisense Suggestion Box
- Gui, Show, NoActivate AutoSize
- ;[/GuiSize - Changes control and Gui size]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement