how do I use an environment variable in a Click statment

Asked by Marc Summers on 2018-04-12

if exists("os.environ('USERPROFILE')\Desktop.sikuli\exit.png"):
    click("os.environ('USERPROFILE')\Desktop.sikuli\exit.png")

I am trying to use an environment variable in the if exists
and click statements, but I do not know the correct syntax.

Can you help me?

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
Sikuli Edit question
Assignee:
No assignee Edit question
Solved by:
masuo
Solved:
2018-04-13
Last query:
2018-04-13
Last reply:
2018-04-13
Best masuo (masuo-ohara) said : #1

Use addImagePath()
http://sikulix-2014.readthedocs.io/en/latest/scripting.html?#addImagePath

Then you do not need to specify the entire path as the argument to exists() and click().

masuo (masuo-ohara) said : #2

newimagepath = os.path.join(os.environ.get('USERPROFILE'),'Desktop.sikuli')
addImagePath(newimagepath)

Marc Summers (2aircraft) said : #4

Thanks masuo, that solved my question.