start hidden at boot

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
jomaweb
Posts: 11
Joined: 20 Dec 2020, 06:01

start hidden at boot

09 Feb 2021, 02:37

I have a working script that parses for matching text inside a file when keybinding Ctrl+L is pressed.

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
}
garry
Posts: 3795
Joined: 22 Dec 2013, 12:50

Re: start hidden at boot

09 Feb 2021, 04:31

Code: Select all

;- start hidden at boot 
;- https://www.autohotkey.com/boards/viewtopic.php?f=76&t=86695

#warn
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
#Singleinstance,force
;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 vED2
FileRead, contents, C:\Users\joe\AutoHotkey\hotkeys.txt
;FileRead, contents,C:\test.txt
Return
;---------------------
GuiEscape:
GuiClose:
GuiControl,1:,ED2,
GuiControl,1:,query,
Gui, 1:Cancel
return
;---------------------
^l:: 
Gui, Show
return
;---------------------
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
;======================================================================

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], Chunjee, Hansielein, Lpanatt and 327 guests