mr-es335 Posted 13 hours ago Posted 13 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 8 hours ago by mr-es335 typo mr-es335 Sentinel Music Studios
Werty Posted 11 hours ago Posted 11 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 10 hours ago Posted 10 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 9 hours ago Posted 9 hours 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 9 hours ago by ioa747 mr-es335 1 I know that I know nothing
mr-es335 Posted 8 hours ago Author Posted 8 hours ago (edited) Good day... May I ask how to "integrate" your2nd offering "If you want to leave after clicking" into the following?: ; ----------------------------------------------- #include <AutoItConstants.au3> ; ----------------------------------------------- Global $iTimeOut = 100 Global $iX = 711, $iY = 80 ; For F12 ; ----------------------------------------------- UpdateScenesF12($iX, $iY) ; ----------------------------------------------- Func UpdateScenesF12($iX, $iY) ConsoleWrite("UpdateScenes(" & $iX & ", " & $iY & ")" & @CRLF) Local $hSAC_MAIN = "[CLASS:SAC_MAIN]" Local $hSAC_SCENES = "[CLASS:SAC_SCENES]" Local $hSAC_SCENEPROPERTIES = "[CLASS:SAC_SCENEPROPERTIES]" ; ----------------------------------------------- WinActivate($hSAC_MAIN) WinActivate($hSAC_SCENES) ; ----------------------------------------------- ; <<<<==== Script Intervention ====>>>> Send("{End}") ; Select [End Of List] ; ----------------------------------------------- Sleep($iTimeOut) MouseClick($MOUSE_CLICK_LEFT, 188, 118, 1, 0) ; Select [New], the [Enter Scene Name] dialog is displayed. ; ----------------------------------------------- Send("{CTRLDOWN}") Send("v") ; Enter Scene Name Send("{CTRLUP}") ; ---------------------- Send("{ENTER}") ; Select [Ok], the [Enter Scene Name] dialog is exited...and the [Scene Properties] dialog is displayed ; ----------------------------------------------- Sleep($iTimeOut) WinMove($hSAC_SCENEPROPERTIES, "", $iX, $iY) ; The [Scene Properties] dialog is repositioned ; ----------------------------------------------- Sleep($iTimeOut) MouseMove(1000, 550, 0) ; The mouse is positioned within the [Scene Properties] dialog EndFunc ;==>UpdateScenesF12 ; ----------------------------------------------- ...this is point where the [Enter] key is invoked and the MouseClick occurs... PS: I have been able to do so, with my offering, but NOT with the 2nd offering!?!... Edited 8 hours ago by mr-es335 mr-es335 Sentinel Music Studios
ioa747 Posted 7 hours ago Posted 7 hours ago You don't seem to call GetKeyPress anywhere How do I understand at what point you want it? Why don't you just put MouseClick($MOUSE_CLICK_LEFT, 134, 163, 2, 0) and do it with enter? I know that I know nothing
Trong Posted 1 hour ago Posted 1 hour ago You may not need to use _IsPressed(): expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> ; === Create GUI === Global $hGUI = GUICreate("Demo GUI - Handle Enter (WM_COMMAND)", 400, 200) Global $lblName = GUICtrlCreateLabel("Enter your name:", 30, 30, 150, 20) Global $inpName = GUICtrlCreateInput("", 180, 28, 150, 20) Global $btnOK = GUICtrlCreateButton("OK", 50, 100, 80, 30) Global $btnCancel = GUICtrlCreateButton("Cancel", 160, 100, 80, 30) Global $btnAbout = GUICtrlCreateButton("About", 270, 100, 80, 30) GUISetState(@SW_SHOW, $hGUI) ; === Register Windows message handler for WM_COMMAND === GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") ; === Main loop === While True Local $nMsg = GUIGetMsg() Switch $nMsg ;~ Case $btnOK ;This is not necessary! ;~ Action_OK() ;~ Case $btnCancel;This is not necessary! ;~ Action_Cancel() ;~ Case $btnAbout;This is not necessary! ;~ Action_About() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGUI) Exit ; ========================================================= ; === WM_COMMAND message handler === ; ========================================================= Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $lParam Local $nCtrlID = BitAND($wParam, 0xFFFF) Local $nCode = BitShift($wParam, 16) ; Handle Enter key press (BN_CLICKED / EN_CHANGE etc.) If $nCode = 0 Then Switch $nCtrlID Case $inpName Action_Input() Case $btnOK Action_OK() Case $btnCancel Action_Cancel() Case $btnAbout Action_About() EndSwitch EndIf Return $GUI_RUNDEFMSG EndFunc ; ========================================================= ; === Action Functions === ; ========================================================= Func Action_Input() Local $sText = StringStripWS(GUICtrlRead($inpName), 3) If $sText = "" Then MsgBox($MB_ICONWARNING, "Warning", "Please enter your name!") GUICtrlSetState($inpName, $GUI_FOCUS) Return EndIf MsgBox($MB_ICONINFORMATION, "Hello", "Hello, " & $sText & "!") EndFunc Func Action_OK() MsgBox($MB_ICONINFORMATION, "OK", "You pressed the OK button or hit Enter on it.") EndFunc Func Action_Cancel() MsgBox($MB_ICONINFORMATION, "Cancel", "You pressed the Cancel button or hit Enter on it.") EndFunc Func Action_About() MsgBox($MB_ICONINFORMATION, "About", "Demo GUI AutoIt") EndFunc Enjoy my work? Buy me a 🍻 or tip via ❤️ PayPal
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