Code Monkey home page Code Monkey logo

luamacros's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

luamacros's Issues

ctrl+C input

Hi
lmc_send_keys("^{V}") this make ctrl+V like it correctly BUT

lmc_send_keys("^{C}") make something strange ... after using keyboard testers , it seems this make << ctrl + shift + C >> input ( tested with multiple keyboards )

EDIT : in fact every time i want ctrl key in a macro it use ctrl+shift

any ideas to fix it ?

could checksum be provided to the binary releases? thanks

Someone would have jumped out and shout that if the server is hacked,
the checksum could be modified.

BUT from a lay man user like me,
sign-ed.exe = PGP signed .exe > > file with checksum >>> nothing .

hope the develop understand that this help both parties.

thanks.

Some keys don't fire up

Hope this is the best way to ask it:

My keyboard has a key to fire up a calc app and I want to remap it.
Its vk code is:

  • int: 183
  • hex: 0xB7
  • vk code description: VK_LAUNCH_APP2

It happens with that specific key code but could affect another ones like that

And get me the following log:

2017-12-14 10:57:04:679 [KBD]: RAW message: message WM_KEYDOWN, key code 183, extended 0, flags 2, makecode 0, direction UP, keyboard handle 0
2017-12-14 10:57:04:690 [HOOK]: Hook message: key code 183 [183], repeat 1, scan code 0, extended 1, alt 0, previous UP, direction DOWN
2017-12-14 10:57:04:690 [HOOK]: Key log match for key 183 direction 1, time diff 11 ms.
2017-12-14 10:57:04:690 [HOOK]: Raw message not yet arrived for key 183 direction 1, trying PeekMessage.
2017-12-14 10:57:04:690 [HOOK]: Key NOT FOUND in key log for key 183 direction 1.
2017-12-14 10:57:04:744 [KBD]: RAW message: message WM_KEYUP, key code 183, extended 0, flags 3, makecode 0, direction DOWN, keyboard handle 0
2017-12-14 10:57:04:753 [HOOK]: Hook message: key code 183 [183], repeat 1, scan code 0, extended 1, alt 0, previous DOWN, direction UP
2017-12-14 10:57:04:753 [HOOK]: Key log match for key 183 direction 0, time diff 9 ms.
2017-12-14 10:57:04:753 [HOOK]: Raw message not yet arrived for key 183 direction 0, trying PeekMessage.
2017-12-14 10:57:04:753 [HOOK]: Key NOT FOUND in key log for key 183 direction 0.

The last line comes from ukeylogservice.pas line 97, AssignDevice function right after calling AssignDeviceInLogRange and trying to pull the key from pile and store on pKS.DeviceHandle

Not sure if it's the expected behavior or if there's an intention to get this kind of keys working

Enter issues

There seems to be an enter issue, and I managed to track it down and make it consistent.
Code is below.

Input given to keyboard

a
b
c
helloworld
h

Feedback from program:

data: a~
data: b~
data: c~
data: helloworld~
data: h~

What the program does:

a
b
c
helloworld
helloworld

It seems to search for an already printed string and autocomplete to that and send that instead

What I suspected that it would do:
Not to autocomplete and send the string I have given with just the character 'h' with an enter

`-- get luamacros HERE: http://www.hidmacros.eu/forum/viewtopic.php?f=10&t=241#p794
-- plug in your 2nd keyboard, load this script into LUAmacros, and press the triangle PLAY button.
-- Then, press any key on that keyboard to assign logical name ('MACROS') to macro keyboard
clear() --clear the console from last run

local keyboardIdentifier = '2A1CBAB5'

BarCodeScanner1 = ''

print(BarCodeScanner1)

if keyboardIdentifier == '0000AAA' then --if this key is pressed by a known scanner
lmc_assign_keyboard('MACROS'); --just do the input
else lmc_device_set_name('MACROS', keyboardIdentifier); --execute scanner code
end
--This lists connected keyboards
dev = lmc_get_devices()
for key,value in pairs(dev) do
print(key..':')
for key2,value2 in pairs(value) do print(' '..key2..' = '..value2) end
end
print('You need to get the identifier code for the keyboard with name "MACROS"')
print('Then replace the first 0000AAA value in the code with it. This will prevent having to manually identify keyboard every time.')
-- Hide window to tray to keep taskbar tidy
lmc.minimizeToTray = true
--lmc_minimize()

local config = {

[65]  = "a",
[13]  = "Enter",	--Enter

[string.byte('Q')] = "q",
[string.byte('W')] = "w",
[string.byte('E')] = "e",
[string.byte('R')] = "r",
[string.byte('T')] = "t",
[string.byte('Y')] = "y",
[string.byte('U')] = "u",
[string.byte('I')] = "i",
[string.byte('O')] = "o",
[string.byte('P')] = "p",
[string.byte('A')] = "a",
[string.byte('S')] = "s",
[string.byte('D')] = "d",
[string.byte('F')] = "f",
[string.byte('G')] = "g",
[string.byte('H')] = "h",
[string.byte('J')] = "j",
[string.byte('K')] = "k",
[string.byte('L')] = "l",
[string.byte('Z')] = "z",
[string.byte('X')] = "x",
[string.byte('C')] = "c",
[string.byte('V')] = "v",
[string.byte('B')] = "b",
[string.byte('N')] = "n",
[string.byte('M')] = "m",

[string.byte('0')] = "0",
[string.byte('1')] = "1",
[string.byte('2')] = "2",
[string.byte('3')] = "3",
[string.byte('4')] = "4",
[string.byte('5')] = "5",
[string.byte('6')] = "6",
[string.byte('7')] = "7",
[string.byte('8')] = "8",
[string.byte('9')] = "9",

--[255] = "printscreen" --these keys do not work

}

function wait(seconds)
local _start = os.time()
local _end = _start+seconds
while (_end ~= os.time()) do
end
end

-- define callback for whole device
lmc_set_handler('MACROS', function(button, direction)
if (direction == 0) then return end -- ignore key upstrokes.
if type(config[button]) == "string" then
--print(' ')
--print('Your key ID number is: ' .. button)
--print('It was assigned string: ' .. config[button])

	if button == 13 then
		BarCodeScanner1 = '' .. BarCodeScanner1 .. '~'
		print('data:    ' .. BarCodeScanner1)
		lmc_send_keys(BarCodeScanner1)
		BarCodeScanner1 = ''
	else
		BarCodeScanner1 = BarCodeScanner1 .. config[button]
	end 
else
            print(' ')
            print('Not yet assigned: ' .. button)
end

end)
`

Stats

Trying to compile the latest version and uStatsForm is generating errors because TMemo.Lines.Add (TStrings.Add) only accepts one argument but there are multiple calls to Add with two arguments. Example:

Add('Refresh count of this window: %d', [fRefreshCount]);

I am using Lazarus 1.2.6 and I cannot find any documentation that TStrings.Add allows two parameters. It looks like there is a missing Format() around the arguments. Or is there something I am missing?

special characters

When I am wan't it to type ä, ö, or ü it shows up something strange.

Not working in Steam in-home streaming

Created a Lua macros script to reassign keys on a bluetooth numeric keypad to emulate wasd gaming keypad. Works locally, but when using it in Steam in-home streaming, the original numeric keys are sent instead of the remap.

I also tried running Luamacros as administrator, but no difference was found.

Cannot compile - error in TKeyLogService

Trying to compile your luamacros. First was the issue with ExtraHighliters, which was fixed by downloading the update by the person from dec issue.

Now I get the following, but the function is there. I have made no other changes.

error:

ukeylogservice.pas(56,25) Error: function header doesn't match any method of this class "AddRaw(PRAWINPUT):^TKeyStroke;"

What version of lazarus are you using?

code:

TKeyLogService = class
private
fLog: Array[0..cLogArrayLength] of TKeyLogItem;
fIndex: Integer; // points to first free block
fJustScannedKs: TKeyStroke;
procedure AssignDeviceInLogRange(var pKS: TKeyStroke; pSearchCount: Integer);
function KeyStrokeEqual(p1, p2: TKeyStroke): boolean;
public
constructor Create;
function AddRaw(pRawdata: PRAWINPUT): TKeyStrokePtr;
procedure AssignDevice(var pKS: TKeyStroke);
procedure RemoveOldItems;
procedure ResetScanned;
property JustScannedKs: TKeyStroke read fJustScannedKs;
end;

later

function TKeyLogService.AddRaw(pRawdata: PRAWINPUT): TKeyStrokePtr;
begin
case pRawdata^.keyboard.Message of
WM_KEYDOWN, WM_SYSKEYDOWN: fLog[fIndex].KeyStroke.Direction:=cDirectionDown;
WM_KEYUP, WM_SYSKEYUP: fLog[fIndex].KeyStroke.Direction:=cDirectionUp;
end;
fLog[fIndex].TimeStamp:=Glb.UnixTimestampMs;
fLog[fIndex].KeyStroke.DeviceHandle:=pRawdata^.header.hDevice;
fLog[fIndex].KeyStroke.VKeyCode:=pRawdata^.keyboard.VKey;
Result := @(fLog[fIndex].KeyStroke);
if (Glb.ScanService.Scanning) and (fLog[fIndex].KeyStroke.Direction=cDirectionDown) then
begin
fJustScannedKs := fLog[fIndex].KeyStroke;
Glb.DebugLog('Recorder scanned keystroke', cLoggerHook);
end;
fIndex:=(fIndex+1) mod cLogArrayLength;
end;

Help - trying to get LuaMacros to read my HID device

Hello. I have stumbled upon LuaMacros and I feel that this might be the solution for my current project. I am however unable to get it to "see" the HID device I am trying to work with.
I run the lmc_print_devices() and get some of the USB devices I have but not the one I need to work with.
Here is some of the definition items from the device I am trying to work with, perhaps there might be an easy reason why this device does not come up on the list (and hopefully a way to get it to do so!)

clipboard01

Default keys and programmed keys fire up

After a longer time running LuaMacros ( a couple of hours) it sometimes happens that when a button is pressed the default key of the keyboard is send to the running program and also the programmed shortcut is send. So for example if you have a editor running and have something marked and have at num7 the key combination ctr+f for search it rewrites the marked text by 7 and also sends ctr+f after this to open the search dialog.
Only a restart of LuaMacros corrects this behavior.
Sadly I cannot say why this happens and why it sometimes happens after 1 hour and sometimes it is not happening in 8 hours.

Only affects single user (normal or admin), will not run 2 instances at once

After having a problem with an app running in administrator mode not getting mapped keys, I found that luamacros seems to affect only the user that ran the script.
ie If I run as me, it does not affect apps running in admin mode, if I run in admin mode, it does not affect apps that I run in normal mode.
Attempting to start 2 instances of luamacros (one normal, one admin) causes the 2nd instance to crash on startup (regardless of the order)

Errors compiling ExtraHighlighters_RT V1.0

Trying to compile luamacros from source and getting the following errors on the ExtraHighlighters_RT library:

Compile package ExtraHighlighters_RT 1.0: Exit code 1, Errors: 2, Hints: 2 syneditstrconstExtra.pas(4,6) Hint: Unit "SynEditStrConst" not used in SynEditStrConstExtra synhighlighteradsp21xx.pas(210,47) Hint: Parameter "LineNumber" not used synhighlighteradsp21xx.pas(1392,13) Error: Illegal type conversion: "TRangeState" to "Pointer" synhighlighteradsp21xx.pas(1397,13) Error: Illegal type conversion: "Pointer" to "TRangeState"

Tried to fix it using PtrUInt function but just got more errors, not familiar with Object Pascal or Lazarus so probably doing something wrong.

Right-versions of shifts do not work

The SendKeys code allows a < or > modifier after a shift key to modify which key is sent.

No modifier works as expected:

  • ^ = VK_CONTROL
  • % = VK_MENU
  • + = VK_SHIFT
  • # = VK_LWIN

The < modifier works as expected:

  • ^< = VK_LCONTROL
  • %< = VK_LMENU
  • +< = VK_LSHIFT
  • #< = VK_LWIN

The > modifier does not work:

  • ^> = VK_TAB
  • %> = VK_RCONTROL
  • +> = VK_RMENU
  • #> = VK_RSHIFT
  • &> = VK_RWIN

As you can see, the > modifier is off by 1.

key is captured, but still sent through anyway

I'm hoping to use a Chatpad keyboard connected to a wired Microsoft Xbox controller. This is an original Xbox Chatpad, not one of the aftermarket knock-offs. It uses the same connection as the Xbox controller, not a separate USB receiver. It does show up in Windows as a HID device.

The quickstart script sees the keyboard and does detect the CHN sample keystrokes. But the same CHN keys still get sent through to whatever the active text entry screen is at the moment.

I can press c here in this box, calc.exe is started, but the letter c is still also entered here into this text box.

Is there a way to suppress that follow-on keystroke?

I have tried this with another 'regular' USB keyboard and that one DOES NOT have the pass-through problem.

I think I have figured out part of the problem. If I have the Steam game client running I get the problem. If I quit the Steam client the problem goes away. This is not a solution, however, as the whole point of my attempt here is to use the macros during gameplay and that requires the Steam client.

I'm "guessing" the steam client is using some of the same tricks as luamacros to capture and manage the inputs through the controller and chatpad?

Can this be used in a video game?

i have a lua game. can i use this to detect if inputs are from a different keyboard? (for player 2)

if yes, can you give a minimal example

if no, ;(

Recognizing input - Left Ctrl, Right Ctrl

There is a problem with recognizing keys on a keyboard in LuaMacros. Both left control and right control appear as one key (identical key number). Same thing goes with left and right alt. In logs those keys have different "extended" flag.

Left CTRL: Hook message: key code 17 [17], repeat 1, scan code 29, extended 0, alt 0, previous DOWN, direction UP
Right CTRL: Hook message: key code 17 [17], repeat 1, scan code 29, extended 1, alt 0, previous DOWN, direction UP

Need to add the extended flag as 4th parameter of trigger callback.

LuaMacros not working in different native Windows Applications

I registered that LuaMacros is working well in a lot of programms but in some default Windows programs it is absolutely not working correct.
One example for this is the Microsoft Calculator. In here also if the key is set to a shortcut the calculator knows it is always getting the default keys first and the mapped shortcut.
For example if a value is in the calculator and you have the num1 key bound to ctr+c it will add the 1 to the number shown in the calculator and then copying the value to the clipboard but with the extra number.
This is always happening also when LuaMacros and the calculator is fresh started after a system boot.

Pressing other button or same on release

Hello Petr, I need help with LuaMacros.
Is there any chance when I execute my code:

lmc_device_set_name('lul','1549AFE2')
lmc_print_devices()

lmc_set_handler('lul', function(button,direction)
if ( direction == 1) then
lmc_send_input(17, 0, 0)
elseif (direction == 0) then
lmc_send_input(17, 0, 2)
lmc_send_input(17, 0, 0)
lmc_send_input(17, 0, 2)
end
end
)

To work only when i press left ctrl, and all other keys to work properly, I have only one keyboard.

MIDI Support - Volunteering to help

I have a number of Behringer USB devices that I'd really like to be able to use in X-Plane and in general gaming. Lots of sliders and knobs & buttons, you know the type of thing.

Anyway, I don't know Lua or Delphi (yet), though I took Pascal classes many years ago. Regardless of the steepness of the learning curve, I'd like to volunteer to start adding / porting MIDI support.

If you have any guidelines on where to start digging, please let me know. I'd love to collaborate.

Unicode support

I can write a LUA macro containing lmc_send_keys('你好.') and it saves and loads fine, displaying the Chinese characters. However, they don't get typed like that, e.g. in Notepad. Notepad will display the Chinese characters fine when I enter them directly. Is there a way to make it work in LuaMacros? Maybe it's a limitation of SendKeys()?

Send a Key combination on "release" , very new to this.

I would like to send "+F13" to be sent ony when "button 86" is released.

-- //if button 86 is released then send Shift+F13

if (button == 86) then
lmc_send_keys('+{F13}', 50)

//the structure of my currently working code is like this.

lmc_device_set_name('OBSDeck','2FAD678D')
lmc_print_devices()
lmc.minimizeToTray = true
lmc_minimize()

lmc_set_handler('OBSDeck', function(button,direction)
if (direction == 1) then return end

if (button == 86) then --V
lmc_send_keys('+{F13}', 50)

elseif (button == 13) then --enter
lmc_send_keys('%<{ENTER}', 50)

end
end
)

Add start parameters for .exe to wiki

I had no problem to find out how to load a script on start over a shortcut or console. But there was no hint on how to start it instantly. In the forum of hidmacros I found out that it is "-r" and nothing linke "-run" or "-start". Could you add all the important parameters to the wiki?

Building

Can you give me any hints on your build setup.
Mine is just throwing SIGSEGV errors whenever i run it.

Project LuaMacros raised exception class 'External: SIGSEGV'.
At address 10002B71F

Builds ok, and other applications run fine.

Windows10, Lazarus 1.6, FPC 3.0.0

Virtual-key code

It would be great if there was an option to send a virtual key code like described on msdn here

It would open the possibilities to infinite possibilities once lua macros is used beyond flight simulator programs, a good use for that are:

  • send media keys
  • send non European char
  • send special keys, like browser or windows key
  • much more

New/Virtual Keys

I see in the Key Names there is F1-F24, so I though of asking if there is any way to add our own custom virtual keys, like how the MouseButton4 and MouseButton5 are.

I mean, I'd like to have a second keyboard with all the keys different from the main keyboard. Can I just have the second keyboard's keys be, aa, ab, ac, etc. and have them recognized by apps when setting hotkeys?

I want to play old same-screen multiplayer games using different keyboards (so they can both have assigned the exact same keys but on different keyboards).

lmc_send_keys('{NUMLOCK}') don't work

I'm trying to use lmc_send_keys('{NUMLOCK}') to switch between numpad to home, end, and the other keys but it doesn't work in any key ( i've tried with different numpad-only keyboards and other keyboard). Using lmc_send_keys('{CAPSLOCK}') and other special keys works fine, so I don't know what is the problem

lmc_xpl_command has 50 char limit

lmc_xpl_command has a limit of 50 chars so longer commands get truncated and don't work
e.g.
'laminar/B738/EFIS_control/capt/push_button/tfc_press' becomes 'laminar/B738/EFIS_control/capt/push_button/tfc_pre'
In the log file:
2020-07-09 17:45:58:254 [XPLLUMplugin 20220]: XPL doesn't know command laminar/B738/EFIS_control/capt/push_button/tfc_pre

Lmc_print_devices should give the text it prints (and some other stuff) .

I have started working on a "java Client" to exploit LuaMacros ability to intercept keys ans use it to implement a general "programmable keyboards" controller, with various types of macros and with a comprehensive capability of generating application-dependent macro, manually selected use cases, title-dependent use cases and keeping track of various past versions of it.

I know, it is going to be a hell of work... I posted some of the code I did till now here

https://github.com/DaBotz/JavaMacros

Doing so, I come into a set of very small, but frustrating limitations of LuaMacros, problems in building and modding it on my computer (at first, I had issues with the Hilighter package, then with adding the INet package ) and I realized that it is time for me to update the "automatic GUI creator" class(es) that I use for everything.

(They are not nice, but they generate automatically controls from any object, and one has just to tweak their behaviour by implementing some limited business logic, which beats drawing controls around in WindowBuilder for me).

Business as usual

Anyway, I have found some issues with LuaMacros that I feel have a general relevance also to he rest of the world:

  1. It would be nice that lmc_print_devices didn't just print the devices, but also gave back the text it prints. - _More ideally yet, if there was a lmc_list_devices that gave back an array (ehr, numbered map, if I understand well how Lua works) with the devices detected, people might do stuff with it. Us of now, I have stolen some code from https://github.com/mrsimb/macrorecorder and found my way around it, however functional it still makes for a bit of a mess at start-up, which leads to...

  2. It would be good to have a "clear" function for the print window callable from Lua (to hide the aforementioned mess)

  3. It would be a good thing to have a lmc_remove_handler function, to "detach" a device that is not in use for macros any more - alternatively, a "resetAllHandlers" would be good (I know... if I managed to have it built in my Lazarus, it would take some minutes to add it).

  4. It would be wonderful if LuaMacros had a "hard reset" function, that allowed it to "completely restart", reset its table of system handles and re-load and re-launch the current script.

As of now, my Java "monstrosity" can detect when a new keyboard is plugged to the system, but I am forced to kill & re-launch LM (I hope those days had died with HidMacros) because it does not "see" it.

At first, I had tried to simply have the Lua script doing a "system re-scan", but then I realized that LM shares this old HidMacros limitation... it stores the device handles at start, and does not see "new ones", even when one knows that they must be there.

My thanks (and if I manage to get what I am doing wrong with Lazarus, I hope that I will be able to help) for both HidMacros and LuaMacros.

They really helped me (also, it amaze the people that see me drawing what one can do with them and a couple of 10$ numeric pads... ).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.