Disable original key echo

Announcements, questions
alex
Posts: 3
Joined: 09 Dec 2015, 14:34

Re: Disable original key echo

Post by alex » 15 Dec 2015, 14:46

Having same problem here.


Code: Select all

-- assign logical name to macro keyboard
print(lmc_device_set_name('MACROS', 'ACPI#MSFT0001'));
 lmc_print_devices();

lmc_set_handler('MACROS',45,1,function(button, direction)
  lmc_send_keys("{END}")
end)
lmc_set_handler('MACROS',35,1,function(button, direction)
  lmc_send_keys("{INS}")
end)

i have end and insert button at the same key, I want to invert their behaivor.
it basically works fine, but when I press "end" it passes "ins" as well.
For example - Shift-END causes selection + inerting item.

SifJar
Posts: 5
Joined: 12 Jan 2016, 13:55

Re: Disable original key echo

Post by SifJar » 12 Jan 2016, 14:06

I'm experiencing this problem as well. Was the DLL to always block the key ever made?

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Disable original key echo

Post by admin » 13 Jan 2016, 08:55

Not yet, if you're willing to test, I'll prepare this dll
Petr Medek
LUAmacros author

SifJar
Posts: 5
Joined: 12 Jan 2016, 13:55

Re: Disable original key echo

Post by SifJar » 13 Jan 2016, 15:23

admin wrote:Not yet, if you're willing to test, I'll prepare this dll
Upon further testing (as mentioned in my other topic), it appears only to apply to the Windows key, unfortunately. So I'm not experiencing the same issue as others I don't think.

tld1990
Posts: 1
Joined: 09 Feb 2016, 20:10

Re: Disable original key echo

Post by tld1990 » 09 Feb 2016, 20:26

I have the echoing of the original key problem.

The actual problem
When I use a macro recorded with LuaMacros the original keypress gets sent as well. LuaMacros doesn't seem to stop the system from getting the original keypress.
Using the script below when I press 1 on my USB numpad (button 97) I get "1762" in Notepad, the LuaMacros editor and every other window I can try it in. I'll try it here now: 1762

Possible hint for a solution?
With

Code: Select all

if (direction == 1) then return end 
The original key 1 gets sent when the key is pressed DOWN.
The LuaMacro gets sent when the key is RELEASED.
Meaning if I press the key down and hold it for a moment and then release the result looks like this: 1111111111111111111111111111111111111111762

If I comment out the direction line or set the value to some other number both the original key press and the LuaMacro will print out at press DOWN: 17621762176217621762176217621762762

Maybe if I can bind the key presses down as something to be ignored? Or the LuaMacro to be sent only when the key is pressed down?
Edit: Unless the problem is with lmc_send_keys not removing/replacing the original string with the new one, but rather simply adding to the existing string?

What am I using?
Windows 10 Pro 64bit
Deltaco USB numpad
Tried running Compatability mode for Windows 7, Windows Vista.. no dice.
Tried running with Admin rights.. no change.



Here is my entire .lua:

Code: Select all

-- assign logical name to macro keyboard
clear();
lmc_print_devices();
lmc_device_set_name('TLD1990KEYB', '2FB0C399')
lmc_assign_keyboard('TLD1990KEYB')
-- lmc.minimizeToTray = true
-- lmc_minimize()

-- define callback for whole device
-- NUMLOCK MUST BE ON! RED LIGHT ON!
lmc_set_handler('TLD1990KEYB',function(button, direction)
  if (direction == 1) then return end  -- ignore down
  if     (button == 97) then lmc_send_keys('762') -- key 1
  elseif (button == 98) then print('Callback for keyboard TLD1990KEYB key "2".')
  elseif (button == 99) then print('Callback for keyboard TLD1990KEYB key "3".')
  elseif (button == 100) then print('Callback for keyboard TLD1990KEYB key "4".')
  elseif (button == 101) then print('Callback for keyboard TLD1990KEYB key "5".')
  elseif (button == 102) then print('Callback for keyboard TLD1990KEYB key "6".')
  elseif (button == 103) then print('Callback for keyboard TLD1990KEYB key "7".')
  elseif (button == 104) then print('Callback for keyboard TLD1990KEYB key "8".')
  elseif (button == 105) then print('Callback for keyboard TLD1990KEYB key "9".')
  elseif (button == 96) then print('Callback for keyboard TLD1990KEYB key "0".')
  elseif (button == 110) then print('Callback for keyboard TLD1990KEYB key "DEL".')
  elseif (button == 111) then print('Callback for keyboard TLD1990KEYB key "/".')
  elseif (button == 106) then print('Callback for keyboard TLD1990KEYB key "*".')
  elseif (button == 8) then print('Callback for keyboard TLD1990KEYB key "backspace".')
  elseif (button == 109) then print('Callback for keyboard TLD1990KEYB key "-".')
  elseif (button == 107) then print('Callback for keyboard TLD1990KEYB key "+".')
  elseif (button == 13) then print('Callback for keyboard TLD1990KEYB key "Enter".')
--  elseif (button == string.byte('N')) then lmc_spawn("notepad", "C:\\test.txt")
--  elseif (button == string.byte('H')) then lmc_send_keys('Hello world')
  else print('Not yet assigned: ' .. button)
  end
end)
--lmc_set_handler('TLD1990KEYB',35, 1, function()
--  print('Callback for keyboard TLD1990KEYB key "1".')
--end)   

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Disable original key echo

Post by admin » 11 Feb 2016, 09:13

Nice analysis, thanks.
I can do some tests related to press/release event, but the problem is I cannot see the problem myself - it always works fine at my PC.
I'll try to use your exact script...
Petr Medek
LUAmacros author

MHR
Posts: 1
Joined: 10 Apr 2016, 14:40

Re: Disable original key echo

Post by MHR » 10 Apr 2016, 15:53

Hia,
I'm trying out LuaMacros now as well for development purposes. However, I've run into the same problem described here.
The problem started with some of the keys not being intercepted by LuaMacros at all.

Reading a bit online I've discovered that this might have to do with 'Administrator mode', as the target application for the macro's was running as Administrator.
Only by running LuaMacros as administrator itself it would allow me to catch the keys pressed within this application.

However, this, such as described here, also caused that the key is still being echoed.
You can still delete the key within editors (like notepad) with:

Code: Select all

if (direction == 1) then
     lmc_send_keys('{left}{del}')
     return
end  -- ignore down 
(note, I know I'm sending this while the key is being pressed, but sending it during direction == 0 would not send both up/down events (or 'del' alltogether), if other simulated keys followed.)

Above solution seems to work in most situations, but not in all.
I use a simple .NET forms application to debug the output of LuaMacros. The program consists of a textbox which listens to the KeyDown and KeyUp events and prints it in a debug window.

If I run the test application normally, it will echo the key and generates the event.
If I run the test application as administrator, it will not echo the key nor generate an event.

This was the output of my testing program, typing first 'ABC' followed by NumPad7 (which just returns in the lua script).
Running normally:

Code: Select all

KeyDown     A             65      
KeyUp       A             65      
KeyDown     B             66      
KeyUp       B             66      
KeyDown     C             67      
KeyUp       C             67      
KeyDown     NumPad7       103     
KeyUp       NumPad7       103     
KeyDown     Left          37      
KeyUp       Left          37      
KeyDown     Delete        46      
KeyUp       Delete        46
Running as administrator:

Code: Select all

KeyDown     A             65      
KeyUp       A             65      
KeyDown     B             66      
KeyUp       B             66      
KeyDown     C             67      
KeyUp       C             67      
KeyDown     Left          37      
KeyUp       Left          37      
KeyDown     Delete        46      
KeyUp       Delete        46
Lua code that triggers it:

Code: Select all

-- define callback for whole device
lmc_set_handler('MACROS', function(button, direction)
  print('key: ' .. button .. ' - ' .. direction)

  if (direction == 1) then
     lmc_send_keys('{left}{del}')
     return
  end  -- ignore down

  if (button == 103) then return                   -- 7
  elseif (button == 104) then return               -- 8
  elseif (button == 105) then return               -- 9
  else print('Not yet assigned: ' .. button)
  end
end) 
The program I used for testing is in the attachments (with its source code if you want to build it yourself).

Hope it helps!
Attachments
KeyTest.zip
The testing program + src as reference.
(36.85 KiB) Downloaded 503 times

admin
Site Admin
Posts: 735
Joined: 01 Nov 2010, 13:00
Location: Prague, Czech republic
Contact:

Re: Disable original key echo

Post by admin » 11 Apr 2016, 08:19

Thanks, nice work.
These days I'm busy with different sw project but once I'm back to LuaMacros improvements I'll definitely play with your test program and see what can be done.
Petr Medek
LUAmacros author

xaker_of_xanthi
Posts: 3
Joined: 13 Apr 2016, 13:58

Re: Disable original key echo

Post by xaker_of_xanthi » 13 Apr 2016, 19:48

Hello. The luamacros is just craaaaaaaaaaaazy good job man.
I have the same thing with the keystrokes example "aok" and not just "ok" windows 8.1 64.
I try the follow
1.unplug the keyboard
2.close the luamacros
3.now reopen the luamacros
4.load your macros
5.plug your keyboard
6.push run
7.assign keyboard
and now works for me and with 2 keyboards for macros.

Edvards55
Posts: 1
Joined: 08 Jun 2020, 09:26

Re: Disable original key echo

Post by Edvards55 » 08 Jun 2020, 09:30

i found that my code only does that in windows specific text boxes (Windows search, File explorer, etc.) but otherwise it works great but it is also intended to be used with autohotkey heres the code:

Code: Select all

clear()
local keyboardIdentifier = '0000AAA'



if keyboardIdentifier == '0000AAA' then
	lmc_assign_keyboard('MACROS');
else lmc_device_set_name('MACROS', keyboardIdentifier);
end

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.')

lmc.minimizeToTray = true
--lmc_minimize()

--Start Script
sendToAHK = function (key)
      --print('It was assigned string:    ' .. key)
      local file = io.open("C:\\AHK\\2nd-keyboard\\LUAMACROS\\keypressed.txt", "w") -- writing this string to a text file on disk is probably NOT the best method. Feel free to program something better!
     	  --print("we are inside the text file")
      file:write(key)
      file:flush() --"flush" = "save."
      file:close()
      lmc_send_keys('{F24}')
end

local config = {
	[45]  = "insert",
	[36]  = "home",
	[33]  = "pageup",
	[46]  = "delete",
	[35]  = "end",
	[34]  = "pagedown",
	[27]  = "escape",
	[112] = "F1",
	[113] = "F2",
	[114] = "F3",
	[115] = "F4",
	[116] = "F5",
	[117] = "F6",
	[118] = "F7",
	[119] = "F8",
	[120] = "F9",
	[121] = "F10",
	[122] = "F11",
	[123] = "F12",
	[8]   = "backspace",
	[220] = "backslash",
	[13]  = "enter",
--	[16]  = "rShift",
--	[17]  = "rCtrl",
--	[38]  = "up",
--	[37]  = "left",
--	[40]  = "down",
--	[39]  = "right",
--	[32]  = "space",
	[186] = "semicolon",
	[222] = "singlequote",
	[190] = "period",
	[191] = "slash",
	[188] = "comma",
	[219] = "leftbracket",
	[221] = "rightbracket",
	[189] = "minus",
	[187] = "equals",
--	[96]  = "num0",
	[97]  = "num1",
	[98]  = "num2",
	[99]  = "num3",
	[100] = "num4",
	[101] = "num5",
	[102] = "num6",
	[103] = "num7",
	[104] = "num8",
	[105] = "num9",

	[106] = "numMult",
    [107] = "numPlus",
--    [108] = "numEnter",
	[109] = "numMinus",
--    [110] = "numDelete",
	[111] = "numDiv",
    [144] = "numLock",
      
    [192] = "disdontwork",
    [9]   = "tab",
--  [20]  = "capslock",
--    [18]  = "alt",


	[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
}


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])
				sendToAHK(config[button])
	else
                print(' ')
                print('Not yet assigned: ' .. button)
	end
end)     

Post Reply