Jump to content
littlebigman

Why can't AutoIT copy the contents of an editbox?

Recommended Posts

littlebigman

Hi,

I'm no AutoIT expert, so it could be something obvious.

The following code fails getting (copying) the contents of the Note section of items in Outlook's Tasks list:

#include <Constants.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>

;Wait for item from Tasks list
Opt("WinTitleMatchMode", 2) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase
Local $hWndLocal = WinWaitActive("[TITLE:Task; CLASS:rctrl_renwnd32]", "", 10)

#cs
>>>> Control <<<<
Class:    _WwG
ClassnameNN:    _WwG1
Name:
Advanced (Class):    [CLASS:_WwG; INSTANCE:1]
Text:    Message
Style:    0x56000000
ExStyle:    0x00000010
Handle:    0x00760D2E
#ce

Local $sNote = ControlGetText($hWndLocal, "", "[CLASSNN:_WwG1]")
;Displays "Message" !
MsgBox($MB_SYSTEMMODAL, "$sNote", $sNote)

The following works, but I was wondering why the former doesn't, and if there's a more elegant solution:

;Move from Subject field
Send("{TAB 9}")
Send("^a")
Send("^c")
Local $sNote = ClipGet()
MsgBox($MB_SYSTEMMODAL, "$sNote", $sNote)

Thank you.

Share this post


Link to post
Share on other sites
kosamja

Maybe because class _WwG1 is not standard Windows control?

Share this post


Link to post
Share on other sites
Earthshine

water has an Outlook UDF that might help. otherwise it's UIAutomation for you

Edited by Earthshine

My resources are limited. You must ask the right questions

 

Share this post


Link to post
Share on other sites
Subz

In Outlook select Tasks (tab) ( or select any mail folder) then run the following:

$oOutlook = ObjCreate("Outlook.Application")
$oOutlookFolder = $oOutlook.ActiveExplorer.CurrentFolder

For $i = 1 To $oOutlookFolder.Items.Count
    $oOutlookItem = $oOutlookFolder.Items($i)
    ConsoleWrite($oOutlookItem.Subject & @CRLF & $oOutlookItem.Body & @CRLF)
Next

 

Share this post


Link to post
Share on other sites
littlebigman

Thanks much.

Notes

  • Because of the ConsoleWrite(), click on Tools > Compile, and check "Create CUI instead of GUI EXE"
  • There's no need to add some #include: The required code is available by default with AutoIT
  • By some kind of magic, it can locate the running instance of Outlook and read items from its Tasks window.

I'll experiment, and see how to insert each item's Subject + Note sections into an SQLite database.

Here's how to display items in a ListView grid:

#include <GUIConstantsEx.au3>
#include <ColorConstants.au3>

GUICreate("listview items", 700, 700)

Global $idListview = GUICtrlCreateListView("col1                                              |col2                          ", 10, 10, 650, 650)

$oOutlook = ObjCreate("Outlook.Application")
$oOutlookFolder = $oOutlook.ActiveExplorer.CurrentFolder

For $i = 1 To $oOutlookFolder.Items.Count
    $oOutlookItem = $oOutlookFolder.Items($i)
    GUICtrlCreateListViewItem($oOutlookItem.Subject & "|" & $oOutlookItem.Body, $idListview)
Next

GUISetState(@SW_SHOW)

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

 

Edited by littlebigman

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

×