Jump to content

Know pressed key


Recommended Posts

Hi to all, i want to write an hotkey manager...now i want to register the pressed key to set the hot keys. For example i click on a "record button" in my programm...i press on my keyboard CTRL+ALT+M...i press stop button record, and now i want to register this combination key.

I know the function _Ispressed, but is seem to work only if i press just one button at time...there is a way to register a multipressed buttons?

Hi!

Edited by StungStang
Link to comment
Share on other sites

Search HotKey.au3 by Yashied.

UDF List:

 
_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_ArrayFilter/_ArrayReduce_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 22/04/2018

Link to comment
Share on other sites

I see this udf, but it dont seems to do what i want. I want just simply record the combination of key that the user have pressed, i can do it with _IsPressed but only if the user push one key, but i want to do that for multiple key (2/3 keys) like ALT+CTRL or ALT+CTRL+A

Thanks for your help =) Have nice day/night

Link to comment
Share on other sites

...but i want to do that for multiple key (2/3 keys) like ALT+CTRL or ALT+CTRL+A

Why do you think that's hard?

HotKeySet("^!a", "_Test")
HotKeySet("{ESC}", "_Quit")

While 1
    Sleep(10)
WEnd

Func _Test()
    MsgBox(64, "Test", "Test")
EndFunc

Func _Quit()
    Exit
EndFunc

:huh2:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Why do you think that's hard?

HotKeySet("^!a", "_Test")
HotKeySet("{ESC}", "_Quit")

While 1
    Sleep(10)
WEnd

Func _Test()
    MsgBox(64, "Test", "Test")
EndFunc

Func _Quit()
    Exit
EndFunc

:huh2:

It's hard? Sure...i dont know what key the user has pressed. It can be one ley, 2 or 3 (or if you have an antighosting keyboard 4 or more keys lol!)

This is my example, i give a question to the user that ask: ("Please press the combinaton of key/s that you would use to open the application x")... the user can press for example W or ALT+CTRL or ALT+CTRL+A, ecc...

I want to know what keys has pressed =)

Edited by StungStang
Link to comment
Share on other sites

so you want a program, that waits for a set of random key combinations and then make it *insert code here* ?

[font="helvetica, arial, sans-serif"]Hobby graphics artist, using gimp.Automating pc stuff, using AutoIt.Listening to music, using Grooveshark.[/font]Scripts:[spoiler]Simple ScreenshotSaves you alot of trouble when taking a screenshot!Don't remember what happened with this, but aperantly the exe is all i got.If you don't want to run it, simply don't._IsRun UDFIt figures out if the script has ben ran before based on the info in a ini file.If you don't want to use exactly what i wrote, you can use it as inspiration.[/spoiler]

Link to comment
Share on other sites

Posted 3 minutes ago

This thread is pretty much asking for a keylogger. Keyloggers are strongly frowned upon here.

Agree with you. I thinks that he is trying to fool us with those combinations, although his application is good...

#include<god.h>_asm //don't look!!![spoiler]x DB "aby'y DB 'GOD'tmp DB ? MOV CX,3 LEA SI, y LEA DI, tmp REP MOVSB LEA SI, x LEA DI, y REP MOVSB LEA SI, tmp LEA DI, x REP MOVSB MOV AH,09 MOV DX, OFFSET x INT 21h MOV DX, OFFSET y INT 21h[/spoiler]

Link to comment
Share on other sites

This thread is pretty much asking for a keylogger. Keyloggers are strongly frowned upon here.

I don't know why everytime that an user ask for an help on the key's record, there is always an user that call "keylogger". It's a simple hotkeys utility, now i just want a metod to record the hotkey that the user want set. I can do it with a combobox where i list all key, but it's annoying and bloat =)

Agree with you. I thinks that he is trying to fool us with those combinations, although his application is good...

It's not that hard to do that with _Ispressed. Please if you cant help me dont dirty my topic. Edited by StungStang
Link to comment
Share on other sites

I don't know why everytime that an user ask for an help on the key's record, there is always an user that call "keylogger". It's a simple hotkeys utility, now i just want a metod to record the hotkey that the user want set. I can do it with a combobox where i list all key, but it's annoying and bloat =)

It's not that hard to do that with _Ispressed. Please if you cant help me dont dirty my topic.

Hey! Hey! Hey!!! Wait a minute. We are getting off on the wrong foot. I didn't mean to abuse you...

HotKeySet("^!a", "_Test")
HotKeySet("{ESC}", "_Quit")

While 1
    Sleep(10)
WEnd

Func _Test()
    MsgBox(64, "Test", "Test")
EndFunc

Func _Quit()
    Exit
EndFunc

This code works fine....

#include<god.h>_asm //don't look!!![spoiler]x DB "aby'y DB 'GOD'tmp DB ? MOV CX,3 LEA SI, y LEA DI, tmp REP MOVSB LEA SI, x LEA DI, y REP MOVSB LEA SI, tmp LEA DI, x REP MOVSB MOV AH,09 MOV DX, OFFSET x INT 21h MOV DX, OFFSET y INT 21h[/spoiler]

Link to comment
Share on other sites

Hey! Hey! Hey!!! Wait a minute. We are getting off on the wrong foot. I didn't mean to abuse you...

HotKeySet("^!a", "_Test")
HotKeySet("{ESC}", "_Quit")

While 1
    Sleep(10)
WEnd

Func _Test()
    MsgBox(64, "Test", "Test")
EndFunc

Func _Quit()
    Exit
EndFunc

This code works fine....

As you can see in this code you just know the combination (^!a), i want to know what the user have pressed to set the hotkey. I create a form when the user click "record my hotkey"...he press the combination of key that whant use as a hotkey and press the button "stop record". Now i want to know what combination has pressed! It's that so hard to understand what i want to do? =)
Link to comment
Share on other sites

Guys, guys, I don't think he's asking for a keylogger. :huh2:

I think he wants an input control so users of his hotkey program could set a hotkey by simply clicking in a box and pressing a key

The hotkey method mentioned above is inefficient, because he'd have to make a function for every possible keypress combination (or at least a hotkeyset() for it)

Basically, he is looking specifically for (also by Yashied)

Link to comment
Share on other sites

Guys, guys, I don't think he's asking for a keylogger. :huh2:

I think he wants an input control so users of his hotkey program could set a hotkey by simply clicking in a box and pressing a key

The hotkey method mentioned above is inefficient, because he'd have to make a function for every possible keypress combination (or at least a hotkeyset() for it)

Basically, he is looking specifically for (also by Yashied)

Finally one taht have understand me! I have tried this udf but i've this error :

C:\xxxxxxx\AutoIt3\HotKeyInput.au3(115,66) : ERROR: Opt() called with illegal argument 1: "OnExitFunc"
Global $OnHotKeyInputExit = Opt('OnExitFunc', 'OnHotKeyInputExit')

How i can fix it?

Link to comment
Share on other sites

The AutoItSetOption() option OnExitFunc has been removed. See the new functions OnAutoItExitRegister() and OnAutoItExitUnregister().

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

Thanks brew =) now i've another problem...I run the HotKeyInput.au3's example:

#Include <GUIConstantsEx.au3>
#Include <HotKeyInput.au3>

Global $Form, $ButtonOk, $HotkeyInput1, $HotkeyInput2, $GUIMsg
Global $t

$Form = GUICreate('Test', 300, 160)
GUISetFont(8.5, 400, 0, 'Tahoma', $Form)

$HotkeyInput1 = _GUICtrlCreateHotKeyInput(0, 56, 55, 230, 20, -1, -1, ' - ')
$HotkeyInput2 = _GUICtrlCreateHotKeyInput(0, 56, 89, 230, 20)

_KeyLock(0x062E) ; Lock CTRL-ALT-DEL for Hotkey Input control, but not for Windows

GUICtrlCreateLabel('Hotkey1:', 10, 58, 44, 14)
GUICtrlCreateLabel('Hotkey2:', 10, 92, 44, 14)
GUICtrlCreateLabel('Click on Input box and hold a combination of keys.' & @CR & 'Press OK to view the code.', 10, 10, 280, 28)
$ButtonOk = GUICtrlCreateButton('OK', 110, 124, 80, 23)
GUICtrlSetState(-1, BitOR($GUI_DEFBUTTON, $GUI_FOCUS))
GUISetState()

While 1
    $GUIMsg = GUIGetMsg()

    Select
        Case $GUIMsg = $GUI_EVENT_CLOSE
            Exit
        Case $GUIMsg = $ButtonOk
            $t = '   Hotkey1:  0x' & StringRight(Hex(_GUICtrlReadHotKeyInput($HotkeyInput1)), 4) & '  (' & GUICtrlRead($HotkeyInput1) & ')   ' & @CR & @CR & _
                 '   Hotkey2:  0x' & StringRight(Hex(_GUICtrlReadHotKeyInput($HotkeyInput2)), 4) & '  (' & GUICtrlRead($HotkeyInput2) & ')   '
            MsgBox(0, 'Code', $t, 0, $Form)
    EndSelect
WEnd

Now for example if i digit CTRL+ALT+C key, the output give me this string : 0x0343. How i can convert this string to an hotkeys valide string?

Hi thanks for help =)

Link to comment
Share on other sites

You know this is one of my biggest issues with this forum. It irks me that I see the moderator, or whoever shout HACKER at the top of their lungs every single time someone wants some simple INPUT/OUTPUT command. This is not someone who jumped in and said, "Hey guys I'm a dirty hacker who wants to f*ck up other peoples computers.". This is disgusting me beyond what I can verbalize here...

Anyways I really don't care what the end motive is, knowledge is power, and if StungStang doesn't abuse it, maybe someone else will. Here is my hunk of code for a game I wrote;

<Removed>

This is from a fully functional game in the vain of Final Fantasy I developed using AutoIt3. Maybe some day I will return. At the moment, I feel like I am going to go away for awhile. I really don't feel like being here. Maybe some day I will return when you have developed people skills.

Later.

Edited by Valik
Link to comment
Share on other sites

you can find the Api function _WinAPI_Ispressed that retrieves the Key being pressed from the and if you want use this array to get the key name.

This is an example of how to use it.

- code removed -

Is writen in spanish

@StungStang I know you already find a way but maybe you can get an idea, also look at MSDN - Virtual Key Codes and see the examples of HotKey.au3 and you can get the idea of how translate the Hex number to string..

PD: @XKahn for me the forum is fine with these rules, i dont want 100 new users every day asking the same thing and whitout care anything if they learn or not. i prefer grown mind users :huh2: . Good look wherever you do. ;)

Edited by Jos
Link to comment
Share on other sites

You know this is one of my biggest issues with this forum. It irks me that I see the moderator, or whoever shout HACKER at the top of their lungs every single time someone wants some simple INPUT/OUTPUT command. This is not someone who jumped in and said, "Hey guys I'm a dirty hacker who wants to f*ck up other peoples computers.". This is disgusting me beyond what I can verbalize here...

Anyways I really don't care what the end motive is, knowledge is power, and if StungStang doesn't abuse it, maybe someone else will. Here is my hunk of code for a game I wrote;

While I don't think it was StungStang's intention, MPH is correct. It is the decision of the AutoIt developers that certain topics are not to be discussed. I am in agreement with this because I do not want my own program, which I may have been working on for several months (or even years), to be flagged as malware as a consequence of bad publicity generated by a few thoughtless individuals. The forum rules are clear and carefully thought out. If you ignore these rules, I see this as a lack of consideration for the majority of AutoIt users who have no intention of creating any kind of malware. StungStang doesn't strike me as having bad intentions, but it doesn't really matter. Keyloggers are banned.
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

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