Sign in to follow this  
Followers 0
littlebigman

Right way to put focus on control?

7 posts in this topic

Hello

I need to interact with Outlook 2007. At some point, a window pops up and I need to put the focus on a control with Class=RichEdit20WPT and Instance=8.

What is the right way to do this? Should I use ControlFocus(), where "ID" is synonymous with "Instance"?

Thank you.

Share this post


Link to post
Share on other sites



What do you want to do with Outlook? There is an UDF available that might do what you need.

For download please see my siganture.


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

Thanks for the help. For each item in Contacts, I need to edit a few fields, eg. numbers in the Phone Numbers section.

Since Outlook doesn't provide keyboard shortcuts to put the focus on eg. the Home phone number, I figured I should use the revelant function to put the focus on that item.

If there's an Outlook UDF that makes it easier, I'm definitely interested.

Thank you.

Share this post


Link to post
Share on other sites

That should be possible with my UDF. In short:

_OL_Open             ; Open the connection to Outlook
_OL_FolderAccess     ; Access the contact folder
_OL_ItemFind          ; Find all or some contacts
_OL_ItemModify     ; Modify the contacts in a loop
_OL_Close           ; Close the connection to Outlook

If you would like to use the Outlook UDF I can give more details how to code the script.


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

Yes, please. I only have shallow knowledge of AutoIT, so any help/samples can help :-)

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

I downloaded and unzipped , but the included web pages are references to the different functions it provides while I would need a tutorial on how to get started. I also checked its wiki, but it doesn't contain samples either.

I need to loop through all the items in Contacts and, for each, edit some fields that contain wrong characters.

Would someone have some code handy that an AutoIT newbie could use to get up and running?

Thank you.

---

Edit: Here's what I did:

1. From the , copied OutlookEX.au3 into AutoIt3Include

2. Since I'm using the Scite editor, copied au3.user.calltips.api into AutoIt3SciTEapi. I tried to copy au3.userudfs.properties into AutoIt3SciTEproperties, but there is no such file or directory. Instead, there's au3.keywords.properties, so just copied au3.userudfs.properties in the same directory

3. Launched Scite, copy/pasted and hit F7 to build:

Aut2Exe Error: Line 8 (File "C:AppsAutoIT3.3.8.1IncludeOutlookEX.au3"):

#include <OutlookExConstants.au3>

Error: Error opening the file.

4. So copied OutlookEXConstants.au3 into AutoIt3Include as well, hit F7... and it builds OK.

5. After launching Outlook and running the AutoIT script, it does open the Contacts tab, but displays this dialog: "OutlookEX UDF: _OL_ItemFind Example Script. Number of items found: 0""

Edited by littlebigman

Share this post


Link to post
Share on other sites

Something like this.

It displays all contacts in your contact folder in an array.

Before you click on "YES" to alter every item you need to set the properties you want to change: "<property=value,property=value>" needs to be replaced!

#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
#include <OutlookEX.au3>
#include <array.au3>
; Open conenction to Outlook
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error opening connection to Outlook. @error = " & @error & ", @extended = " & @extended)
; Access the default contacts folder of the current user
Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderContacts)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error accessing the default contacts folder. @error = " & @error & ", @extended = " & @extended)
; Get a list of all contacts in folder
Global $aOL_Item = _OL_ItemFind($oOutlook, $aFolder[1], $olContact, "", "", "", "FullName,EntryID")
If @error Then Exit MsgBox(16, "OutlookEX UDF", "Error searching for items in the contacts folder. @error = " & @error & ", @extended = " & @extended)
If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF", "Could not find a contact item in the default contact folder. @error = " & @error & ", @extended = " & @extended)
_Arraydisplay($aOL_Item)
; Ask user if he wants to modify all items
Global $iReply = MsgBox(36, "OutlookEX UDF", "Do you want to modify all displayed contact items?")
If $iReply = 6 Then
; Modify all found items
For $i = 1 To $aOL_Item[0][0]
  _OL_ItemModify($oOutlook, $aOL_Item[$i][1], Default, "<property=value,property=value>")
  If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error modifying a contact item. @error = " & @error & ", @extended = " & @extended)
Next
EndIf
; Close connection to Outlook
_OL_Close($oOutlook)

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