Code: Select all
#SingleInstance, Force
Code_For_The_Temporary_File =
(
#Persistent
SetTimer, Check_For_Esc_Key_Being_Pressed, 50
Return
Check_For_Esc_Key_Being_Pressed:
KeyState := GetKeyState("q", "P")
if (KeyState)
{
SetTitleMatchMode, 2
WinClose, TEST TITLE ahk_exe cmd.exe
FileDelete, , %Name_Of_The_Temporary_File%
ExitApp
}
Return
)
Name_Of_The_Temporary_File := "Close CMD Window Entitled ''TEST TITLE'' When Pressing Of ''q'' Is Detected.ahk"
FileAppend, %Code_For_The_Temporary_File%, *%Name_Of_The_Temporary_File%
Run, %Name_Of_The_Temporary_File%
#1] It only closes one such window, leaving other CMD TEST TITLE windows opened
#2] It does not delete the temporary Name_Of_The_Temporary_File.ahk file
#3] If there already is a Name_Of_The_Temporary_File file present in the folder with the mother script when I execute it then I get a pop-up message saying
---------------------------
Close CMD Window Entitled ''TEST TITLE'' When Pressing Of ''q'' Is Detected.ahk
---------------------------
Error at line 21.
Line Text: Check_For_Esc_Key_Being_Pressed
Error: Duplicate label.
I thought I could easily work around issues #2 and #3 with such version
Code: Select all
#SingleInstance, Force
FileDelete, , %Name_Of_The_Temporary_File%
Sleep 1000
Code_For_The_Temporary_File =
(
#Persistent
SetTimer, Check_For_Esc_Key_Being_Pressed, 50
Return
Check_For_Esc_Key_Being_Pressed:
KeyState := GetKeyState("q", "P")
if (KeyState)
{
SetTitleMatchMode, 2
WinClose, TEST TITLE ahk_exe cmd.exe
}
Return
)
Name_Of_The_Temporary_File := "Close CMD Window Entitled ''TEST TITLE'' When Pressing Of ''q'' Is Detected.ahk"
FileAppend, %Code_For_The_Temporary_File%, *%Name_Of_The_Temporary_File%
Run, %Name_Of_The_Temporary_File%
A] The Close CMD Window Entitled ''TEST TITLE'' When Pressing Of ''q'' Is Detected.ahk file is still not being deleted
B] The mother script adds content of Code_For_The_Temporary_File variable to the content of the Close CMD Window Entitled ''TEST TITLE'' When Pressing Of ''q'' Is Detected.ahk file instead of overwriting that whole content