Define PATH to pics or logs with A_WorkingDir or other env var

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
aircooled
Posts: 80
Joined: 01 Dec 2018, 08:51

Define PATH to pics or logs with A_WorkingDir or other env var

22 Jan 2019, 08:05

I would like to define the PATH to the script logfiles (write to logs with FileAppend) or to the pics (Image recognition) with env variables.

Today I define:

Code: Select all

ThisLogfile := "C:\Users\dir\Documents\Script.Test Automation." A_Now ".log"
I would like to define:

Code: Select all

ThisLogfile := "%A_WorkingDir%\Script.Test Automation." A_Now ".log"
or

Code: Select all

ThisLogfile := "A_WorkingDir\Script.Test Automation." A_Now ".log"
(unsure if it must have percents here, have tried both)

The same goes for pics location:

Code: Select all

ImageSearch, FoundX, FoundY, 1200, 1, 1610, 200, C:\Users\dir\Pics\PIC_A.png
to be

Code: Select all

ImageSearch, FoundX, FoundY, 1200, 1, 1610, 200, A_WorkingDir\Pics\PIC_A.png
Can this be done? What are the available variables?

A_AhkPath? A_ScriptDir? A_ScriptFullPath?

Haven't been able to make this work
eelrod
Posts: 65
Joined: 10 Apr 2018, 11:17

Re: Define PATH to pics or logs with A_WorkingDir or other env var

22 Jan 2019, 08:50

You're nearly there; use the period to concatenate when evaluating and percents when literal, like so:

Code: Select all

ThisLogfile := A_WorkingDir . "\Script.Test Automation." . A_Now . ".log"
ImageSearch , FoundX , FoundY , 1200 , 1 , 1610 , 200 , %A_WorkingDir%\Pics\PIC_A.png
Sometimes it is difficult to tell which way to do it, but it's always one of the two (as far as I know, at least).

All of the A_xxxx variables listed in the help are usable.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 127 guests