Sign in to follow this  
Followers 0
MattHiggs

(solved) Use of ControlCommand

8 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



#2 ·  Posted

Are the questions that I ask really that complicated that no one knows the answer or too stupid that no one bothers with an answer?

Share this post


Link to post
Share on other sites

#3 ·  Posted

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?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#5 ·  Posted

Can you show us your Programmatic Access settings, which are found under Options > Trust Center > Trust Center Settings > Programmatic Access?

1 person likes this

Share this post


Link to post
Share on other sites

#8 ·  Posted

Glad the solution (albeit non-AutoIT) is working for you. ;-)

Share this post


Link to post
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
Sign in to follow this  
Followers 0