AHK to run PowerShell command Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

AHK to run PowerShell command

05 Jul 2018, 15:14

In my search for a good CSV viewer. I found Windows has it's own CSV VIEWER which is by far the best I have seen.

Now I just needed it to be launched via AHK. How?

The code is simply.

Code: Select all

 Import-Csv yourfile.csv |Out-GridView
remixyz
Posts: 1
Joined: 05 Jul 2018, 12:26

Re: AHK to run PowerShell command

05 Jul 2018, 19:19

Code: Select all

SetKeyDelay, 0, 0

Run, C:\WINDOWS\system32\WindowsPowerShell\v1.0\powershell_ise.exe
Sleep, 3000
string=Import-Csv yourfile.csv |Out-GridView
clipboard = %string%
ControlSend,, {Enter},ahk_exe powershell_ise.exe
Send ^v
Sleep, 200
ControlSend,, {Enter},ahk_exe powershell_ise.exe

Return


I don't know if that was what u want.
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: AHK to run PowerShell command

05 Jul 2018, 20:08

Code: Select all

Run, powershell -NoExit -Command "Import-Csv D:\Desktop\yourfile.csv | Out-GridView"
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: AHK to run PowerShell command

05 Jul 2018, 20:51

tmplinshi wrote:

Code: Select all

Run, powershell -NoExit -Command "Import-Csv D:\Desktop\yourfile.csv | Out-GridView"

damn, this popped...

https://i.imgur.com/3HdyakX.png
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

Re: AHK to run PowerShell command  Topic is solved

05 Jul 2018, 21:27

It's because of the spaces in your path. You can either use:

Code: Select all

Run powershell -NoExit -Command "Import-Csv \"D:\Desktop\your file.csv\" | Out-GridView"
or:

Code: Select all

Run powershell -NoExit -Command "Import-Csv 'D:\Desktop\your file.csv' | Out-GridView"
fenchai
Posts: 292
Joined: 28 Mar 2016, 07:57

Re: AHK to run PowerShell command

05 Jul 2018, 21:54

What about using variables? because I have multiple computers so different filepaths. :D

I figured it out :) thanks
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: AHK to run PowerShell command

05 Jul 2018, 23:50

tmplinshi wrote:It's because of the spaces in your path. You can either use:

Code: Select all

Run powershell -NoExit -Command "Import-Csv \"D:\Desktop\your file.csv\" | Out-GridView"
or:

Code: Select all

Run powershell -NoExit -Command "Import-Csv 'D:\Desktop\your file.csv' | Out-GridView"
Cool stuff.
Is it possible to determine another delimiter than semikolon or comma?
Einfach nur ein toller Typ. :mrgreen:
LAPIII
Posts: 668
Joined: 01 Aug 2021, 06:01

Re: AHK to run PowerShell command

05 Jun 2023, 08:25

Where can I see a list of options like -NoExit and -Command?
RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: AHK to run PowerShell command

05 Jun 2023, 08:34

Google "powershell command line options"

Russ

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 372 guests