I don't know what to do, please help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
19Daniel93
Posts: 40
Joined: 25 Mar 2021, 12:56
Location: La Habana, Cuba

I don't know what to do, please help

28 Apr 2021, 21:18

hello I was trying to make a script but there are things that I don't understand, I have tried to search and I have not found anything about this. if you could help me please.

First I had a little problem when writing the text, then I saw that it was fixed with () but the% A_ScriptDir% of text I would like it to be written literally, try with "%", (%), {%} but it doesn't work

- how to write %A_ScriptDir% literally in text

- as I could do so that when it is run again it does not add text, but rather creates a New AutoHotkey Script (2).ahk, New AutoHotkey Script (3).ahk, etc ...

- as I could use reload, pause, suspend or close in a script for a different script.

Code: Select all

FileAppend,
(
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.`n; #Warn  ; Enable warnings to assist with detecting common errors.`nSendMode Input  ; Recommended for new scripts due to its superior speed and reliability.`nSetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.`n
), %A_ScriptDir%\Nuevo AutoHotkey Script.ahk
User avatar
flyingDman
Posts: 2848
Joined: 29 Sep 2013, 19:01

Re: I don't know what to do, please help

28 Apr 2021, 22:58

Please use more descriptive topic name, not just "I don't know what to do, please help". Many readers will just skip these topics.
Try something like this:

Code: Select all

top =
(
#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.`n
)

loop
{
if !fileexist("Nuevo AutoHotkey Script(" a_index ").ahk")
	{
	fileappend, %top%, % "Nuevo AutoHotkey Script(" a_index ").ahk"
	break
	}
}
Note the escape character ` before the %

To pause another script, see here:
https://www.autohotkey.com/docs/commands/Pause.htm#Examples
14.3 & 1.3.7
19Daniel93
Posts: 40
Joined: 25 Mar 2021, 12:56
Location: La Habana, Cuba

Re: I don't know what to do, please help

29 Apr 2021, 09:43

:thumbup: Thank you for your help. Could I use "reload" or "close" like "pause"? is that I thought to use it to create a gui that I was adding content and reloading
:D
User avatar
flyingDman
Posts: 2848
Joined: 29 Sep 2013, 19:01

Re: I don't know what to do, please help

29 Apr 2021, 10:43

To kill another script, you can use something like this:

Code: Select all

for process in ComObjGet("winmgmts:").ExecQuery("Select * from Win32_Process where name = 'Autohotkey.exe'")
	if instr(process.CommandLine, "yourscript.ahk") 
		process, close, % process.ProcessId
or use this https://www.autohotkey.com/docs/commands/PostMessage.htm#ExPID to find the processID and then use process, close
To reload a script, close it's process and run it again.
I am not sure if using this technique would be the best to add content to a gui script. Look into using a .ini file instead. https://www.autohotkey.com/docs/commands/IniRead.htm and https://www.autohotkey.com/docs/commands/IniWrite.htm
14.3 & 1.3.7

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: peter_ahk and 340 guests