Jump to content

Recommended Posts

 

 
#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


 

Link to post
Share on other sites

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.

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)



460px-Thief-4-temp-banner.jpg
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.

 
Link to post
Share on other sites
  • Moderators
6 hours ago, ashraful089 said:

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!

Link to post
Share on other sites

@Gianni@bogQ

#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  ?

Link to post
Share on other sites
#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 by Gianni

 

image.jpeg.9f1a974c98e9f77d824b358729b089b0.jpeg Chimp

small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Link to post
Share on other sites
;#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

 

Link to post
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...