Jump to content

Recommended Posts

Posted

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.

0330.png

Posted

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.

Posted

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

 

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