Sign in to follow this  
Followers 0
SocramMalaquias

Get pressed keys

8 posts in this topic

#1 ·  Posted (edited)

Hello.

First of all, don't be fooled by the title, I don't want to make a Keylogger.

I have here a DVB-T with a remote IR controller, and its keys are mapped to keyboard keys. Some of them are very simple (for example, CH UP is ¡ and CH DOWN is '), but some aren't. Thus, I would want to know which virtual keys are being pressed (and if it's possible, in what keyboard), so I can then make a script to remap them to some functions, like stopping a video on Windows Media Player, ...

Right now I'm trying to use a _IsPressed loop, but I'm unsure if the device uses virtual keys (these special keys Stop, Play, Pause, etc... on newer keyboards) and if _IsPressed support them

If it helps, the application came with the following IR configuration file:

[General]
Name=Default
Plugin=HID Device.dll
[Custom]
MaskCode=0x00FF
[CommandMaps]
1=Power_Off,6,80,0,0,0,0,0,0
2=ReturnLastChannel,6,82,0,0,0,0,0,0
3=Volume_Up,6,187,0,0x00,0,0,0,0
4=Volume_Down,6,189,0,0x00,0,0,0,0
5=Next_Chapter,0,187,0,0x00,0,0,0,0
6=Previous_Chapter,0,189,0,0x00,0,0,0,0
7=Num_1,2,49,0,0,0,0,0,0
8=Num_2,2,50,0,0,0,0,0,0
9=Num_3,2,51,0,0,0,0,0,0
10=Num_4,2,52,0,0,0,0,0,0
11=Num_5,2,53,0,0,0,0,0,0
12=Num_6,2,54,0,0,0,0,0,0
13=Num_7,2,55,0,0,0,0,0,0
14=Num_8,2,56,0,0,0,0,0,0
15=Num_9,2,57,0,0,0,0,0,0
16=Full_Screen,0,27,0,0,0,0,0,0
17=Num_0,2,48,0,0,0,0,0,0
18=Stop,8,35,0,0,0,0,0,0
19=Record,6,84,0,0,0,0,0,0

Thanks

Edited by SocramMalaquias

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

#include <Misc.au3>
$d = DllOpen("user32.dll")
Dim $pressed[256]
Dim $ban[256]
$ban[1] = True
$ban[2] = True
$ban[4] = True
While True
$show = False
For $i = 0 To 256
  $press = _IsPressed($i, $d)
  If $press And Not $pressed[$i] And Not $ban[$i] Then
   ConsoleWrite($i & @crlf)
   $show = True
  EndIf
  $pressed[$i] = $press
Next
If $show Then ConsoleWrite("--" & @crlf)
Sleep(10)
WEnd

I found that, for example, the power button is CTRL+ALT+P, but unfortunately the CH UP nor CH DOWN don't get mapped on 0-255

PS: $ban is the keys I don't want to see (1, 2 and 4 are mouse left, right and center button)

Edited by SocramMalaquias

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

HotKeySet("^!r", "recall")
HotKeySet("+", "volup")
HotKeySet("-", "voldown")
HotKeySet("^!+", "chup")
HotKeySet("^!-", "chdown")
HotKeySet("^1", "button1")
HotKeySet("^2", "button2")
HotKeySet("^3", "button3")
HotKeySet("^4", "button4")
HotKeySet("^5", "button5")
HotKeySet("^6", "button6")
HotKeySet("^7", "button7")
HotKeySet("^8", "button8")
HotKeySet("^9", "button9")
HotKeySet("^0", "button0")
HotKeySet("{ESC}", "zoom")
HotKeySet("{END}", "stop")
HotKeySet("^!t", "rec")
HotKeySet("{SPACE}", "timeshift")
HotKeySet("^!p", "power")

While 1
WEnd

Func recall()
ToolTip("RECALL",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func volup()
ToolTip("VOLUME UP",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func voldown()
ToolTip("VOLUME DOWN",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func chup()
ToolTip("CHANNEL NEXT",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func chdown()
ToolTip("CHANNEL PREVIOUS",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button1()
ToolTip("BUTTON 1",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button2()
ToolTip("BUTTON 2",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button3()
ToolTip("BUTTON 3",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button4()
ToolTip("BUTTON 4",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button5()
ToolTip("BUTTON 5",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button6()
ToolTip("BUTTON 6",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button7()
ToolTip("BUTTON 7",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button8()
ToolTip("BUTTON 8",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button9()
ToolTip("BUTTON 9",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button0()
ToolTip("BUTTON 0",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func zoom()
ToolTip("ZOOM",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func stop()
ToolTip("STOP",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func rec()
ToolTip("REC",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func timeshift()
ToolTip("TIMESHIFT",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func power()
ToolTip("POWER",@DesktopWidth/2,@DesktopHeight/2)
EndFunc

Write to Functions!

Edited by szalaisanyi86

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Sorry!

I'm Hungarian!

Here English keyboards:

Remote key commands:

Power = CTRL+ALT+P

Vol+ = "+"

Vol- = "-"

CH+ = CTRL + ALT + "+"

CH- = CTRL + ALT + "-"

Recall = CTRL + ALT + R

1 = CTRL + 1

2 = CTRL + 2

3 = CTRL + 3

4 = CTRL + 4

5 = CTRL + 5

6 = CTRL + 6

7 = CTRL + 7

8 = CTRL + 8

9 = CTRL + 9

0 = CTRL + 0

Zoom = ESC

Stop = END

Rec = CTRL + ALT + T

Timeshift = SPACE

English keyboards!

HotKeySet("^!r", "recall")
HotKeySet("+", "volup")
HotKeySet("-", "voldown")
HotKeySet("^!+", "chup")
HotKeySet("^!-", "chdown")
HotKeySet("^1", "button1")
HotKeySet("^2", "button2")
HotKeySet("^3", "button3")
HotKeySet("^4", "button4")
HotKeySet("^5", "button5")
HotKeySet("^6", "button6")
HotKeySet("^7", "button7")
HotKeySet("^8", "button8")
HotKeySet("^9", "button9")
HotKeySet("^0", "button0")
HotKeySet("{ESC}", "zoom")
HotKeySet("{END}", "stop")
HotKeySet("^!t", "rec")
HotKeySet("{SPACE}", "timeshift")
HotKeySet("^!p", "power")

While 1
WEnd

Func recall()
ToolTip("RECALL",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func volup()
ToolTip("VOLUME UP",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func voldown()
ToolTip("VOLUME DOWN",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func chup()
ToolTip("CHANNEL NEXT",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func chdown()
ToolTip("CHANNEL PREVIOUS",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button1()
ToolTip("BUTTON 1",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button2()
ToolTip("BUTTON 2",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button3()
ToolTip("BUTTON 3",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button4()
ToolTip("BUTTON 4",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button5()
ToolTip("BUTTON 5",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button6()
ToolTip("BUTTON 6",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button7()
ToolTip("BUTTON 7",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button8()
ToolTip("BUTTON 8",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button9()
ToolTip("BUTTON 9",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func button0()
ToolTip("BUTTON 0",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func zoom()
ToolTip("ZOOM",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func stop()
ToolTip("STOP",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func rec()
ToolTip("REC",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func timeshift()
ToolTip("TIMESHIFT",@DesktopWidth/2,@DesktopHeight/2)
EndFunc
Func power()
ToolTip("POWER",@DesktopWidth/2,@DesktopHeight/2)
EndFunc

Rewrite to Functions!

Edited by szalaisanyi86

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Share this post


Link to post
Share on other sites

Belini,

The code you posted is a full keyboard keylogger - even though it is a pretty poor one. Someone of your experience should know better. :(

I am fed up with repeating myself - use the next 3 days to understand that when I say this I mean it. :naughty:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  
Followers 0