The Corsair User Forums  

Go Back   The Corsair User Forums > Corsair Product Discussion > Corsair Utility Engine (CUE) 1.x and 2.x

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 08-19-2017, 06:33 PM
hastegag hastegag is offline
Registered User
hastegag's PC Specs
 
Join Date: Dec 2016
Location: Northeast US
Posts: 898
POST ID # = 916799
hastegag Reputation: 20
Default Translating Cue Macros into AHK regex's

For the rare few of you who may need to convert some of your CUE 2 Macros to AutoHotKey compatibility (other some other application), I figured I would share the below.

For me, I had two separate Cue Macros that would take a teed up email and put the addresses into the to, cc, and bcc lines and clean up the top of the email where I had the drafted/suggested folks I was sending the email to. Basically I wanted to combine these two separate Macros into a single Macro. The reason I needed two was because the email may or may not have had attachments which affects the number of tab keys involved.

In cue 2, the software provides you a nice little view of the keys and steps in a macro, but there's not really an easy way to count out separate actions etc.

My solution was to export the cueprofile which contains the macro. Opening in a text editor such as notepad++, you can search for the <name> tag containing the name you gave the macro inside of Cue 2. This has a lot of extra notes to cue that you may need to strip out in order to keep track of what you may need to convert to AHK.

First, I would suggest deleting everything above your first <name> tag.

Then I find replace in normal mode all tabs, in my case it was in the tens of thousands.

There's another thirty eight lines of stuff or so above the first key which you'll find in a <value> tag. Delete all that by hand.

Then ran this regex under find: <[/]*.*>(.*)<[/]*.*>
Replace with $1 and be sure to check Regular Expression or hit Alt R.

Then ran this regex to remove the longer digits that were not delays or other relevant stuff: \d{4,999} and replace with blank

I replaced <[/]*.*> with blank and then ran a replace of ^$\R with blank a few times to clean up empty lines.

Replace "false" without quotes a few times and then I realized the timings are going to be somewhat different with Cue 2 and AHK for a variety of reasons, so the delays and the numbers for me were irrelevant, but mind the fact that your keynames may have numbers in them (mine didn't)

I ran replace of ^\d{1,30}$\R with blank and ^(.*)$\RKey+(.*) with $1,$2

Then I ran ^.*Release.*\R with blank

Then I ran ,Press with blank

and at this point, I ended up with stuff that was a lot simpler to translate to AHK like:

LeftCtrl
Home
Delete
Delete
Delete
Delete
Delete
...

which easily becomes
Send ^{home}
Send {Delete 13}
...

This is a lot of jibberish, but I assume it may be helpful if someone is not familiar with regex or looking to consolidate multiple macros from Cue to decision making macros (in this example, whether the email had an attachment).

I selected a new Macro in cue to mash Ctrl Shift Alt Windows F24 so it wouldn't get in the way and still be recognizable. in AHK it became ^+!#F24:: starting the hotstring defining the actions.
Reply With Quote


1 members found this post helpful.
  #2  
Old 08-22-2017, 07:21 PM
Comet ☄'s Avatar
Comet ☄ Comet ☄ is offline
Witch
Comet ☄'s PC Specs
 
Join Date: Feb 2016
Location: San Francisco Bay Area, California
Posts: 877
POST ID # = 917180
Comet ☄ Reputation: 10
Send a message via Yahoo to Comet ☄
Default

When configuring CUE and AutoHotKey, it is important to realize that the Corsair hardware may initially lack defined key sequences which can be used by AutoHotKey.

For example, G keys of the expanded keyboard would first need to be defined using CUE to emit keystrokes, and then these keystrokes can be automated using AutoHotKey.

If you do not have such definitions within CUE, then AutoHotKey will not be able to detect the keypress of such keys.
Reply With Quote


  #3  
Old 08-22-2017, 09:18 PM
hastegag hastegag is offline
Registered User
hastegag's PC Specs
 
Join Date: Dec 2016
Location: Northeast US
Posts: 898
POST ID # = 917196
hastegag Reputation: 20
Default

Quote:
Originally Posted by Comet ☄ View Post
When configuring CUE and AutoHotKey, it is important to realize that the Corsair hardware may initially lack defined key sequences which can be used by AutoHotKey.

For example, G keys of the expanded keyboard would first need to be defined using CUE to emit keystrokes, and then these keystrokes can be automated using AutoHotKey.

If you do not have such definitions within CUE, then AutoHotKey will not be able to detect the keypress of such keys.
This is absolutely correct and I've done that in other instances to use my Gkeys to do stuff with AHK like formatting selected text (rounding, adding dollar signs and commas etc), and that works amazing, typically using off keyboard keys to not jam myself up like F13-24 or others, but for this example, I wanted to combine two CUE Macros into a decision making macro that allowed me to unify them.

It could only be achieved with a simple conditional (GetPixelColor in my instance to detect whether an attachment was present although there may have been other solutions). This would have been challenging to achieve the other way around, say if I let my cue macro play and then detected some sequence in AHK and then used it to decide on something (the timings are - I would suspect - too tight for that to be effective, even if AHK inserted the required extra tab key within 10 ms or so). Plus I felt as though this method is extensible and if Outlook versions change the tab stops involved or if perhaps I wanted to add a modifier key to take alternate or extra steps like eliminate a FW: in a subject line, I'll be in a better position to do so.

It is still extremely helpful having the cue 2 software record the actions whatever they may be as it is substantially better than other things I have tried - even AHK itself or pulovers macro creator etc. The ability to go from Cue 2 out to AHK I think is kind of clutch. I think we could even write a macro to do that... :)))
Reply With Quote


Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 06:47 PM.


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