ashraful089 Posted August 22, 2022 Posted August 22, 2022 #include <Misc.au3> #include <MsgBoxConstants.au3> Local $hDLL = DllOpen("user32.dll") While 1 If _IsPressed("10", $hDLL) Then ConsoleWrite("_IsPressed - Shift Key was pressed." & @CRLF) ; Wait until key is released. While _IsPressed("10", $hDLL) Sleep(250) WEnd ConsoleWrite("_IsPressed - Shift Key was released." & @CRLF) ElseIf _IsPressed("1B", $hDLL) Then MsgBox($MB_SYSTEMMODAL, "_IsPressed", "The Esc Key was pressed, therefore we will close the application.") ExitLoop EndIf Sleep(250) WEnd DllClose($hDLL) Without code _IsPressed("52", $hDLL) is it possible to detect key press using normal write _IsPressed("R", $hDLL) ? https://www.autoitscript.com/autoit3/docs/libfunctions/_IsPressed.htm
bogQ Posted August 22, 2022 Posted August 22, 2022 Do not think so, because you cannot translate string for eg. (Shift Key was pressed) or for numpad. You can somewhat use _StringToHex as _IsPressed(_StringToHex("R"), $hDLL) with usage of capital letters. On the other hand you can try to make your own function for key to letter translation/mapping and use it instead. ashraful089 1 TCP server and client - Learning about TCP servers and clients connectionAu3 oIrrlicht - Irrlicht projectAu3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related) There are those that believe that the perfect heist lies in the preparation.Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.
Gianni Posted August 22, 2022 Posted August 22, 2022 ... or _IsPressed(Hex(Asc("R"), 2), $hDLL) as well ... ashraful089 and Zedna 2 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
Moderators JLogan3o13 Posted August 22, 2022 Moderators Posted August 22, 2022 6 hours ago, ashraful089 said: Without code _IsPressed("52", $hDLL) is it possible to detect key press using normal write _IsPressed("R", $hDLL) ? We get these kinds of "how do I create a MsgBox without using MsgBox" questions a lot. My first question is always why you need do avoid doing things the best practice way? "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!
ashraful089 Posted August 23, 2022 Author Posted August 23, 2022 @JLogan3o13sir, for hex code i have to remember or check hex to ascii list. so i think if i can use ascii character it will be easy for me to check which key i assigned as hotkey.
ashraful089 Posted August 23, 2022 Author Posted August 23, 2022 I tried this but not working, have i done any mistake
ashraful089 Posted August 23, 2022 Author Posted August 23, 2022 @Gianni@bogQ expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.0U Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <misc.au3> #include <AutoItConstants.au3> ;#include "ImageSearch.au3" AutoItSetOption('MouseCoordMode', 0) Global $hDLL While 1 ;($m = 0) ;sleep(100) ;If _IsPressed("52") Then ;R If _IsPressed(Hex(Asc("R"), 2), $hDLL) Then ;if _IsPressed(_StringToHex("R"), $hDLL) Then MsgBox($MB_SYSTEMMODAL, "", "currently running R", 1) ;Sleep($Sleep_Sec) ElseIf _IsPressed("54") Then ;T MsgBox($MB_SYSTEMMODAL, "", "currently running T", 1) ;Sleep($Sleep_Sec) ElseIf _IsPressed("55") Then ;U MsgBox($MB_SYSTEMMODAL, "", "currently running U", 1) ;Sleep($Sleep_Sec) Else Sleep(10) EndIf WEnd I tried this but not working, have i done any mistake ?
Gianni Posted August 23, 2022 Posted August 23, 2022 (edited) expandcollapse popup#cs ---------------------------------------------------------------------------- AutoIt Version: 3.3.16.0U Author: myName Script Function: Template AutoIt script. #ce ---------------------------------------------------------------------------- ; Script Start - Add your code below here #include <GUIConstantsEx.au3> #include <ButtonConstants.au3> #include <MsgBoxConstants.au3> #include <misc.au3> #include <AutoItConstants.au3> ;#include "ImageSearch.au3" AutoItSetOption('MouseCoordMode', 0) ; Global $hDLL Global $hDLL = DllOpen("user32.dll") ; <-- you missed this While 1 ;($m = 0) ;sleep(100) ;If _IsPressed("52") Then ;R If _IsPressed(Hex(Asc("R"), 2), $hDLL) Then ;if _IsPressed(_StringToHex("R"), $hDLL) Then MsgBox($MB_SYSTEMMODAL, "", "currently running R", 1) ;Sleep($Sleep_Sec) ElseIf _IsPressed("54", $hDLL) Then ;T MsgBox($MB_SYSTEMMODAL, "", "currently running T", 1) ;Sleep($Sleep_Sec) ElseIf _IsPressed("55", $hDLLr) Then ;U MsgBox($MB_SYSTEMMODAL, "", "currently running U", 1) ;Sleep($Sleep_Sec) Else Sleep(10) EndIf WEnd Edited August 23, 2022 by Gianni Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
ashraful089 Posted August 23, 2022 Author Posted August 23, 2022 ;#include <GUIConstantsEx.au3> ;#include <ButtonConstants.au3> ;#include <MsgBoxConstants.au3> #include <misc.au3> #include <AutoItConstants.au3> ;#include "ImageSearch.au3" AutoItSetOption('MouseCoordMode', 0) ; Global $hDLL Global $hDLL = DllOpen("user32.dll") ; <-- you missed this While 1 ;($m = 0) ;sleep(100) ;If _IsPressed("52") Then ;R If _IsPressed(Hex(Asc("R"), 2), $hDLL) Then MsgBox($MB_SYSTEMMODAL, "", "currently running R", 1) ElseIf _IsPressed("54", $hDLL) Then ;T MsgBox($MB_SYSTEMMODAL, "", "currently running T", 1) ElseIf _IsPressed("55", $hDLL) Then ;U MsgBox($MB_SYSTEMMODAL, "", "currently running U", 1) Else Sleep(10) EndIf WEnd Many many Thanks @Gianni its working now
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