vrocco Posted July 16, 2010 Share Posted July 16, 2010 (edited) I am trying to send the contents of a text file to an email recipient using outlook. The only problem I am having is that my company uses a third party plugin that allows you to add a classification to the message before sending. I am trying to click-through that classification window so that it will send without any user interaction. However, it doesn't seem to identify the window that pops up. Can somebody help me with what I am doing wrong here. Included the relevant part of the code below: $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem($olMailItem) $oOMail.Save With $oOMail .To = $address .Subject = $subject .BodyFormat = $olFormatHTML .Importance = $olImportanceNormal While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $lineFinal = $lineFinal & "<BR>" &$line WEnd FileClose($file) .HTMLBody = $lineFinal .Send Do Sleep(500) Until WinExists("Message Classification", "Select Classification") ControlClick("Message Classification", "Select Classification", 1) EndWith $oOApp = 0 WinMatchTitleMode is set to 2 Edited July 16, 2010 by vrocco Link to comment Share on other sites More sharing options...
vrocco Posted July 16, 2010 Author Share Posted July 16, 2010 no one? Link to comment Share on other sites More sharing options...
vrocco Posted July 17, 2010 Author Share Posted July 17, 2010 So everyone else is as stumped as I am? Link to comment Share on other sites More sharing options...
water Posted July 17, 2010 Share Posted July 17, 2010 Did you use AutoIts Window Info Tool to check if the Window title, window text and ControlId are correct? Where does your script hang? In the loop or when it tries to ControlClick? If you don't know insert a ConsoleWrite in the loop, before and after the ControlClick. Check the return value of ControlClick. I separated the parts of your script: reading the file, creating the mail and waiting for the window to pop up While 1 $line = FileReadLine($file) If @error = -1 Then ExitLoop $lineFinal = $lineFinal & "<BR>" & $line WEnd FileClose($file) $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem($olMailItem) With $oOMail .Save .To = $address .Subject = $subject .BodyFormat = $olFormatHTML .Importance = $olImportanceNormal .HTMLBody = $lineFinal .Send EndWith Do ConsoleWrite("Sleep" & @CRLF) Sleep(500) Until WinExists("Message Classification", "Select Classification") ConsoleWrite("Before ControlClick" & @CRLF) $iResult = ControlClick("Message Classification", "Select Classification", 1) ConsoleWrite("After ControlClick. Result = " & $iResult & @CRLF) $oOApp = 0 My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Juvigy Posted July 19, 2010 Share Posted July 19, 2010 If it is a plug in you can disable it and then send the mail and then enable it. Most likely you can set classification(what is that?) using the Outlook COM . Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 Did you use AutoIts Window Info Tool to check if the Window title, window text and ControlId are correct?Where does your script hang? In the loop or when it tries to ControlClick? If you don't know insert a ConsoleWrite in the loop, before and after the ControlClick. Check the return value of ControlClick.I separated the parts of your script: reading the file, creating the mail and waiting for the window to pop upI have never used ConsoleWrite before. How do I view the output? Do I need notepad or something open for it to write to? I tried to do something similar by placing a MsgBox after the WinExists function that just said "Got Window". It never gave me the message box, so I assume that is where it is stalling. I did check the AutoIt Info tool to make sure I had the window title and text set correctly and set the WinTitleMatch Mode to 2. Still no love.If it is a plug in you can disable it and then send the mail and then enable it.Most likely you can set classification(what is that?) using the Outlook COM .This isn't an option because they are set by global policy. All machines are part of a domain, so as the local admin, I don't have the power to change this. Link to comment Share on other sites More sharing options...
water Posted July 19, 2010 Share Posted July 19, 2010 ConsoleWrite in the SciTE environment does the same as MsgBox for compiled scripts. As you never get to the MsgBox either the title or the text can not be found. Could you please try Until WinExists("Message Classification")so we can check where the problem is? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 ConsoleWrite in the SciTE environment does the same as MsgBox for compiled scripts. As you never get to the MsgBox either the title or the text can not be found. Could you please try Until WinExists("Message Classification")so we can check where the problem is? Still no MsgBox when doing it this way. I was looking at the Au3Info window and this window seems to have a different class than just the normal explorer windows. Would it be possible to use WinTitleMatchMode 4 with the classname to find it? I have never done that either. How would I format that? Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 Incidentally, here is the Au3Info. Am I missing something? Press CTRL-ALT-F to freeze the display. >>>>>>>>>>>> Window Details <<<<<<<<<<<<< Title: Message Classification - PAROCCOVS11 MAC Address Class: #32770 Size: X: 432 Y: 240 W: 417 H: 167 >>>>>>>>>>> Mouse Details <<<<<<<<<<< Screen: X: 557 Y: 254 Cursor ID: 2 >>>>>>>>>>> Pixel Color Under Mouse <<<<<<<<<<< RGB: Hex: 0x3997DD Dec: 3774429 >>>>>>>>>>> Control Under Mouse <<<<<<<<<<< Size: Control ID: ClassNameNN: Text: >>>>>>>>>>> Status Bar Text <<<<<<<<<<< >>>>>>>>>>> Visible Window Text <<<<<<<<<<< Select Classification Level(s)... Classification UNCLASSIFIED Caveats OK Cancel >>>>>>>>>>> Hidden Window Text <<<<<<<<<<< >> << &Help Verify Recipients Link to comment Share on other sites More sharing options...
water Posted July 19, 2010 Share Posted July 19, 2010 For the Advanced Window Descriptions to work you don't have to set the WinTitleMatchMode (according to the help file). Just use: WinWaitActive("[CLASS:#32770]") My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 For the Advanced Window Descriptions to work you don't have to set the WinTitleMatchMode (according to the help file). Just use: WinWaitActive("[CLASS:#32770]") That didn't do anything. However, here is something weird. When I did set the WinTitleMatchMode to 4 and used this: Do Sleep(500) Until WinExists("classname=#32770") MsgBox(0, "Got it", "Got window") It did nothing while the window was visible, but when I manually clicked the cancel button on the window, then the msgbox popped up. So somehow it exited that loop when I cancelled which it wasn't doing before. Link to comment Share on other sites More sharing options...
water Posted July 19, 2010 Share Posted July 19, 2010 Another try. Replace the loop Do Sleep(500) Until WinExists("[CLASS:#32770]") MsgBox(0, "Got it", "Got window")with WinWait("[CLASS:#32770]") MsgBox(0, "Got it", "Got window") WinActivate("[CLASS:#32770]") Make sure to write CLASS in upper case - as the examples in the help file do. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
water Posted July 19, 2010 Share Posted July 19, 2010 I searched the forum and found this one.So this class seems to be very common and therefore the code should describe the window as good as possible:WinWait("[CLASS:#32770]","Select Classification Level(s)") MsgBox(0, "Got it", "Got window") WinActivate("[CLASS:#32770]","Select Classification Level(s)") My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 OK it does the same thing as before. Nothing until I hit the cancel button on the popup window and then I get the msgbox. Man this is frustrating. Link to comment Share on other sites More sharing options...
water Posted July 19, 2010 Share Posted July 19, 2010 (edited) Could you run this little code snippet when your Classification Window is active and post the results? #include <array.au3> $avWinList = WinList("[Class:#32770]") _ArrayDisplay($avWinList, "#32770") Edited July 19, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 I searched the forum and found this one. So this class seems to be very common and therefore the code should describe the window as good as possible: WinWait("[CLASS:#32770]","Select Classification Level(s)") MsgBox(0, "Got it", "Got window") WinActivate("[CLASS:#32770]","Select Classification Level(s)") This one doesn't even give me the msgbox when I hit cancel Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 Could you run this little code snippet when your Classification Window is active and post the results? #include <array.au3> $avWinList = WinList("[Class:#32770]") _ArrayDisplay($avWinList, "#32770") [0]|8| [1]|On-Access Scan Messages|0x00010210 [2]|Message Classification - PAROCCOVS11 MAC Address|0x00040814 [3]|2 Reminders|0x0003051A [4]|Outlook Send/Receive Progress|0x00090336 [5]|McAfee AutoUpdate|0x000102E6 [6]|McAfee Agent Monitor|0x000102C4 [7]|On-Access Scan Statistics|0x0001022E [8]|Odtray Window|0x000201A8 Link to comment Share on other sites More sharing options...
water Posted July 19, 2010 Share Posted July 19, 2010 (edited) [0]|8| [1]|On-Access Scan Messages|0x00010210 [2]|Message Classification - PAROCCOVS11 MAC Address|0x00040814 [3]|2 Reminders|0x0003051A [4]|Outlook Send/Receive Progress|0x00090336 [5]|McAfee AutoUpdate|0x000102E6 [6]|McAfee Agent Monitor|0x000102C4 [7]|On-Access Scan Statistics|0x0001022E [8]|Odtray Window|0x000201A8 As you can see the entry number [2] is what you need. What do you get when you just run #include <array.au3> Opt("WinTitleMatchMode", 2) $avWinList = WinList("Classification") _ArrayDisplay($avWinList, "Classification") Edited July 19, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
vrocco Posted July 19, 2010 Author Share Posted July 19, 2010 [0]|1| [1]|Message Classification - PAROCCOVS11 MAC Address|0x001A0D20 Link to comment Share on other sites More sharing options...
water Posted July 19, 2010 Share Posted July 19, 2010 (edited) OK, another try: #include <array.au3> Opt("WinTitleMatchMode", 2) $avWinList = WinList("Message Classification") _ArrayDisplay($avWinList, "Message Classification") If you don't get a result with this try then we know that there is no space betwenn "Message" and "Classification" in the window title. Edited July 19, 2010 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now