Information for the run is contained in a ini-file

Get help with using AutoHotkey and its commands and hotkeys
Albireo
Posts: 1188
Joined: 16 Oct 2013, 13:53

Information for the run is contained in a ini-file

16 Oct 2019, 05:34

I'm having trouble running a program with AHK, that retrieves the information for the run from an ini file.

Starting the program is no problem, if I use the file icon on the desktop. (or in AHK use Run ..desktop\prog.lnk)
The icon Prog.lnk have the following information .:
Under the Tab .: Genväg (Shortcut?)
On the line .: Mål (Target?) "C:\Pvx\Pvxwin32.exe" .\chncupd.ini
On the line .: Starta i (Start in?) C:\Squid2\Program

The program to run is .: c:\pvx\Pvxwin32.exe
And the ini-file with information for the run is .: c:\squid2\program\CHNCUPD.ini

I have tried the following (but it gave not the same result as the Shortcut icon)

Code: Select all

Run "C:\Pvx\Pvxwin32.exe .\chncupd.ini", C:\Squid2\Program
User avatar
TheDewd
Posts: 1391
Joined: 19 Dec 2013, 11:16
Location: USA

Re: Information for the run is contained in a ini-file

16 Oct 2019, 11:29

Code: Select all

Run, C:\Pvx\Pvxwin32.exe C:\squid2\program\CHNCUPD.ini
:?:
Image Bulldozer - Sokoban inspired game from 1994 recreated in AutoHotkey.
Albireo
Posts: 1188
Joined: 16 Oct 2013, 13:53

Re: Information for the run is contained in a ini-file

16 Oct 2019, 11:34

TheDewd wrote:
16 Oct 2019, 11:29

Code: Select all

Run, C:\Pvx\Pvxwin32.exe C:\squid2\program\CHNCUPD.ini
:?:
No it doesn't work. :(
I have tried all this ways

Code: Select all

; Run %comspec% /k "C:\Pvx\Pvxwin32.exe" ".\chncupd.ini", C:\Squid2\Program
; Run "C:\Pvx\Pvxwin32.exe .\chncupd.ini", C:\Squid2\Program

; Run C:\Pvx\Pvxwin32.exe .\chncupd.ini, C:\Squid2\Program
; Run C:\Pvx\Pvxwin32.exe C:\Squid2\Program\chncupd.ini, C:\Squid2\Program
; Run "C:\Pvx\Pvxwin32.exe" C:\Squid2\Program\chncupd.ini, C:\Squid2\Program
; Run C:\Pvx\Pvxwin32.exe chncupd.ini, C:\Squid2\Program
; Run ""c:\pvx\PVXWIN32.exe" ".\chncupd.ini"", c:\squid2\program, max, PvxPID
Albireo
Posts: 1188
Joined: 16 Oct 2013, 13:53

Re: Information for the run is contained in a ini-file

16 Oct 2019, 11:40

I have found a way to start the program with AHK (but maybe there is a better way to do it on?)
(I think the solution is a little complicated)

Code: Select all

SetWorkingDir c:\Squid2\Program
Run %comspec% /c ""c:\pvx\PVXWIN32.exe" ".\chncupd.ini"", c:\squid2\program, MIN, PvxPID	; PID on the CMD window
It works, but I do not like that the CMD window does not close immediately after the command is executed.

To make sure that the CMD window can be closed, a check is done that the program has made its first write to the log file (about 5-10 seconds)
And when the second write to the log-file is done, the AHK-program can be closed. (like this)

Code: Select all

SetWorkingDir c:\Squid2\Program
Run %comspec% /c ""c:\pvx\PVXWIN32.exe" ".\chncupd.ini"", c:\squid2\program,, PvxPID	; PID for the CMD window

FileGetTime LogTime, c:\squid2\program\dll\SQDLL.LOG, M
WriteCount = 0
Loop
{	Sleep 250
	FileGetTime LogTime1, c:\squid2\program\dll\SQDLL.LOG, M
	CountLogTime := LogTime1 - LogTime
	If ( CountLogTime > 0 )
	{	If ( WriteCount = 0 )
		{	; MsgBox ,, Rad %A_LineNumber% -> %A_ScriptName%, Starttid .: %TimeNow% `nLogTime .: %LogTime% `nLogTime1 .: %LogTime1% `nCountLogTime .: %CountLogTime% `nPvxPID .: %PvxPID%
			WinClose ahk_pid %PvxPID%	; Stäng CMD-fönstret
			WinWaitClose ahk_pid %CommLogID%,, 30
			If ErrorLevel
			{	MsgBox 16, Rad %A_LineNumber% -> %A_ScriptName%, % "DOS CMD - could not be closed... `n`nThis program End!"
				ExitApp
			}
			LogTime := LogTime1
		}
		WriteCount += 1
	}
	If ( WriteCount = 2 )
		Break
}

MsgBox ,, Rad %A_LineNumber% -> %A_ScriptName%, the program Pvxwin32.exe is started!

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], JackMa, rpgfreak128 and 269 guests