Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.03 KB | None | 0 0
  1. /*
  2. AutoHotkey Version: 1.0.48.05
  3. Language: English
  4. Platform: Win9x/NT
  5. Author: Leo Xiong <leoxiong@txttext.com>
  6.  
  7. Script Function:
  8. Intelisense, auto-suggests words as you type with custom wordlist
  9. */
  10.  
  11. /*
  12. AutoHotkey Version: 1.0.48.05
  13. Language: English
  14. Platform: Win9x/NT
  15. Author: Leo Xiong <leoxiong@txttext.com>
  16.  
  17. Script Function:
  18. Intelisense, auto-suggests words as you type with custom wordlist
  19. */
  20.  
  21. #SingleInstance Force
  22. #IfWinExist, Intelisense Suggestion Box
  23. SetBatchLines, -1
  24. CoordMode, Mouse, Screen
  25. CoordMode, Caret, Screen
  26.  
  27.  
  28. ;[Settings]
  29. ;RegRead, AutoHotkeyDir, HKEY_LOCAL_MACHINE, SOFTWARE\AutoHotkey, InstallDir
  30. WordListDir = WordList.txt ;%AutoHotkeyDir%\Extras\Editors\Syntax\CommandNames.txt
  31. EndChr = ~!@#$`%^&*()_+{}|:"<>?`-=[]\;',./" " ;State the characters which will terminate suggestions
  32. ;[/Settings]
  33.  
  34. ;[Assigning keyboard hotkeys]
  35. Loop, 113
  36. Hotkey, % "~" Chr(A_Index+9), KeyDown
  37. ;[/Assigning keyboard hotkeys]
  38.  
  39. ;[Loading Gui]
  40. Gui, Font, Verdana Bold
  41. Gui, +Resize -Caption +LastFound +AlwaysOnTop +ToolWindow +MinSize150x30 +MaxSize150x160
  42. Gui, Margin, 0, 0
  43. Gui, Add, ListBox, x0 y0 w150 h80 vListBoxSuggestions gListBoxSuggestions
  44. Gui, Show, -Hide, Intelisense Suggestion Box
  45. ;[/Loading Gui]
  46.  
  47. FileRead, WordList, %WordListDir%
  48.  
  49. SetTimer, CheckInput, 0
  50. SetTimer, SetTimer, 0
  51.  
  52. Return
  53. ;[Body]
  54. CheckInput:
  55. Input, InputChr, L1 V
  56. Word .= InputChr
  57. Suggest:
  58. If InStr(EndChr,InputChr) Or (Word = "")
  59. Goto GuiClear
  60. GuiControl,, ListBoxSuggestions, |
  61. StringSplit, Word, Word
  62. ;--[Match score]
  63. Loop, Parse, WordList, `n
  64. {
  65. ToolTip, Word: %Word%`nA_Indxe: %A_Index%
  66. If (Word = SubStr(A_LoopField,1,StrLen(Word))) And (Word <> A_LoopField) And (A_LoopField <> ""){
  67. GuiControl,, ListBoxSuggestions, %A_LoopField%|
  68. IfWinNotExist, Intelisense Suggestion Box
  69. Gui, Show, x%A_CaretX% y%A_CaretY% NoActivate
  70. }
  71. Continue
  72. KeyDown:
  73. StringRight, InputChr, A_ThisHotKey, 1
  74. Word .= InputChr
  75. Goto, Suggest
  76. Return
  77. }
  78. ;--[/Match score]
  79. GuiControl, Choose, ListBoxSuggestions, 1
  80. ;[/Body]
  81.  
  82. Return
  83. ;[Hotkeys]
  84. ;--[Backspace - delete last character]
  85. ~BackSpace::
  86. StringTrimRight, Word, Word, 1
  87. Goto, Suggest
  88.  
  89. ;--[/Backspace]
  90.  
  91. Return
  92. ;--[Left, Space, Enter - close 'Intelisense Suggestion Box']
  93. ~Left::
  94. ~Space::
  95. ~Enter::
  96. Goto, GuiClear
  97. ;--[Left, Space, Enter]
  98. Return
  99. ;--[Up, PgUp - choose suggestion]
  100. PGUP::
  101. Up::
  102. ControlSend,, {Up}, Intelisense Suggestion Box
  103.  
  104. Return
  105. ;--[Down, PgDown - choose suggestion]
  106. PGDN::
  107. Down::
  108. ControlSend,, {Down}, Intelisense Suggestion Box
  109.  
  110. Return
  111. ;--[DoubleClick, Enter, Right, Insert - choose and complete entered suggestion]
  112. ListBoxSuggestions:
  113. If (A_GuiEvent <> "DoubleClick")
  114. Return
  115. Right::
  116. Insert::
  117. Tab::
  118. GuiControlGet, SelectedSuggestion,, ListBoxSuggestions
  119. ControlSend,, % SubStr(SelectedSuggestion,StrLen(Word),StrLen(SelectedSuggestion)-StrLen(Word)), %ActiveWinTitleOld%
  120.  
  121. ;--[/DoubleClick, Enter, Right, Insert]
  122. ;[/Hotkeys]
  123.  
  124. ;--[GuiClear - Clear 'ListBoxSuggestions', hides Gui and clear variable]]
  125. GuiClear:
  126. GuiControl,, ListBoxSuggestions, |
  127. Gui, Hide
  128. Word =
  129. ;--[/GuiClear]
  130.  
  131. Return
  132. ;[SetTimer - Commands and settings to be checked regularly]
  133. SetTimer:
  134. WinGetActiveTitle, ActiveWinTitle
  135. MouseGetPos, MouseX, MouseY,, MouseControl
  136. WinGetPos, WinX, WinY,,, Intelisense Suggestion Box
  137. MouseDistance := (Abs(MouseX - WinX))+(Abs(MouseY - WinY))
  138. TransVar := 255 - ((MouseDistance / 5) / (A_ScreenWidth / A_ScreenHeight))
  139. If (TransVar > 200)
  140. TransVar = 200
  141. Else If (TransVar < 120)
  142. TransVar = 120
  143. If (MouseControl = "ListBox1")
  144. TransVar = 255
  145. WinSet, Trans, %TransVar%, Intelisense Suggestion Box
  146. If (ActiveWinTitle <> "Intelisense Suggestion Box") And (ActiveWinTitle <> ActiveWinTitleOld){
  147. ActiveWinTitleOld := ActiveWinTitle
  148. Goto, GuiClear
  149. }
  150. ;[/SetTimer]
  151.  
  152. Return
  153. ;[GuiSize - Changes control and Gui size]
  154. GuiSize:
  155. GuiControl, Move, ListBoxSuggestions, h%A_GuiHeight%
  156. IfWinExist, Intelisense Suggestion Box
  157. Gui, Show, NoActivate AutoSize
  158. ;[/GuiSize - Changes control and Gui size]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement