Works great so far but two annoying thins I want to change:
1. the window opens when booting the PC and keeps in the middle of screen until I close it. I would like to start hidden
2. the sucessive calls the inserted text is not removed so I have to clean the text box again and again every time I use it. I would like the textbox cleaned when losing focus (Escape key)
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Gui, 1: New,, If WinExist("Search in C:\Users\joe\AutoHotkey\hotkeys.txt")
Gui, Add, Text,, Enter the command to search
Gui, Add, Edit, w600 vQuery gShowResult
Gui, Font, s14, Verdana
Gui, Add, Edit, wp h400
FileRead, contents, C:\Users\joe\AutoHotkey\hotkeys.txt
Gui, Show
Return
^l:: Gui, Show
ShowResult:
GuiControlGet, Query
p := ""
for k, v in StrSplit(Query, " ")
(v != "" && p .= "\V*\Q" . v . "\E")
p .= "\V*\R?"
text := Query = "" ? "" : RegExReplace(contents, "si).*?(" . p . ")|.*", "$1")
GuiControl,, Edit2, % text
Return
GuiEscape:
{
;MsgBox escape pressed
Gui, 1:Cancel
return
}