The issue is it only works once. After first use the window icon appears on windows bar but is not visible.
I have to reload script to make GUI viisble again.
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
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:Destroy
return
}