Jump to content
Corsair Community

How Do I run powershell script with G-Key?


Recommended Posts

I would like to use a G-key to run a .ps1 powershell macro when pressed. I had thought this would be straightforward enough by using the 'Launch Application' action however I found that I am limited to exe, bat and cmd files only.


Is there a way to add more file types that are able to be opened via the 'Run the following program __' command in the 'Launch Application' section? Or simply remove the exe, bat and cmd limitation and have it able to open/run any file?


I realize I can make a bat file that will run the powershell script but I wanted to try and avoid having to make bat files every time I want to run/open a file that isn't either exe, bat or cmd.

Link to comment
Share on other sites

yes others have noted that not only will powershell not open if you run the powershell.exe (due i posit to some weird behavior of the command shell host when run from the Qt framework), and another user was upset about the lack of being able to execute .ahk autohotkey without compiling them which is i assume for the same reason. They may be just running some shellEx in .net i dont know a lot about it, but it may be limited as it does not know where to load dependencies from and other reasons.


Honestly, because it is fairly easy to setup, the best workaround might be to just make an exe that executes the .ps1. Easiest way to do that may even be Autohotkey, just type "

Run ___.ps1

and save it out as a .ahk with autohotkey installed and then right click on the .ahk you made and hit compile, then link G key in Cue to that exe. You could also use register callback example in the SDK with cue that requires a few more steps to setup although it is worth the time invested.


I am so unfamiliar with powershell, but the few times i have used other ppls scripts they have been infinitely powerful. I fsk'd a website the other day just in order to search all their available PDFs at once for a specific thing I was looking for (i didnt have time to look for it the hard way) and was able to get it to grab a list of URLs i generated as they were sequentially saved.


Programming my own socket method would have been a real pain and this banged it out in like a minute for thousands of files.


Get-Content urls.txt | ForEach-Object {Invoke-WebRequest $_ -OutFile $(Split-Path $_ -Leaf)}

Source: https://daniel.streefkerkonline.com/2015/03/08/powershell-download-a-list-of-files/



If my code above in the first block for autohotkey does not work, try this:



There are probably other silent ways to run the task as a scheduled one or as a service in windows or silently, or even on a new desktop that you are not currently using in windows 10. There may be vbs or wsh type methods as well that are just as easy interim fixes

Edited by hastegag
sourcing ps code
Link to comment
Share on other sites


  • Create New...