Sign in to follow this  
Followers 0
kevinward13

Outlook Warning...

15 posts in this topic

First off...bare with me as this is one of my first scripts. It looks messy i know. but it works. But my question goes to Water and Wooltown. I have poked and prodded and can not for the life of me figure out how to get (_OL_Warnings.au3) to work like its stated on the Wiki. Could I bother someone or you two for a pointer?

Anyway...the below code was made for the pure and simple fact that our users are lazy and do not like to report problems with the PCs. So I thought i would make this just a weeee bit easier for them with a minimum interaction as possible. Just give me the small details as to what you were doing and viola.... done.

I know in the outlook send message it only sends it to yourself atm, but once i get this all tested and working like i want it to, then I will have to get the boss' approval first.

As always please feel free to cut, gut and slash the code around. I am always open to suggestions. Thanks!

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <EditConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <OutlookEx.au3>
#include <ScreenCapture.au3>
#include <Date.au3>

$iOL_Debug = 2
Global $oOutlook = _OL_Open()

Global $ping, $colItems, $objItem, $ComputerName, $OS, $SP, $Disk, $Disk_Caption, $Disk_FreeSpace, $Disk_Perc_Free, $Disk_Size, $AssetTag, $PC_Loc, $PIMS, $Answer, $Myedit, $Sub_Button, $No_Sub, $Sc_Path, $Sc_Name, $Sc_P

; Capture full screen
$Sc_Path = "C:\TEMP"
$Sc_P = _ScreenCapture_Capture("")
_ScreenCapture_SaveImage($Sc_Path & "\" & @ComputerName & "_Error.jpg", $Sc_P)



Global $ip = "localhost"
If $CmdLine[0] > 0 Then $ip = $CmdLine[1]

$objWMIService = ObjGet("winmgmts:{impersonationLevel = impersonate}!\\" & $ip & "\root\cimv2")

_WMI($ip)

Exit

Func _WMI($srv)
    ;Local $ping, $colItems, $objItem, $ComputerName, $OS, $SP, $Disk, $Disk_Caption, $Disk_FreeSpace, $Disk_Perc_Free, $Disk_Size, $AssetTag, $PC_Loc, $PIMS, $Answer, $Myedit, $Sub_Button, $No_Sub, $Full_Msg
    $ping = Ping($srv)
    If $ping Then
        $colItems = $objWMIService.ExecQuery("Select CSName, Caption, CSDVersion from Win32_OperatingSystem", "WQL", 0x30)
        If IsObj($colItems) Then
            For $objItem In $colItems
                $ComputerName = $objItem.CSName
                $OS = $objItem.Caption
                $SP = $objItem.CSDVersion
            Next
                ;ConsoleWrite($ComputerName & @CRLF & $os & @CRLF & $SP & @CRLF & @CRLF)
        EndIf
        $colItems = $objWMIService.ExecQuery("Select Caption, FreeSpace, MediaType, Size from Win32_LogicalDisk Where MediaType = '12'", "WQL", 0x30) ;get fixed harddisk media
        If IsObj($colItems) Then
            For $objItem In $colItems
                If $objItem.Size > 0 And $objItem.MediaType <> "" Then
                    $Disk_Caption = $objItem.Caption
                    $Disk_FreeSpace = Round($objItem.FreeSpace / 1024 ^ 3, 2)
                    $Disk_Size = Round($objItem.Size / 1024 ^ 3, 2)
                    $Disk_Perc_Free = Round(100 * $objItem.FreeSpace / $objItem.Size, 2)
                    ;$Disk &= $Disk_Caption & @CRLF & $Disk_Size & @CRLF & $Disk_FreeSpace & @CRLF
                EndIf
            Next
            ;ConsoleWrite($Disk & @CRLF & $Disk_Size & " GB" & @CRLF & $Disk_FreeSpace & " GB" & @CRLF & @CRLF)
            ;ConsoleWrite($Disk & @CRLF & @CRLF)
        EndIf
        $AssetTag = RegRead("HKLM\SYSTEM\SETUP", "AssetTag")
        $PIMS = RegRead("HKLM\SYSTEM\SETUP", "PIMS")
        $PC_Loc = RegRead("HKLM\SYSTEM\SETUP", "Location")
        ;ConsoleWrite($ComputerName & @CRLF & $os & @CRLF & $SP & @CRLF & $Disk & @CRLF & $Disk_Size & " GB" & @CRLF & $Disk_FreeSpace & " GB" & @CRLF & "Serial Number: " & $AssetTag & @CRLF & "PIMS Number: " & $PIMS & @CRLF & "Location: " & $PC_Loc & @CRLF & @CRLF)
    Else
        Return "Host not reachable"
    EndIf
    
    GUICreate("Describe your Problem...", 350, 350, -1, -1, -1, $WS_EX_TOPMOST)  ; will create a dialog box that when displayed is centered

    $Myedit = GUICtrlCreateEdit("", 10, 10, 300, 300, $WS_VSCROLL + $ES_UPPERCASE + $ES_WANTRETURN)
    $Sub_Button = GUICtrlCreateButton("Submit", 150, 320, 50)
    $No_Sub = GUICtrlCreateButton("Cancel", 250, 320, 50)
    
    GUISetState()
; testing information gathered and format.
    Do
        $Answer = GUIGetMsg()
        If $Answer = $Sub_Button Then
            
            GUISetState(@SW_HIDE)
                        
        ElseIf $Answer = $No_Sub Then
            GUIDelete()
            Exit
        EndIf
    Until $Answer = $Sub_Button

; Sending mail

    Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name
    _OL_Wrapper_SendMail($oOutlook, $sCurrentUser, "", "", "PROBLEM REPORTED: " & @ComputerName & " - " & _Now(), _Now() & "<br>" & "<br>" & "User logged into PC: " & @UserName & " / " & $sCurrentUser & "<br>" & $ComputerName & "<br>" & $os & "<br>" & $SP & "<br>" & $Disk & "<br>" & "Disk Size: " & $Disk_Size & " GB" & "<br>" & "Free Space: " & $Disk_FreeSpace & " GB" & "<br>" & "Serial Number: " & $AssetTag & "<br>" & "PIMS Number: " & $PIMS & "<br>" & "Location: " & $PC_Loc & "<br>" & "<br>" & "<br>" & "<br>" & "PROBLEM DESCRIPTION: " & "<br>" & "<br>" & GUICtrlRead($MyEdit), $Sc_Path & "\" & @ComputerName & "_Error.jpg" , $olFormatHTML, $olImportanceHigh) ;@ScriptDir & "\include\_OL_Wrapper_SendMail.au3"
    If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
    MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")



EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Maybe the Wiki is wrong :huh2:

Did you compile _OL_Warnings.au3 to create an exe? If yes, where did you store the exe?

If the exe is in the same directory as the script then _OL_Open(True) to activate it is enough. Else you have to provide the full path as parameter 2.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you Water!

I did compile the exe. the exe is the in same folder as the script.

when watching my tasklist, I see the _OL_Warnings.exe running while the script is being executed, but when it comes to the pop-up warning messages, it just sits there and does no clicky clicky or tool tip. Any more thoughts or ideas?

Win XP SP3 and Outlook 2003

Share this post


Link to post
Share on other sites

ok also noticed that the script finishes with error code 1.

which from the _OL_Warnings.au3 means - 1 - ProcessID is missing as first parameter.

Ok so this is really a noob question...i noticed on the task manger the PID keeps changing...so how do you specify?

Share this post


Link to post
Share on other sites

Might be a bug - I will check and post the results.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Might be a bug - I will check and post the results.

Thanks Water!

More than likely an error on my side. But I keep looking at it over and over thinking i have some sort of syntax error in there but i just can not figure it out or find :huh2: it.

Share this post


Link to post
Share on other sites

Thanks Water!

More than likely an error on my side. But I keep looking at it over and over thinking i have some sort of syntax error in there but i just can not figure it out or find :huh2: it.

Sorry, I meant: It could be a bug on our side! Because the ProcessID should be passed automatically. I will investigate the problem and post the findings.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

It might be a timing problem. _OL_Warnings stops to check for the warnings window and click on the buttons to close it as soon as the calling script has ended. Your script might end too fast.

I've changed _OL_Warnings so it does at least check one time for the warnings window and then exit if the calling process doesn't exist any more.

Could you please replace _OL_Warnings.au3 with the following code:

; #PROGRAM# =====================================================================================================================
; Name ..........: _OL_Warnings
; Description ...: Check if Outlook warning windows pops up, if so bypass them, by clicking "allow".
; Syntax.........: Run(_OL_Warnings.exe $iOL_ProcessID [$iOL_WinCheckTime[ $iOL_ControlCheckTime]])
; Parameters ....: $iOL_ProcessID   - The ProcessID of the calling script we should monitor and exit when finished
;                  $iOL_WinCheckTime  - Optional: How long, in milliseconds, we will wait before we check for the warning windows (default = 1000)
;                  $iOL_CtrlCheckTime - Optional: How long, in milliseconds, we will wait before we check that the controls we click are enabled (default = 1000)
; Return values .: Failure - Sets returns value:
;                  |1 - ProcessID is missing as first parameter
;                  |2 - Specified ProcessID does not exist at startup
; Author ........: Wooltown
; Modified ......:
; Remarks .......: If Outlook has security settings enabled, then warning windows will pop up, requiring manual key pressing.
;                  This function makes the necessary key presses. It is called by _OL_Open if you set $fOL_WarningClick to True or anytime by your script.
;                  The exe runs until the calling script is terminated.
;+
;                  Compile this script into an exe. Default location is the directory where the calling script is located.
;                  If you run Outlook in a different language then please change window title ($sWindowTitle) and text ($sWindowText).
;+
;                  To test the exe in case of problems please run the following DOS bat file:
;                    _OL_Warnings.exe ProcessID [$iOL_WinCheckTime[ $iOL_ControlCheckTime]]
;                    echo %ErrorLevel%
;                  If the output is not 0 then one of the errors described above has happened (section: Return values).
; Related .......:
; Link ..........:
; Example .......:
; ===============================================================================================================================
Global $sWindowTitle = "Microsoft Outlook"
Global $sWindowText  = "A program is trying to"
Opt("TrayIconHide", 1)          ; 0=show, 1=hide tray icon
Opt("WinSearchChildren", 1)     ; 0=no, 1=search children also
Global $iOL_ProcessID, $iOL_WinCheckTime, $iOL_CtrlCheckTime
If $CmdLine[0] = 0 Then Exit 1  ; No ProcessID was specified
$iOL_ProcessID = $CmdLine[1]
If Not ProcessExists($iOL_ProcessID) Then Exit 2
If $CmdLine[0] > 1 Then $iOL_WinCheckTime  = $CmdLine[2]
If $CmdLine[0] > 2 Then $iOL_CtrlCheckTime = $CmdLine[3]
If $CmdLine[0] < 2 Then $iOL_WinCheckTime  = 1000
If $CmdLine[0] < 3 Then $iOL_CtrlCheckTime = 1000
While 1
    If WinExists($sWindowTitle, $sWindowText) Then
        Local $aOL_WinSize = WinGetPos($sWindowTitle, $sWindowText)
        ToolTip(@CRLF & "OL_Warning will automatically click these buttons" & @CRLF, $aOL_WinSize[0] + 50, $aOL_WinSize[1] + 70, "Don't touch")
        While 1
            WinActivate($sWindowTitle, $sWindowText)
            If ControlCommand($sWindowTitle, $sWindowText, "Button3", "IsEnabled") Then
                ControlFocus($sWindowTitle, $sWindowText, "[CLASS:Button; INSTANCE:3]")
                ControlClick($sWindowTitle, $sWindowText, "Button3")
            EndIf
            If ControlCommand($sWindowTitle, $sWindowText, "Button4", "IsEnabled") Then
                ControlFocus($sWindowTitle, $sWindowText, "[CLASS:Button; INSTANCE:4]")
                Send("{SPACE}")
                ToolTip("")
                ExitLoop
            EndIf
            Sleep($iOL_CtrlCheckTime)
            If Not WinExists($sWindowTitle, $sWindowText) Then ExitLoop
        WEnd
    EndIf
    Sleep($iOL_WinCheckTime)
    If Not ProcessExists($iOL_ProcessID) Then Exit
WEnd

BTW: The returncode set by _OL_Warnings isn't useful when called from _OL_Open because "Run" doesn't return any data to the calling script. It's only useful for debugging using the steps as described in the remarks.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I recompiled the exe and put it in the script dir and still no go.

I was watching my tasklist and saw _OL_Warnings.exe appear as soon as i click submit. I sat there for a minute or so and still no clicking.

Based on your feed back about the calling script exiting too fast, i think that is the problem. the code in the script is scrabble and needs to be cleaned up to make it purtty. I am stil thinking the issue is my code

Edited by kevinward13

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

I recompiled the exe and put it in the script dir and still no go.

I was watching my tasklist and saw _OL_Warnings.exe appear as soon as i click submit. I sat there for a minute or so and still no clicking.

Based on your feed back about the calling script exiting too fast, i think that is the problem. the code in the script is scrabble and needs to be cleaned up to make it purtty. I am stil thinking the issue is my code

Can we use one of the sample scripts to track down the problem? This modified _OL_Wrapper_SendMail should give us a clue where the problem is.

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <outlookex.au3>

$iOL_Debug = 2
Global $oOutlook = _OL_Open(True)
Msgbox(0,"","_OL_Warnings.exe should now be visible in the taskmanager")
Global $sCurrentUser = $oOutlook.GetNameSpace("MAPI" ).CurrentUser.Name
_OL_Wrapper_SendMail($oOutlook, $sCurrentUser, "", "", "TestSubject", "Bodytext", @ScriptDir & "\_OL_Wrapper_SendMail.au3", $olFormatHTML, $olImportanceHigh)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Error sending mail. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OutlookSendMail Wrapper Script", "Mail successfully sent to user '" & $sCurrentUser & "'!")

Can you see the _OL_Warnings.exe in the taskmanager when the MsgBox pops up?

Could you please attach a screenshot of the Outlook warning screen you get?

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Yep...when the MsgBox came up I saw the _OL_Warnings.exe in the taskmanager.

Here are the screen shots of the warnings.

post-61425-0-07463800-1307141084_thumb.j

post-61425-0-66470300-1307141093_thumb.j

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

FIGURED IT OUT!!!!! Had to change this

Global $sWindowTitle = "Microsoft Outlook"

to this

Global $sWindowTitle = "Microsoft Office Outlook"

inside the _OL_Warnings.au3

Edited by kevinward13

Share this post


Link to post
Share on other sites

Great you could solve the problem!

I'm going to check if this is the Window title for Outlook 2010 as well. If yes, I will change _OL_Warnings.au3 accordingly.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Great you could solve the problem!

I'm going to check if this is the Window title for Outlook 2010 as well. If yes, I will change _OL_Warnings.au3 accordingly.

oddly enough...when i ran this script on our windows 7 and outlook 2010 i did not get this issue. even before the _OL_Warnings was resolved.

I sent right on through

Share this post


Link to post
Share on other sites

oddly enough...when i ran this script on our windows 7 and outlook 2010 i did not get this issue. even before the _OL_Warnings was resolved.

The window title has been changed by M$.

If all the coding has been done and before releasing the product it seems that they randomly change window titles :huh2:

I will pass the Outlook version to _OL_Warnings so the script can decide which window title to use.

Thanks for taking the time to test this.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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