P.I. Engineering User Forum

Product Support, Technical Questions and Answers, and Examples for P.I. Engineering Products

You are not logged in.

#1 2016-09-11 21:45:15

Registered: 2016-09-11
Posts: 2

Backlighting issues and scripting

I'm new to X-Keys programming, and I'm really enjoying it so far. I'm using two devices (a 16-button stick and a 24-button chunk), and all of my work so far has involved attaching the buttons to a Python script - and I've got a lot of scripts! Thanks for this great hardware.

The one niggling detail that I'm having trouble resolving is with the key backlighting.

The backlighting utility itself works great. I can set individual backlights, save them as a default, etc. The problem is that even when I save it as a default, when the machine it's attached to gets power-cycled, the buttons all come back on at full intensity until I use the backlight utility to reload the default script.

First, I don't think it should be doing that... right? I thought the values were supposed to be stored in nonvolatile memory.

Second, if the backlighting doesn't work that way, I'd like to configure a button to set the backlighting on all of the buttons. Unfortunately, I'm having trouble doing that:

* My first instinct was to script it with Python, where Python is just calling out to the shell and invoking the X-Keys backlight utility with some command-line parameters. Unfortunately, XKeysBacklight ignores all command-line parameters and just loads the GUI. I hoped that the GUI might just be a front end that calls out to another utility... no such luck.

* I read the documentation and found some discussion of Visual Basic. My VB skills are rusty but serviceable, and I'd give this a shot... bit the XKeys scripting architecture is very confusing, and I have some fundamental questions:

(1) Where do I put my VB code so that the macro is available? I could stick it in Script Code (Ctrl-Shift-E), but that seems like a global file, and messing with it seems like a very bad idea. I could stick it into a text file somewhere, but I don't know which files XKeys will actually load and use.

(2) Presuming I've put the macro somewhere where it gets loaded, how do I configure a button to trigger it? The "Macro" window for each button has four areas - Text, Keystrokes, Shortcut, and Function - none is obviously the right place. "Function" is promising, but it looks like it only accepts the preformulated functions. (I found the Macros folder where all of those functions are stored - but to my surprise, those files aren't VB; they're XML that wraps a function stored... somewhere else.)

Any help? Thanks in advance.


#2 2016-09-12 08:51:56

PIE Amber
Technical Software Developer
From: Williamston, MI
Registered: 2016-01-21
Posts: 196

Re: Backlighting issues and scripting

The default backlighting settings are stored in the memory, but if something else -- MacroWorks 3.1 for example -- is running it will take control of the backlighting even if you haven't otherwise programmed anything with it. You can turn this off through a menu option under Tools > Advanced > Disable Scripted Backlighting.

1) Stick your code in "Script Code". This is the only VB file that your device loads. It is not Global, but a unique copy for your individual device. Be sure to make a backup when  hand-editing, just in case. Note that the file itself is located in C:\Users\YourUsername\AppData\Local\PI Engineering\MacroWorks 3\MyScripts\YOURDEVICENAME\ which is a hidden location. It must keep a very specific name in order for our software to load it in (Script_PID#_UID#.mw3), but it may be easier for you to work with the raw file.

2) Simply put your code under "Case 001" for button 1 and so on for all the other buttons. The code under "If State 'Pressed" is what code will execute when the button is pressed.

Try reading the Advanced Help file through the Help menu for an overview of what you can do, and how the script file works. The script was made to be edited by advanced users.

Amber from P.I. Engineering


#3 2016-09-13 16:18:23

Registered: 2016-09-11
Posts: 2

Re: Backlighting issues and scripting

Yep, that worked like a charm. Thank you!


Board footer

Powered by FluxBB