Jump to content
Sign in to follow this  
jimboza

Implementing a G15 macro in a script

Recommended Posts

jimboza

Hey I'm new on the scene of scripting but I have made some progress. But another hurdle stands in my way. I have used the G15 macro keys to execute some commands which I found simpler to do with them then Autoit at the moment. I want to include the G15 macro key in a script and allow it to run its macro , IE i would just put the script to sleep for 10000ms while the macro in the G15 works...but I dont know how to get auto it to send the g15 macro key. When i press the macro keys eg G1 on my keyboard it is not recognised by the auto it script editor. So is there a way to include my G15 key in a script? Also, and this is a much simpler question, is there a way to get a script to hold a key for a period of time rather than sending it as a solo push. If so i could struggle through including the G15 macro in the script XD.

Thanks, Jim

Share this post


Link to post
Share on other sites
Kealper

From the AutoIt3 help docs (Under Function Reference for Send()):

To hold a key down (generally only useful for games)
    Send("{a down}") ;Holds the A key down
    Send("{a up}") ;Releases the A key

Not sure if that works all of the time, as some programs do not like simulated keystrokes and the likes, but it usually works.

As for the sending of G15 macro keys, I do not think there is an easy way to go about that. (seeing as I've never owned one, I have never had a reason to look into it, so I could be wrong on that one)

Edited by Kealper

Share this post


Link to post
Share on other sites
z3r0c00l12

I don't think you can map a G# key through autoit as it's not considered a keyboard, I.E : When you plug your keyboard for the first time, without the drivers, it will register 2 Human Interface Devices, one is the actual keyboard, and the other HID is the Multimedia Keys, LCD Screen, M# buttons and G# buttons.

SO, unfortunately, I don't think you can send("{G1}"). But for your other question, yes it is possible to set the key down delay using the SendKeyDownDelay option like such (Untested) :

opt("SendKeyDownDelay", 1000) ;Hold Key for 1000 Milliseconds (Default is 5 Milliseconds)
send("a")
opt("SendKeyDownDelay", 50) ;Hold Key for 50 Milliseconds (This option is useful in games)
send("w")

Like I said, I haven't tested this, but it may help you.

You can probably use this with a mix of Kealper's method and have really good script, even better than the G15 can provide.

Share this post


Link to post
Share on other sites
omikron48

If G15 has a value, you could try using _IsPressed to detect for it.

Dunno how you could try getting the value of the key though.

Share this post


Link to post
Share on other sites
DW1

Try the following code to see if _IsPressed() will pick up the key:

#include<misc.au3>
HotKeySet("{ESC}", "TimeToLeave")
MsgBox(0, "Key Testing", "Press ESC when you are finished")
While 1
    For $a = 0 To 255
        If _IsPressed(Hex($a)) Then
            If $a = Dec("1B") Then
                Exit
            Else
                MsgBox(0, "test", "KEY: " & Chr($a) & @CRLF & 'Hex (Decimal)' & @CRLF & "0x" & StringRight(Hex($a),2) & ' (' & $a & ')')
            EndIf
        EndIf
    Next
WEnd

Func TimeToLeave()
    Exit
EndFunc

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×