Jump to content

87-key Macro Keyboard

On 7.4.2016 at 4:58 PM, mike1808 said:

Wow, Luamacros is written in TurboDelphi which isn't a popular language, I doubt that anyone will contribute to that project. It's easier to rewrite everything using some mainstream language.

Wait... I've got turbo delphi 2006!

But it's been a long time... I'll have a look at it, maybe I can understand how it works and make some changes. I don't have much experience with turbo pascal, but you learn as you read someone elses code :)

 

I would probably use it for reaper, because reaper to audacity is like premiere to windows movie maker ;D

THERE ARE JUST TOO MANY FUNCTIONS!!! :)

 

cheers

Link to comment
Share on other sites

Link to post
Share on other sites

18 minutes ago, Das_TIER said:

Wait... I've got turbo delphi 2006!

But it's been a long time... I'll have a look at it, maybe I can understand how it works and make some changes. I don't have much experience with turbo pascal, but you learn as you read someone elses code :)

 

I would probably use it for reaper, because reaper to audacity is like premiere to windows movie maker ;D

THERE ARE JUST TOO MANY FUNCTIONS!!! :)

 

cheers

true, but you can get a ton done in audacity if you are patient :D

Link to comment
Share on other sites

Link to post
Share on other sites

Hi, today i saw the video linus posted on youtube about the diy 2cond keyboard... nad i was wondering since i dont really have programing experience if there was an easier way to bind each key, like for example the logitech software in wich i press the key and sellect function.

i intend to use the second keyboard for csgo,since i have a lot of buy binds  combinations +nade scripts.

 

Link to comment
Share on other sites

Link to post
Share on other sites

22 hours ago, mavu said:

No "could", "can".

When you assemble it you can decide whether you solder 2 switches or one in the middle with a large cap.

I'm an idiot.

If I had just taken a peak at the PCB and I would have seen that. Thanks for correcting me!

 

If you ever need to get rid of the IS, I'd be interested depending on the price.

.

Link to comment
Share on other sites

Link to post
Share on other sites

Ok, a small update from me:

1. Luamakros is NOT in Turbodelphi. Its in Lazarus, the old software was written in TD and is pretty much useless.

 

2. Tarans autohotkey script doesn't work on Win7x64, I had to write my own. Also I had to adapt the lua-script to my german keyboard layout, It seems that the "print" key DOES work, not as its written in the script:

--[255] = "printscreen" --these keys do not work   <--- Bullshit! ;)

 

BUT it works just fine now, I'll try to get someting going with automated startup but that is another story.

If anyone's interested, I have attached the .lua file for the german layout :)

 

Cheers

Multi-Keyboard_LUAmacros - German Layout.lua

Link to comment
Share on other sites

Link to post
Share on other sites

I started using Macro keyboards software about 6 months ago, and I will never go back, I create content for education companies which means I use photoshop, illustrator, premiere, CAD, Solidworks, Powerpoint, Word, Publisher and Flash. I am currently planning on buying 9 cheap keyboards and recording a shit load of macros. 

 

But I have a Idea! Instead of 9 keyboards, would I buy a touchscreen monitor and find some way of launching the macros from the monitor just in front of me? Anyone have any comments on this ? Possible solutions ? 

 

Ì wonder would this do the trick http://chessware.ch/virtual-keyboard/

Link to comment
Share on other sites

Link to post
Share on other sites

So I spent a bit of time and made a programmable emoji keyboard using LuaMacros, AutoHotKey, and some of Taran's code. Nothing too fancy, just allows you to bind arbitrary emoji, (or any text really), to keys on a spare keyboard.

 

Here's a link to the GitHub repo if anyone wants to check it out: https://github.com/edabonacci/Programmable-Emoji-Keyboard.

 

The code isn't that neat or tidy, since I had to do some strange things with AHK in order for it to do what I wanted, but it works. Let me know if anyone runs into problems with it, since I haven't tested it on any other computers besides my own yet.

Edited by edabonacci
Link to comment
Share on other sites

Link to post
Share on other sites

Great video,

 

maybe you could do a short tutorial video to help people like me that dont know a lot about the coding side? Just a bit of information for setting up macros within different programs etc? 

 

thanks

Link to comment
Share on other sites

Link to post
Share on other sites

Very informative video, I might give something like this a try. Wouldn't mind more videos on productivity/workflow stuff too.

NO! It's art, it's colonialism and you'll never get it!

Link to comment
Share on other sites

Link to post
Share on other sites

can someone explain how to do it with HID macros i am so confused

 

Link to comment
Share on other sites

Link to post
Share on other sites

I honestly couldn't figure out HID Macros, but I'm more of a coder anyway. However, this coding is very very simple comparably.

Here is a sample of the code I came up with.

Quote

clear()

--lmc_assign_keyboard('MACROS')
--lmc_print_devices()
lmc_device_set_name('MACROS', '36D2CCE2')

 

--lmc_set_handler('MACROS', function(button, direction)
--   if (direction == 1) then return end
--  print('Your key ID number is:   ' .. button)
--   end)       

 

--DownStreamKeys--
lmc_set_handler('MACROS',103,1,function(button, direction)
  print ("DSK1 On");
  lmc_send_keys("^+{F2}")
end)


lmc_set_handler('MACROS',97,1,function(button, direction)
  print ("DSK1 Off");
  lmc_send_keys("^+{F1}")
end)

 

lmc_set_handler('MACROS',105,1,function(button, direction)
  print ("DSK2 On");
  lmc_send_keys("^+{F3}")
end)


lmc_set_handler('MACROS',99,1,function(button, direction)
  print ("DSK2 Off");
  lmc_send_keys("^+{F4}")
end)

 

 


lmc_set_handler('MACROS',49,1,function(button, direction)
  print ("hook 1");
  lmc_send_keys("{F13}")
end)


lmc_set_handler('MACROS',50,1,function(button, direction)
  print ("hook 2");
  lmc_send_keys("{F14}")
end)


lmc_set_handler('MACROS',51,1,function(button, direction)
  print ("hook 3");
  lmc_send_keys("{F15}")
end)


lmc_set_handler('MACROS',52,1,function(button, direction)
  print ("hook 4");
  lmc_send_keys("{F16}")
end)

 

lmc_set_handler('MACROS',53,1,function(button, direction)
  print ("hook 5");
  lmc_send_keys("{F17}")
end)


lmc_set_handler('MACROS',54,1,function(button, direction)
  print ("hook 6");
  lmc_send_keys("{F18}")
end)


lmc_set_handler('MACROS',55,1,function(button, direction)
  print ("hook 7");
  lmc_send_keys("{F19}")
end)


lmc_set_handler('MACROS',56,1,function(button, direction)
  print ("hook 8");
  lmc_send_keys("{F20}")
end)

 

So each one of the handlers is a listener for a certain key condition. The first parameter is the keyboard, which is set at the top with the line lmc_device_set_name('MACROS', '36D2CCE2') the first parameter being the name we want to call the keyboard and the second being the HID ID.

 

The HID ID changes for every keyboard, computer, and even USB ports.

 

Un-comment the two lines above by removing the "--" and run to find the HID ID of the keyboard you want. It will ask you like LTT's code but will print all the HID's after you hit a key on the keyboard you want to change. Look for the one with the name MACROS and in the middle area there is a string of characters that are the right length and surrounded by &'s like below.

 

Example Output

Quote

<unassigned>  :  \\?\HID#WMVIRTUALDEVICE#2&25D493E&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [131357] :  keyboard
<unassigned>  :  \\?\HID#VID_0C40&PID_7A18&MI_00&COL03#8&3CE0F99&0&0002#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65613] :  keyboard
<unassigned>  :  \\?\HID#VID_046D&PID_C52B&REV_1201&MI_02&QID_4024&WI_01&CLASS_0040000E&COL01#8&26FFA63A&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65611] :  keyboard
MACROS  :  \\?\HID#VID_046D&PID_C517&MI_00#7&28FAAD72&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [65609] :  keyboard
<unassigned>  :  \\?\HID#VID_046D&PID_C52B&MI_00#7&2056C60E&0&0000#{884B96C3-56EF-11D1-BC8C-00A0C91405DD} [720967] :  keyboard
Total number of devices: 5
Your key ID number is:   32

 

The keyboard I hit would be ID 28FAAD72

 

Now you can fill in the lmc_device_set_name function with the proper keyboard ID and start setting functions and never have to assign the keyboard again. (Unless you move USB ports or replace it or the computer)

 

Now back to the handlers. The first parameter was the keyboard, which we just set to MACROS with the ID 28FAAD72. The second parameter is the key. To find these the best way is to un-comment the first handler.

 

Quote

--lmc_set_handler('MACROS', function(button, direction)
--   if (direction == 1) then return end
--  print('Your key ID number is:   ' .. button)
--   end)       

This will capture all keys and tell you what its ID is. Note: It does not interrupt other handlers.

 

The third parameter is the direction, 0 is down, 1 is up, you could duplicate a handler and get one function out of a downward key-press versus a releasing upstroke.

 

The last parameter is the function to do on triggering.

 

I print a little helpful reminder of what the key is supposed to do.

 

Finally it sends the key combination I want, using the same modifiers as AutoHotKey ^+!

 

I am building a keyboard for a live video production switcher, the BlackMagic Design ATEM Production Studio 4k, which as you can guess; requires complicated changes through menus and long sequences of clicks and presses. As well as accessory functions outside the switcher software, like pulling up a PowerPoint that plays out back into the switcher and becomes a keyed overlay, live, on top of the camera feeds.

 

For me the real difficulty is in the AutoHotKey script. It's tedious. In my case I need to have AHK look at the screen for certain conditions like virtual buttons being lit or not.

 

Here is an example of that code. I have since made a function to do all that nonsense window checking at the beginning of every macro.

Quote

F12::
IfWinNotExist, ATEM Production Studio 4K
{
    WinRestore, ATEM Production Studio 4K

}
IfWinNotActive, ATEM Production Studio 4K
{
    WinActivate, ATEM Production Studio 4K
}
    WinMaximize,  ATEM Production Studio 4K
    
ControlClick, x25 y50, ATEM Production Studio 4K 
Sleep 100
Send, {Down}
Sleep 100
Send, {Enter}
Sleep 100
Send, ATEM Default 
Sleep 100
Send, {Enter}
Sleep 1000
ControlClick, x1478 y841, ATEM Production Studio 4K 
Sleep 1000
Return


;DSK1 Off
F1::
IfWinNotExist, ATEM Production Studio 4K
{
    WinRestore, ATEM Production Studio 4K

}
IfWinNotActive, ATEM Production Studio 4K
{
    WinActivate, ATEM Production Studio 4K
}
    WinMaximize,  ATEM Production Studio 4K
    
ImageSearch, FoundX, FoundY, 1391, 283, 1612, 541, C:\Users\ATEM\Pictures\AHK\DSK1-On.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=75
    click %FoundX%,%FoundY%
}
   
Return

;DSK2 Off
F2::
IfWinNotExist, ATEM Production Studio 4K
{
    WinRestore, ATEM Production Studio 4K

}
IfWinNotActive, ATEM Production Studio 4K
{
    WinActivate, ATEM Production Studio 4K
}
    WinMaximize,  ATEM Production Studio 4K
ImageSearch, FoundX, FoundY, 1595, 454, 1666, 543, C:\Users\ATEM\Pictures\AHK\DSK1-On.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=75
    click %FoundX%,%FoundY%
}
   
Return

;DSK1 Off
F3::
IfWinNotExist, ATEM Production Studio 4K
{
    WinRestore, ATEM Production Studio 4K

}
IfWinNotActive, ATEM Production Studio 4K
{
    WinActivate, ATEM Production Studio 4K
}
    WinMaximize,  ATEM Production Studio 4K
ImageSearch, FoundX, FoundY, 1391, 283, 1612, 541, C:\Users\ATEM\Pictures\AHK\DSK1-Off.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=75
    click %FoundX%,%FoundY%
}
   
Return

;DSK2 Off
F4::
IfWinNotExist, ATEM Production Studio 4K
{
    WinRestore, ATEM Production Studio 4K

}
IfWinNotActive, ATEM Production Studio 4K
{
    WinActivate, ATEM Production Studio 4K
}
    WinMaximize,  ATEM Production Studio 4K
ImageSearch, FoundX, FoundY, 1595, 454, 1666, 543, C:\Users\ATEM\Pictures\AHK\DSK1-Off.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=75
    click %FoundX%,%FoundY%
}
   
Return
F6::
    WinActivate, ATEM Production Studio 4K
    WinMaximize,  ATEM Production Studio 4K
    ImageSearch, FoundX, FoundY, 944, 1037, 1148, 1148, C:\Users\ATEM\Pictures\AHK\Audio.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=5
    click %FoundX%,%FoundY%
}
Sleep 50
ImageSearch, FoundX, FoundY, 1328, 944, 1423, 1013, C:\Users\ATEM\Pictures\AHK\Audio-Off.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=5
    click %FoundX%,%FoundY%
}
click 870, 1080
Return
F10::
WinActivate, ATEM Production Studio 4K
    WinMaximize,  ATEM Production Studio 4K
    ImageSearch, FoundX, FoundY, 944, 1037, 1148, 1148, C:\Users\ATEM\Pictures\AHK\Audio.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=5
    click %FoundX%,%FoundY%
}
Sleep 50
ImageSearch, FoundX, FoundY, 1328, 944, 1423, 1013, C:\Users\ATEM\Pictures\AHK\Audio-Off.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=5
    click %FoundX%,%FoundY%
}
click 870, 1080
Return


F11::
IfWinNotExist, ATEM Production Studio 4K
{
    WinRestore, ATEM Production Studio 4K

}
IfWinNotActive, ATEM Production Studio 4K
{
    WinActivate, ATEM Production Studio 4K
}
    WinMaximize,  ATEM Production Studio 4K
ImageSearch, FoundX, FoundY, 944, 1037, 1148, 1148, C:\Users\ATEM\Pictures\AHK\Audio.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=5
    click %FoundX%,%FoundY%
}
Sleep 50
ImageSearch, FoundX, FoundY, 1328, 944, 1423, 1013, C:\Users\ATEM\Pictures\AHK\Audio-On.png
if ErrorLevel = 0
{
    FoundX+=5
    FoundY+=5
    click %FoundX%,%FoundY%
}
click 870, 1080
   
Return

The documentation for AHK is far superior to LUAMacros because it exists. I couldn't find a single place with all the functions and references, really scattered and sparse.

The only advice I have for AHK that isn't in the documentation is that the image search returns the top left corner of the matched image, explaining the additions to FoundX/Y. Also it works better with smaller images, (mine are in the range of 20x20 pixels) and a small search area of where it should find that image.

 

The ATEM software does have Macro'ing built in but for some functions it is just better to do it outside. Plus you would still need to create an AHK macro to start the macro in ATEM which in and of itself is not a simple macro.

 

The video LTT did on the 87 key DIY MACRO keyboard really helped me get the ball rolling though. Thanks for that. And I thought I would try and give a little back with some, possibly improved code.

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 month later...

I experimented a bit with this concept fo a fiew hours, and I think I've improve it a bit. It's still uses AutoHotKey as it's much more powerfull in doing complex macros than luamacro.

Instead of writing new file on your hard drive (slow and dependent on hd speed), you can write autohotkey script that can take arguments when it's run.

 

Here's how to do it:

I assume that you already have AutoHotKey installed and luamacros downloaded.

  1. In your luamacros(where LuaMacros.exe is) folder, create new folder, call it "AHK"
  2. In this folder, create new autohotkey script, call it SendKeys.ahk. Use this code:
    #NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
    ; #Warn  ; Enable warnings to assist with detecting common errors.
    SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
    SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
    
    if 0 < 1  ; The left side of a non-expression if-statement is always the name of a variable.
    {
        MsgBox This script requires at least 1 incoming parameters but it only received %0%.
        ExitApp
    }
    
    Send %1%
    Return

     

  3. Save it, right click on it, and choose "Compile Script". This will create SendKeys.exe file.
  4. Now to the luamacros. Open LuaMacros.exe and paste this code: (remember to change id's of keyboards to something unique for each keyboard, from lmc_print_devices() command. lines 15,16)
    clear()
    lmc.minimizeToTray = true
    lmc_minimize()
    
    print('Version: ' .. lmc.version)
    print(_VERSION)
    
    SendKeysPath = ".//AHK//SendKeys.exe"
    
    function SendKeys(keys)--as keys you can pass anythink that can be used by autohotkey function Send
             lmc_spawn(SendKeysPath, keys)
    end
    
    --change those weird '194036CA' to something unique, in your keyboard id code
    lmc_device_set_name('KB1', '194036CA')--Your primary keyboard
    lmc_device_set_name('KB2', '184B7BA3')--Your secondary keybord, the one with macros
    lmc_print_devices()
    
    
    lmc_set_handler('KB2',function(button, direction)
        if (direction == 0) then return end  -- ignore key up
    
        print('Callback for whole keyboard 2: button ' .. button .. ', direction '..direction)
        if(button == string.byte('N')) then
            lmc_spawn("notepad")-- run notepad program
        elseif ( button == string.byte('T')) then
            SendKeys("test")-- write "test"
        elseif ( button == string.byte('S')) then
            SendKeys("{Media_Play_Pause}")
        end
    end)

     

  5. Save it in the same folder as LuaMacros.exe, Call it "MyAwsomeMacros.lua".
  6. Now test it. Run this script in luamacro (it will hide itself to tray, that's expected). Try pressing "T" on your secondary keyboard. It should write "test". If it didn't try:
    1. running luamacros with administator privileges.
    2. check if SendKeys.exe is in AHK folder, and that AHK folder is in the same folder as LuaMacros.exe
    3. make sure that you correctly changed keyboards id's in luamacros script (lines 15,16)
  7. (optional but usefull) Autostart luamacros script
    1. create shortcut to LuaMacros.exe
    2. go to properties of this shortcut and add " -r MyAwsomeMacros.lua" to "target element" field, so you should have something like this "C:\Users\YourUserName\Documents\luamacros\LuaMacros.exe -r MyAwsomeMacros.lua"
    3. find your autostart folder (depending on version of your windows, google it if you dont know where it is)
    4. coppy paste shortcut to LuaMacros.exe to autostart folder.
    5. now your macros will be activated on system bootup

How it's working:

When you call "SendKeys()" function in our luamacros script, it's running SendKeys.exe which is our compiled autohotkey script.

Path to SendKeys.exe is defined in line 8 "SendKeysPath = ".//AHK//SendKeys.exe" "

But it's not just running the script, it's also passing argument with what script should do.

It works just like command line arguments eg. "notepad.exe myFile.txt", opens file called myFile.txt in notepad. in the same way we are passing what keypresses should be simulated by autohotkey using SendKeys.exe "test".

So now, what is in SendKeys.ahk. Not like most autohotkey scripts, we are not listening here for any key strokes. Basicly what really maters is only line 12 "Send %1%" it says "take first argument (%1%) and call Send function on it. Send function is basic autohotkey function that can simulate almost any keystrokes. Here's documentation.

The if statement above is just a check if there is any argument passed to the script.

 

If you want autoHotkey to use other functions beside Send it's just matter of adding if's to SendKeys.ahk.

eg if you want to get pixel color under your mouse, you add 

if 1 = "GetPixel"
{
	MouseGetPos, MouseX, MouseY
	PixelGetColor, color, %MouseX%, %MouseY%
	MsgBox The color at the current cursor position is %color%.
}
return

before Send %1%, in line 11 of SendKeys.ahk and then, in MyAwsomeMacros.lua call SendKeys("GetPixel").

 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 4 weeks later...

Is this possible on Mac OS X without running boot camp windows and if so how?

Link to comment
Share on other sites

Link to post
Share on other sites

7 hours ago, Astin said:

Is this possible on Mac OS X without running boot camp windows and if so how?

Well, do you want to run Windows inside Mac OS?  If so, check our Parallels.  Its awesome.  If you want to run Windows as the actual OS on Apple hardware, your easiest option is to use Boot Camp.  I haven't heard of anyone running Windows via a different method.  Why don't you want to use Boot Camp?

Link to comment
Share on other sites

Link to post
Share on other sites

i made  mine using the mouselic cordinate sistem so i can use it in mmorpg such as pwi   becaus  u cant re asing keybinds to the sqares in tyhe uper rows  

 

If (key = "1") 
{
MouseClick, left, 797, 746 
sleep 30
}
else If (key = "2") 
{
MouseClick, left, 835, 746
sleep 30
} 
else If (key = "3") 
{
MouseClick, left, 870, 746
sleep 30
}
else If (key = "4") 
{
MouseClick, left , 906, 746 
sleep 30
} 

and so on for all the numeric and carecter keys   then do the cuting and gluing part and voila u get custum game keybord 

so screw u  z bord 

 

now i need to figure out how to program a key that lets me tugle betwen the macro keys and being able to tipe on the same keybord

pwi.ahk

oups.png

Link to comment
Share on other sites

Link to post
Share on other sites

also is the a way to exclude keys like the 4 arow keys  so that ther not past tro to ahk  but stil move the carater in game 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 1 month later...

@nicklmg, is Taran still looking for someone to help him with this?  I'm a senior software engineer, with a heavy focus of systems programming, looking for a project to do in my spare time.

Link to comment
Share on other sites

Link to post
Share on other sites

Savstars, you should look into combining the functions of luamacros into AutoHotKey. 

Link to comment
Share on other sites

Link to post
Share on other sites

I would want to use this for my photoshop tasks but don't want the hassle of the luo coding bit. 

Link to comment
Share on other sites

Link to post
Share on other sites

  • 2 months later...

I just registered to say thank you; thank you! <:-)

 

I was often thinking about using a second keyboard for hotkeys and even started to code my own (kinda shitty) thing, but never got really into it.

The combination of LuaMacros and AutoHotkey is awesome! I'm reading and experimenting since a couple of days and yeah, it's totally fun.

Link to comment
Share on other sites

Link to post
Share on other sites

In Luamacros how do I do to send a special key command. For example, if I want to press "A" and send a backspace, how do I do it?

 

To send another char the code is like this 

if (button == 96) then lmc_send_keys('q')

How about to send a backspace?

Link to comment
Share on other sites

Link to post
Share on other sites

  • 4 weeks later...

This might be too late to ask this but...

I wanted to use this functionally for PC gaming. Bare with me. I wanted to see if I could use this in order to bind several keys in counter strike.

As of now, people bind several keys on their keyboards to say a phrase. Typically written out like so : bind K "say I'm leaving you behind."

 

I was wondering if there was a way to use this method to bind more keys to more phrase. Or if counter strike just wouldn't be able to see the other keys as "other" keys. Thaks for the help!

Link to comment
Share on other sites

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

×