Outlook COM - Enable or disable add-ins Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Outlook COM - Enable or disable add-ins

18 Nov 2016, 12:25

This topic is created on behalf of another user who asked:
Hi , I saw your input here:
https://autohotkey.com/board/topic/7133 ... ntry730111

your code will show me the add-ins installed on my outlook , my question is: is there anyway to disable one of them?
If we convert your code to GUI, will it be possible to add like Button to disable one of the add-ins in my list?

Any help will be appreciated.
Thank you
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Outlook COM - Enable or disable add-ins

18 Nov 2016, 12:26

COMAddIn Object wrote:Use the Connect property to set or return the state of the connection to a specified COM add-in.
This is untested. It should be possible to run this from a GUI g-label.

Code: Select all

; **Probably needs to be run as admin** (untested)

olApp := ComObjActive("Outlook.Application")
for COMAddIn, in olApp.COMAddIns
{
    MsgBox, % COMAddIn.Creator "`n"
        . COMAddIn.Description "`n"
        . COMAddIn.Guid "`n"
        . COMAddIn.ProgId "`n"
        . COMAddIn.Connect  ; Dispay add-in state
    
    if (COMAddIn.Guid = "{F37AFD4F-E736-4980-8650-A486B1F2DF25}")  ; GUID for Windows Search Email Indexer add-in
        COMAddIn.Connect := -1  ; 0 for false, -1 for true
    
    MsgBox, % COMAddIn.Creator "`n" 
        . COMAddIn.Description "`n"
        . COMAddIn.Guid "`n"
        . COMAddIn.ProgId "`n"
        . COMAddIn.Connect  ; Dispay add-in state
}
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Outlook COM - Enable or disable add-ins

18 Nov 2016, 15:23

Hi Kon,
Thank you for your response.

Unfortunately it doesn't work for me, I did add all your code in g-label,
I don't know why I cannot upload images in the forum, anyway, the error is on line:
COMAddIn.Connect := -1
Error: 0x80004004 - Operation aborted

I used to run commands, and functions when click, or to delete, but i have zero knowledge in COM stuff :) Can you please help me more to add GUI and how to chose what add-in to disable in that GUI?
appreciate your time.
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Outlook COM - Enable or disable add-ins

18 Nov 2016, 15:29

Or, if it is easier , just to disable one certain add-in , i know its name and the dll file

Thank you
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Outlook COM - Enable or disable add-ins  Topic is solved

18 Nov 2016, 15:40

Not sure why you get that error.
I don't have access to Outlook on an admin account so I can't test at the moment.

Code: Select all

; **Probably needs to be run as admin** (untested)

Gui, Add, ListView, vLV1 w800 h300, Connected|Description|ProgId|GUID
Gui, Add, Button, vB1 gToggleSelected w80, Toggle
Gui, Show
Refresh()
return

GuiClose() {
    ExitApp
}

OutlookConnect() {
    try olApp := ComObjActive("Outlook.Application")
    catch
        throw Exception("Unable to connect to Outlook.")
    return olApp
}

Refresh() {
    LV_Delete()  ; Clear the listview
    for COMAddIn, in OutlookConnect().COMAddIns
        LV_Add(""
            , (COMAddIn.Connect = -1 ? "En" : "Dis") "abled"
            ,  COMAddIn.Description
            ,  COMAddIn.ProgId
            ,  COMAddIn.Guid)
    LV_ModifyCol()  ; Auto-size each column to fit its contents.
}

ToggleSelected() {
    static ColumnNumber := 3
    olApp := OutlookConnect()
    RowNumber := 0  ; This causes the first loop iteration to start the search at the top of the list.
    Loop {  ; Get each selected row in the listview
        RowNumber := LV_GetNext(RowNumber)  ; Resume the search at the row after that found by the previous iteration.
        if !RowNumber  ; The above returned zero, so there are no more selected rows.
            break
        if LV_GetText(ProgId, RowNumber, ColumnNumber) {
            COMAddIn := olApp.COMAddIns.Item[ProgId]
            COMAddIn.Connect := COMAddIn.Connect = -1 ? 0 : -1
        }
    }
    Refresh()
}

Last edited by kon on 18 Nov 2016, 16:03, edited 1 time in total.
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Outlook COM - Enable or disable add-ins

18 Nov 2016, 15:51

Great !! You are so fast! :)
But, it enables the selected add-in but it doesn't disable it :)
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Outlook COM - Enable or disable add-ins

18 Nov 2016, 16:03

There was a typo in my post above. Can you try it again?
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Outlook COM - Enable or disable add-ins

18 Nov 2016, 17:08

Oh man!
You saved me hours, even days of work!!
Thanks a lot Kon! Thank you!

you can mark your answer as the best answer :)
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Outlook COM - Enable or disable add-ins

21 Nov 2016, 12:51

Hi again :)
I think what I will ask for is a lot easier since we have a ready one, but i cannot figure it out by my self since i know nothing regarding COM and these stuff.
Is there a way to make it looks only for one add-in?

let's say (from your script)
Description: Maxhire
ProgId: MHOLAddin.clsOutlookInt

Is it possible to make the script looks ONLY for Maxhire, and disable it if it's enabled?
If it's already disabled then ExitApp

Thank you
Rami
Posts: 55
Joined: 19 May 2016, 07:44

Re: Outlook COM - Enable or disable add-ins

21 Nov 2016, 16:36

I mean, the script does its job by disabling Maxhire just by double click on it, but check at the beggining if Maxhire is disabled the script will exit
Last edited by Rami on 21 Nov 2016, 16:45, edited 1 time in total.
kon
Posts: 1756
Joined: 29 Sep 2013, 17:11

Re: Outlook COM - Enable or disable add-ins

21 Nov 2016, 16:44

Code: Select all

COMAddIn := ComObjActive("Outlook.Application").COMAddIns.Item["MHOLAddin.clsOutlookInt"]
if (COMAddIn.Connect = -1)
    COMAddIn.Connect := 0

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 300 guests