[Ex] Utiliser plusieurs profils Outlook simultanément

Partagez vos scripts, et vos applications AutoIt.
Règles du forum
.
Répondre
Avatar du membre
jguinch
Modérateur
Modérateur
Messages : 2511
Enregistré le : lun. 14 févr. 2011 22:12
Status : Hors ligne

[Ex] Utiliser plusieurs profils Outlook simultanément

#1

Message par jguinch »

Bonjour.

Voici un utilitaire qui permet, grâce à à l'utilisation d'un programme externe, d'ouvrir plusieurs profils Outlook simultanément (on choisit dans la liste le profil qu'on veut utiliser).

Le programme externe à télécharger s'appelle ExtraOutlook, mais il ne s'utilise qu'en ligne de commande (mon utilitaire apporte donc l'interface graphique)
Plus d'infos sur ExtraOutlook ici : http://www.makeuseof.com/tag/open-two-d ... raoutlook/


Code : Tout sélectionner

#NoTrayIcon
Break(0)

#Include <Array.au3>
#include <GUIConstantsEx.au3>

Dim $profList[1]

$outlookPath = @ScriptDir & "\outlook.exe"

; Vérification que Outlook.exe est bien présent dans le même dossier
If NOT FileExists( $outlookPath ) Then
    
    $OLPath = RegRead("HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE", "Path" )
    If FileExists ( $OLPath & "\outlook.exe" ) Then
        $outlookPath = $OLPath & "\outlook.exe"
    Else
        MsgBox( 16 , "ExtraOutlook - Erreur", "Impossible de trouver Outlook.exe")
        Exit
    EndIf
    
    
EndIf

; Vérification que ExtraOutlook.exe est bien présent dans le même dossier
If NOT FileExists(@ScriptDir & "\ExtraOutlook.exe") Then
    FileInstall("ExtraOutlook.exe", @ScriptDir & "\ExtraOutlook.exe" , 1 )
    If NOT FileExists ( @ScriptDir & "\ExtraOutlook.exe") Then
        MsgBox(16, "ExtraOutlook - Erreur", "Impossible d'extraire ExtraOutlook.exe dans " & @ScriptDir )
        Exit
    EndIf
EndIf


; Listage tous les profiles
For $i= 1 to 1000
    $var = RegEnumKey("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles", $i )
    If @error <> 0 then ExitLoop
    _ArrayAdd($profList, $var)
Next

; Si un seul profil a été trouvé, on lance Outlook directement
If UBound ( $profList ) > 2 Then
    ChoiceProfile()
Else
    Run($outlookPath)
EndIf





Func ChoiceProfile()
    ; Création de la fenêtre de choix de profil


    $gui = GUICreate("Choix d'un profil", 300, 280 )
    $label = GUICtrlCreateLabel("Choisissez un profil de messagerie :", 10, 10, 280, 20 )
    $list = GUICtrlCreateList("", 10, 40, 280, 200 )
    
    For $i = 1 To UBound($profList) - 1
        GUICtrlSetData ( $list, $profList[$i] )
    Next
    
    $ok = GUICtrlCreateButton("OK", 10, 240, 130, 25 )
    $cancel = GUICtrlCreateButton("Annuler", 160, 240, 130, 25 )
    
    GUISetState()

    $msg = 0
    $selected = ""
    
    $begin = TimerInit()

    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()
        

        If $msg == $ok Then
            $selected = GUICtrlRead ($list)
            If $selected <> "" Then
                Run ( 'ExtraOutlook.exe "' & $outlookPath & '" /profile "' & $selected & '"' , @ScriptDir )
                Exit
            EndIf
        ElseIf $msg == $cancel Then
            Exit
        EndIf
        
    WEnd


    
    
EndFunc

 
Le script, ça fait gagner beaucoup de temps... à condition d'en avoir beaucoup devant soi !
Répondre