Jump to content

(solved) Use of ControlCommand


Recommended Posts

Hello autoit scripters,

So I am trying to write an autoit script which will help deal with the annoyance that manifests as the below window whenever I begin a new message in outlook.  I want the script to automatically check the checkbox, select the last value in the combo box which will be enabled when the checkbox is selected, and click allow button when the window pops up.  I figured it would be a pretty simple task, but I am having issues with the combo box selection.  I am trying to use the ControlCommand function to manipulate the combo box selection, but it simply doesn't do anything.  I have even used the controlcommand function to force the script to wait until the combo box's state is "enabled" before attempting to manipulate it, and even forced the script to wait a full 5 seconds after the check box is selected (and the combo box enabled) to make sure it wasn't an issue with the script trying to manipulate a control that is disabled.  Below is the code I am using.  Can someone help me out here?

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=y
#AutoIt3Wrapper_Res_SaveSource=y
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=requireAdministrator
#AutoIt3Wrapper_Add_Constants=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------

 AutoIt Version: 3.3.15.0 (Beta)
 Author:         myName

 Script Function:
    Template AutoIt script.

#ce ----------------------------------------------------------------------------

; Script Start - Add your code below here
While 1
    Sleep ( 300 )
    If WinExists ( "Microsoft Outlook", "A program is trying to access email address information stored in Outlook. If this is unexpected, click Deny and verify your antivirus software is up-to-date." ) Then
        WinActivate ( "Microsoft Outlook", "A program is trying to access email address information stored in Outlook. If this is unexpected, click Deny and verify your antivirus software is up-to-date." )
        WinWaitActive ( "Microsoft Outlook", "A program is trying to access email address information stored in Outlook. If this is unexpected, click Deny and verify your antivirus software is up-to-date." )
        ControlClick ( "Microsoft Outlook", "&Allow access for", "[CLASS:Button; INSTANCE:3]" )
        Sleep ( 3000 )
        Do
            Sleep ( 20 )
        Until ControlCommand ( "Microsoft Outlook", "&Help", "[CLASS:ComboBox; INSTANCE:1]", "IsEnabled", "" ) = 1

        ControlCommand ( "Microsoft Outlook", "&Help", "[CLASS:ComboBox; INSTANCE:1]", "SelectString", '10 minutes' )
        Beep ( Default, 2000 )
        Sleep ( 3000 )
        ControlClick ( "Microsoft Outlook", "Allow", "[CLASS:Button; INSTANCE:4]" )
    EndIf
WEnd

 

TFAUJKf.png

Edited by MattHiggs
Link to comment
Share on other sites

29 minutes ago, Danp2 said:

No, I don't think either option applies here. This isn't a dialog that I see when using Outlook. It's possible that I disabled it way back when.

What version of Outlook are you using? Perhaps ControlCommand isn't the best option here. Have you considered using _GUICtrlComboBox_SetCurSel instead?

Thank you for your response.  So I use Office 2016, but I know why the dialog appears.  It is because I don't have any "real-time protection" anti-virus software installed on my computer, as, not only do I think anti-virus technology in of itself is useless, I am sick and tired of all of the anti-virus products that I have tried so far quarantining my scripts/files (files which I know are clean), forcing me to go into the settings and literally wrestle with the product for my files back.  Good judgement and Virus total are good enough for me, so I have no desire to install any anti-virus software.  Windows Defender would be a suitable alternative, if it didn't consume 20% of my processor resources at all times as well.....  So that is why the prompt is appearing.  Look, all I really want to know is if I am using "ControlCommand" correctly.....  As for your suggestion to use " _GUICtrlComboBox_SetCurSel ", I am pretty sure the GUI UDFs to which that function belongs is only applicable to performing actions on combo boxes in GUIs created from within an AutoIT script.  The reason I was using "controlCommand" is because it belongs to the "Windows functions" group, which is for automating actions on any process window.

Edited by MattHiggs
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...