Jump to content
Corsair Community

Translating Cue Macros into AHK regex's


hastegag
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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... :)))

Link to comment
Share on other sites

 Share

×
×
  • Create New...