Jump to content

how to enter the same key used as a hotkey?


Recommended Posts

If you use _WinAPI_GetAsyncKeyState or use _IsPressed can enter the key in Notepad longer use hotkey can not enter the same key is to do this?

#include <Misc.au3>
#include <WinAPI.au3>
Const $MASCARA = 0x8000
Const $key_1 = 0x31; "1"
Const $key_2 = "32"; "2"
Const $key_3 = "3" ; "3"
Local $hDLL = DllOpen("user32.dll")
HotKeySet($key_3, "key_3")
Run("Notepad.exe")
While 1
$a_key_1 = _WinAPI_GetAsyncKeyState($key_1)
If BitAND($a_key_1, $MASCARA) Then Send("{1 10}")
If _IsPressed($key_2, $hDLL) Then Send("{2 10}")
Sleep(1)
WEnd
Func key_3()
Send("{3 10}")
EndFunc   ;==>key_3
Link to comment
Share on other sites

Hotkeys are usually set to use keys from the keyboard that you won't be using in the program you're interacting with. That's why you're rarely going to see a SHIFT+<some letter or number key> because you are expected to be using them in normal use. Use a different set of keys or you're just going to have to program around it by unsetting the hotkey when you enter the function, then resetting it as you return from from it.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

So hotkey is only seen by the script to perform a function is no more seen by the OS

Link to comment
Share on other sites

Yes, a hotkey is system wide, if you map a hotkey for your script it's going to be sent to your script and not to any other window. If you want it to only go to your script, and only when the script's GUI is active, you'll need to use an accelerator key instead using GUISetAccelerator.

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

@ BrewManNH esclarescimentos thank you for, so even if someone has bad intentions can not use hotkeys to make keylogger, that is correct?

Link to comment
Share on other sites

  • Moderators

Belini,

even if someone has bad intentions can not use hotkeys to make keylogger, that is correct?

You are not correct - a crude keylogger can very well be made using HotKeys. ;)

Any code which looks to identify which key has been pressed from more than a very small selection is in breach of the rules - as I explained at length here. So a script with a HotKey for practically every key on the keyboard is most definitely NOT permitted. :naughty:

Is that quite clear? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

I've wanted to do this a couple of times, actually, in AutoIt, but this was at the time that I was more comfortable with AutoHotKey than I was with AutoIt, so I ended up writing the solution in AutoHotKey and wrote it in AutoIt at a later time. There's a design pattern that you can use to actually intercept the hotkey, and still let the keypress go through.

Here's how it works:

The hotkey gets pressed, and so then the function associated with that hotkey gets called, so then what you do is you send that keypress back to the active window, from within the script.

As a general rule though, you don't want to have to do that. If you're writing a hotkey for your program that triggers some action or another, you want that hotkey to be a unique one.

-- Alex

Link to comment
Share on other sites

@ Melba23 I have never had the intention of violating the forum rules only try to understand how to script using hotkey could be used to keyloog? The keystroke is only seen by the script and elsewhere over the keystroke is not seen then as a keylogger would be if only the script sees the key?

Link to comment
Share on other sites

  • Moderators

Belini,

If you code a script which watches the keyboard and reacts when the keys are pressed, it does not take much effort to add a few lines of code to store these keystrokes somewhere and then send/collect them later. So you do not need to actually write a keylogger to fall foul of the Forum rules. That is why I say in the announcement to which I linked:

if you post any code which checks for the best part of the keyboard...

...do not post code which flouts the spirit, if not the exact letter, of the rules

The code you posted watched the entire keyboard so that it could light up the keys on the "virtual keyboard" GUI. Can you really not see how that could be very easily transformed into a full-blown keylogger? :huh:

Your intention is not important - it was the mere fact that you posted code which watched the keyboard that got you moderated. As Valik has said on many occasions, people need to think a little wider than just the immediate use of the code they post - the rules are there to prevent script kiddies getting a free ride. If I can use an awful analogy, giving them a free ticket is just as bad. :naughty:

Does that make sense now? :huh:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

I agree with you that the script monitors the entire keyboard but to be used as a keylogger would have to be redone and all this does not use anything here, or need to use _WinAPI_GetAsyncKeyState _IsPressed and need to use this loop, case, if ... and none of these commands is the script I posted, most still consider that I posted the script can be adapted to be a keylogger I will not discuss it and give it closed then.

Link to comment
Share on other sites

  • Moderators

Belini,

I agree with you that the script monitors the entire keyboard [...] the script can be adapted to be a keylogger

Exactly - so please do not post anything like it again. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

@ Melba23 consider you a great moderator and even not thinking like you give this matter closed and will not post code that can be interpreted as a keylogger, sorry for making you waste time on this subject.

Link to comment
Share on other sites

  • Moderators

Belini,

Thanks. :thumbsup:

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...