Allenhu Posted March 30, 2023 Posted March 30, 2023 Below is my code: #RequireAdmin Run (@ScriptDir & '\UrlDisabler.exe') AutoItSetOption( 'MouseCoordMode', 0) WinWait('URL Disabler v1.2') WinActivate('URL Disabler v1.2') sleep(500) MouseClick('primary',361, 440, 1, 0) ControlClick('[CLASS:#32768]', '',109, 'Block URLs') I just want click 'Block URLs' automatically,hope some master can help me,thanks so much.
mistersquirrle Posted March 30, 2023 Posted March 30, 2023 Most likely your ControlClick isn't matching what you think it is. Can't see it in what's shown with your Window Info, but there likely isn't text to match on "Block URLs". Also your ControlClick syntax is wrong, check it out: https://www.autoitscript.com/autoit3/docs/functions/ControlClick.htm It should be: ControlClick('[CLASS:#32768]', 'Block URLs', '', 'Main') Though I don't think that you even want 'Block URLs' in there, so try it without that. Also if ControlClick doesn't work, just stick with MouseClick. There may also be a better option, such as, are you able to change settings through the menu bar under Options? You might be able to use Send or ControlSend to send Alt + O (or whatever key is highlighted while holding alt for "Options") and then send arrow or more alt + letters to choose options through that menu. Might also be worth seeing if there's command line options, or another way to interact with it. We ought not to misbehave, but we should look as though we could.
Nine Posted March 30, 2023 Posted March 30, 2023 Please when you post code, use the indicated method. As per your request, here the proper way to click on a context menu : #include <WindowsConstants.au3> #include <GuiMenu.au3> #include <SendMessage.au3> #include <Array.au3> MouseClick("right", 200, 200) ; this is for test only Sleep(500) ClickMenu("Undo") ; <<<<<<<<<<<<< put here the menu item you want to click on If @error Then MsgBox($MB_SYSTEMMODAL, "", "Unable to find menu item") Func ClickMenu($sMenu) Local $hWnd = WinGetHandle("[CLASS:#32768]") If Not $hWnd Then Exit MsgBox($MB_SYSTEMMODAL, "", "Unable to get context window handle") Local $hMenu = _SendMessage($hWnd, $MN_GETHMENU) If Not _GUICtrlMenu_IsMenu($hMenu) Then Exit MsgBox($MB_SYSTEMMODAL, "", "Unable to retrieve context menu handle") Local $aRect For $i = 0 To _GUICtrlMenu_GetItemCount($hMenu) - 1 If _GUICtrlMenu_GetItemText($hMenu, $i) = $sMenu Then $aRect = _GUICtrlMenu_GetItemRect($hWnd, $hMenu, $i) MouseClick("left", $aRect[0] + 10, $aRect[1]+ 5, 1) Return EndIf Next Return SetError(1) EndFunc ;==>ClickMenu “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy
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