Reply
Logi Nu
LuckySpammer
Posts: 4
Registered: ‎02-13-2012

Repeat Options when using a Script

[ Edited ]

I have a G13 and I like using the repeat option "while pressed" so I don't have to continusly tap my keys in MMOs. 

 

However recently I had set of sequences I wanted to acheive that a macro just couldn't handle well. So I decided to write a LUA script and got it working. Then I was disappointed to find that the repeat options for a key vanishes when you assigh a script instead of a macro.

 

Why is this? And is there a work around? 

 

Can we get the option added in a later build of the software perhaps?

Logi Guru
bystander
Posts: 1,545
Registered: ‎06-04-2010

Re: Repeat Options when using a Script

Repeat options in script are not easily created, but it is possible with a technique call polling.  The problem with achieving repeating scripts is that the OnEvent function is only called when an event happens, which is when a G or M key is pressed or released as well as when the script is first activated and then deactivated.  Also OnEvent cannot be called until the previous call to OnEvent has ended.   This means that repeating macros cannot be done simply by creating a function that repeats, else it'll lock out all new events until it's done.

 

To get around this problem, you can create a system that will do parts of a script every event and have it continue to do the script every event until it's finished, then restart.  However, as mentioned before, OnEvent is only called when an event is made.  It is possible to create an event at the end of every OnEvent call, which will force the OnEvent function to be repeatedly called.  This can be done by calling SetMKeyState.

 

If you can follow the train of thought I just explained, then you might be able to take advantage of this.  You may be able to do a search on Polling for more examples.

Logi Nu
UPIA
Posts: 2
Registered: ‎02-13-2012

Re: Repeat Options when using a Script

[ Edited ]

hi ..

some time ago i progged this repeat-toggle-function script here:

http://www.logitechusers.com/general-g13-gameboard-talk/9591-repeat-toggle-function-script.html#post...

it is a kind of workaround to make it possible to repeat a function while-pressed or on-toggle without a full polling script. if you dont use too long/many Sleep()s it might help.

otherwise it is like bystander says that you need to get deeper into scritping.

 

 

Logi Guru
bystander
Posts: 1,545
Registered: ‎06-04-2010

Re: Repeat Options when using a Script


UPIA wrote:

hi ..

some time ago i progged this repeat-toggle-function script here:

http://www.logitechusers.com/general-g13-gameboard-talk/9591-repeat-toggle-function-script.html#post...

it is a kind of workaround to make it possible to repeat a function while-pressed or on-toggle without a full polling script. if you dont use too long/many Sleep()s it might help.

otherwise it is like bystander says that you need to get deeper into scritping.

 

 


I saw that earlier.  At the core, that does exactly what I was describing, just in it's simplist form.  It's a good place to start.

Logi Nu
LuckySpammer
Posts: 4
Registered: ‎02-13-2012

Re: Repeat Options when using a Script

[ Edited ]

Thanks for the responses guys.

 

I'm playing with the polling rig now. 

 

Warning, getting geeky: I'm also playing with intercepting the USB communications myself and executing vitual keypresses. 

 

I'm using LibUsbDontNet: http://sourceforge.net/projects/libusbdotnet/ for the USB communication. 

 

I'm sending virtual key presses from a .NET application. But am thinking of allowing the end use to write the scripts using JavaScript so the scripts don't have to be pre-compiled. And doing the integration between the .NET app and JS with Google V8 through: http://javascriptdotnet.codeplex.com/

 

This is all very hacky right now and sort-of-sort-of-not working. If I get even remotely working, I'll open source it and post here. 

 

Thanks again

 

 

Logi Journeyman
h0rse
Posts: 430
Registered: ‎08-13-2010

Re: Repeat Options when using a Script

hi ..

sounds very interesting.

what do you mean by virtual key-presses?

 

-------------- UPIA --------------->
Logi Nu
LuckySpammer
Posts: 4
Registered: ‎02-13-2012

Re: Repeat Options when using a Script

Pretty much exactly what your macros and scripts do now. The keys are not getting physically pressed when you have a macro, the software is sending "virtual" keypresses to the game.

Logi Guru
bystander
Posts: 1,545
Registered: ‎06-04-2010

Re: Repeat Options when using a Script

Seems similar to the Autoit idea we started working with originally.  Where we'd send info to Autoit when a GKey was pressed and released, then just handled all the scripting with Autoit or in his case another piece of software.  The one thing I do like about Logitech's software, is Lua.  Lua is a nice scripting language.