The Corsair User Forums  

Go Back   The Corsair User Forums > Corsair Product Discussion > Corsair Utility Engine (CUE)

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-12-2018, 10:47 PM
Woznet's Avatar
Woznet Woznet is offline
Registered User
Woznet's PC Specs
 
Join Date: Mar 2017
Posts: 2
POST ID # = 935148
Woznet Reputation: 10
Default How Do I run powershell script with G-Key?

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.
Reply With Quote


  #2  
Old 01-12-2018, 11:43 PM
hastegag hastegag is offline
Registered User
hastegag's PC Specs
 
Join Date: Dec 2016
Location: Northeast US
Posts: 290
POST ID # = 935150
hastegag Reputation: 10
Default

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 "
Code:
Run ___.ps1
ExitApp
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.

Code:
Get-Content urls.txt | ForEach-Object {Invoke-WebRequest $_ -OutFile $(Split-Path $_ -Leaf)}
Source: https://daniel.streefkerkonline.com/...list-of-files/


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

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

Last edited by hastegag; 01-12-2018 at 11:47 PM. Reason: sourcing ps code
Reply With Quote


Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:25 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.