AutoIt GUICtrlMenu Click Simulation: A Comprehensive Guide
GUICtrlMenu Click is not a valid AutoIt function. \r\n\r\nHowever, to simulate a click on a menu item in AutoIt, you can use the GUICtrlSendMsg function with the appropriate message and parameters.\r\n\r\nHere's an example code that clicks on a menu item with the index 1 in a GUI:\r\n\r\n\r\n#include <GUIConstantsEx.au3>\r\n#include <WindowsConstants.au3>\r\n\r\nGlobal $hGUI, $hMenu\r\n\r\n$hGUI = GUICreate("AutoIt Menu Example", 300, 200)\r\n$hMenu = GUICtrlCreateMenu("File")\r\nGUICtrlCreateMenuItem("Open", $hMenu)\r\nGUICtrlCreateMenuItem("Save", $hMenu)\r\nGUICtrlCreateMenuItem("", $hMenu)\r\nGUICtrlCreateMenuItem("Exit", $hMenu)\r\nGUISetState(@SW_SHOW)\r\n\r\n; Simulate click on the first menu item\r\nGUICtrlSendMsg($hMenu, $WM_COMMAND, GUICtrlGetHandle($hMenu) + 1, 0)\r\n\r\nWhile 1\r\n Switch GUIGetMsg()\r\n Case $GUI_EVENT_CLOSE\r\n Exit\r\n EndSwitch\r\nWEnd\r\n\r\n\r\nIn the above code, the GUICtrlSendMsg function is used to send a message to the menu control. The message is $WM_COMMAND, which represents a command message. The parameters for the message are the handle of the menu control and the identifier of the menu item to click. In this case, the identifier is obtained by adding 1 to the handle of the menu control.
原文地址: https://www.cveoy.top/t/topic/qib2 著作权归作者所有。请勿转载和采集!