Gaffgarion Posted December 15, 2017 Share Posted December 15, 2017 Hi! Started with AutoIt just some hours ago so please be gentle with me. so my keyboard "e" button is broken, but i dont want to buy a new keyboard yet, so after some thinking and browsing i decided to use autoit to fix my problem just for some time until i buy a new keyboard and i also want to take this chance to learn about autoit. my idea is to use keys combination to send the "e" button. so i want the script to function like this : if i hold "q" button, and then press "w" button, the output will be "e" button. i've tried it myself using example from this forum, but i got "error:unable to parse line". #include <Misc.au3> $dll = DllOpen("user32.dll") While 1 If _IsPressed ("qw") Then Send("{a}") EndIf WEnd DllClose($dll) hopefuly someone can give me a direction for this, thank you! Link to comment Share on other sites More sharing options...
Earthshine Posted December 15, 2017 Share Posted December 15, 2017 have a look at this thread. map e to your scrollock or whatever you don't use maybe? My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted December 15, 2017 Moderators Share Posted December 15, 2017 @Gaffgarion Welcome to the forum. First off, please re-read the _IsPressed section in the help file. You will see that you need to enter the value for the key, not the key itself (e.g. '51' not 'q'). Now, regarding your issue, there are a couple of ways to go about this. There is a UDF out there that you can use to set multiple hotkeys, you can find that here: Alternatively, I like this little function written by Melba. In essence it uses HotKeySet on both keys and points them to the same function, then checks to see if both are pressed before sending the 'e' key. ;All credit to Melba23 #include <Misc.au3> HotKeySet("q", "_Q1") HotKeySet("w", "_Q1") While 1 Sleep(10) WEnd Func _Q1() ; Unset HotKeys to prevent possible double hit HotKeySet("q") HotKeySet("w") ; Are both keys pressed? $iBegin = TimerInit() Do If _IsPressed("51") And _IsPressed("57") Then Send("e", 1) Until TimerDiff($iBegin) > 100 ; Reset HotKeys HotKeySet("q", "_Q1") HotKeySet("w", "_Q1") EndFunc Keep in mind, as the Remarks section of _IsPressed explain, even a brief press of the key combo can result in multiple presses of your output key, so you may get 'eeeee' Earthshine 1 "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
careca Posted December 15, 2017 Share Posted December 15, 2017 (edited) You were close, it's just the way you call it If _IsPressed("28") And _IsPressed("DC") Then Most complete answer from JLogan. Edited December 15, 2017 by careca Spoiler Renamer - Rename files and folders, remove portions of text from the filename etc. GPO Tool - Export/Import Group policy settings. MirrorDir - Synchronize/Backup/Mirror Folders BeatsPlayer - Music player. Params Tool - Right click an exe to see it's parameters or execute them. String Trigger - Triggers pasting text or applications or internet links on specific strings. Inconspicuous - Hide files in plain sight, not fully encrypted. Regedit Control - Registry browsing history, quickly jump into any saved key. Time4Shutdown - Write the time for shutdown in minutes. Power Profiles Tool - Set a profile as active, delete, duplicate, export and import. Finished Task Shutdown - Shuts down pc when specified window/Wndl/process closes. NetworkSpeedShutdown - Shuts down pc if download speed goes under "X" Kb/s. IUIAutomation - Topic with framework and examples Au3Record.exe Link to comment Share on other sites More sharing options...
Gaffgarion Posted May 28, 2018 Author Share Posted May 28, 2018 (edited) On 12/15/2017 at 9:00 PM, JLogan3o13 said: even a brief press of the key combo can result in multiple presses of your output key, so you may get 'eeeee' yes, its hard to use that script, because i only press both keys in just a brief moment and the output is like 'eeeeee' i want it if i hold down Q key and then press W key 1x, the output is E key 1x, not multiple E key i also found this by melba23 #include <Misc.au3> Local $hDLL = DllOpen("user32.dll") HotKeySet("{q}","_Start") ; Fire HotKey on Q key HotKeySet("{ESC}", "_Exit") While 1 Sleep(10) WEnd Func _Start () ; Look for W key If _IsPressed("57", $hDLL) Then ; Only action if BOTH pressed Send("e") EndIf EndFunc Func _Exit() DllClose($hDLL) Exit EndFunc this works perfectly, but its the opposite of what i want, for this one, i have to hold down W key first, and then press Q key. what i needed is, hold down Q key first and then W key. thanks Edited May 28, 2018 by Gaffgarion Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 28, 2018 Moderators Share Posted May 28, 2018 So look in the help file for the values of the keys and swap them... "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now