mr-es335 Posted 5 hours ago Posted 5 hours ago (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 35 minutes ago by mr-es335 typo mr-es335 Sentinel Music Studios
Werty Posted 3 hours ago Posted 3 hours ago 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!
argumentum Posted 2 hours ago Posted 2 hours ago 2 hours ago, mr-es335 said: I require a means of responding to the selection selecting of the [Enter] key expandcollapse popup#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. mr-es335 1 Follow the link to my code contribution ( and other things too ). FAQ - Please Read Before Posting.
ioa747 Posted 1 hour ago Posted 1 hour ago (edited) #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 1 hour ago by ioa747 mr-es335 1 I know that I know nothing
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