Jump to content

Recommended Posts

Posted (edited)

Good day,

I require a means of responding to the selection of the [Enter] key - wherein a MouseClick operation is then executed.

I have the following sampling and am wondering if there might be:

a) a more "elegant" means of executing this operation ...or...
b) a more "simplified" means of executing this operation...

Here is the sampling...

; -----------------------------------------------------------
#include <AutoItConstants.au3>
#include <Misc.au3>
; -----------------------------------------------------------
GetKeyPress()
; -----------------------------------------------------------
Func GetKeyPress()
    Local $hDLL = DllOpen("user32.dll")
    ; -----------------------------------------------------------
    While 1
        If _IsPressed("0D", $hDLL) Then
            While _IsPressed("0D", $hDLL)
                Sleep(250)
            WEnd
            MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0)
            ExitLoop
        EndIf
        Sleep(250)
    WEnd
    ; -----------------------------------------------------------
    DllClose($hDLL)
EndFunc   ;==>GetKeyPress
; -----------------------------------------------------------

As always...any assistance in this matter would be greatly appreciated!

Thank you all for your time!

 

Edited by mr-es335
typo
Posted

You pretty much got what we are allowed to discuss on that subject, going deeper would be against forum rules as it's not allowed to discuss keylogging or keypresses other than a few simple _IsPressed() which you already got.

Some guy's script + some other guy's script = my script!

Posted
2 hours ago, mr-es335 said:

I require a means of responding to the selection selecting of the [Enter] key

#include <GUIConstantsEx.au3>
#include <MsgBoxConstants.au3>

Example()

Func Example()
        GUICreate("Custom MsgBox", 225, 80)

        GUICtrlCreateLabel("Please select a button.", 10, 10)
        Local $idButton_Yes = GUICtrlCreateButton("Yes", 10, 50, 65, 25)
        Local $idButton_No = GUICtrlCreateButton("No", 80, 50, 65, 25)
        Local $idButton_Exit = GUICtrlCreateButton("Exit", 150, 50, 65, 25)

        ; Set GUIAccelerators for the button controlIDs, these being Ctrl + y and Ctrl + n
        Local $aAccelKeys[2][2] = [["^y", $idButton_Yes], ["^n", $idButton_No]]
        GUISetAccelerators($aAccelKeys)

        GUISetState(@SW_SHOW) ; Display the GUI.

        While 1
                Switch GUIGetMsg()
                        Case $GUI_EVENT_CLOSE
                                MsgBox($MB_SYSTEMMODAL, "You selected", "Close")
                                ExitLoop

                        Case $idButton_Yes
                                MsgBox($MB_SYSTEMMODAL, "You selected", "Yes") ; Displays if the button was selected or the hotkey combination Ctrl + y was pressed.

                        Case $idButton_No
                                MsgBox($MB_SYSTEMMODAL, "You selected", "No") ; Displays if the button was selected or the hotkey combination Ctrl + n was pressed.

                        Case $idButton_Exit
                                MsgBox($MB_SYSTEMMODAL, "You selected", "Exit")
                                ExitLoop

                EndSwitch
        WEnd
        GUIDelete() ; Delete the GUI.
EndFunc   ;==>Example

..is in the help file.

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Posted (edited)

:unsure:

#include <AutoItConstants.au3>

HotKeySet("{ENTER}", "MouseClickAction")

While 1
    Sleep(100)
WEnd

Func MouseClickAction()
    HotKeySet("{ENTER}")
    MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0)
    Sleep(100)
    HotKeySet("{ENTER}", "MouseClickAction")
EndFunc


If you want to leave after clicking

#include <AutoItConstants.au3>

HotKeySet("{ENTER}", "MouseClickAction")
Global $bActive = True
While $bActive
    Sleep(100)
WEnd

Func MouseClickAction()
    HotKeySet("{ENTER}")
    MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0)
    $bActive = False
EndFunc

 

Edited by ioa747

I know that I know nothing

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...