Powershell escaping characters in script

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
nebasax834
Posts: 3
Joined: 01 Dec 2021, 08:24

Powershell escaping characters in script

Post by nebasax834 » 05 Dec 2021, 11:02

i am trying to run a powershell script from within autohotkey..because the script has json data, the script is formatted weirdly to escape " (double quotes)...but i guess autohotkey also skips characters bcoz escaping i use for the powershell script and is a big mess...i hope somebody can help me with the script to fix it

Code: Select all

ControlGetText, DLink, Edit1, Download File Info ahk_class #32770 ahk_exe IDMan.exe
ControlGetText, Lname, Edit4, Download File Info ahk_class #32770 ahk_exe IDMan.exe

PS = aria2p call addUri -J '[[\"%DLink%\"],{\"out\": \"%Lname%\"}]'

Clipboard := PS

Runwait Powershell.exe  -noexit -Command "%PS%"
if the script is run as %PS% i get an error....but if i paste the script copied into the clipboard and run it manually it runs jus fine

Rohwedder
Posts: 7768
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Powershell escaping characters in script

Post by Rohwedder » 05 Dec 2021, 12:07

Hallo,
untested:

Code: Select all

PS = aria2p call addUri -J '[[\"%DLink%\"]`,{\"out\"`: \"%Lname%\"}]'
https://www.autohotkey.com/docs/commands/Run.htm#Remarks
If Target contains any commas, they must be escaped

nebasax834
Posts: 3
Joined: 01 Dec 2021, 08:24

Re: Powershell escaping characters in script

Post by nebasax834 » 05 Dec 2021, 12:24

thank you..unfortunately tht comma is not the issue in my case.. tested it trying to skip tht comma and it didnt really make a difference...is there any way to pass the command as a string or as RAW to powershell??? or wud it be possible to pass the variable to an external powershell script??

Post Reply

Return to “Ask for Help (v1)”