Jump to content
cag8f

How to send a CTRL-B command after using ControlFocus()?

Recommended Posts

cag8f

Hi all.  I have AutoIt code that activates an open window, then focuses one of its controls:

WinActivate (" - Task")
ControlFocus ( " - Task", "", "Message")

The window in-question is a Microsoft Outlook window, and the control is its 'message' field (screenshot).  When this code is run, the Windows and control focus, and I can then type text into this control, as expected. But I cannot carry out a CTRL-B to enable bold text (or CTRL-U, or similar commands).  When I do so, I am met with an audible alert for 'command not allowed' (or something similar).  It is only after I manually mouse over the control in-question and click inside it, that a CTRL-B is then recognized.  How can I resolve this, and ensure that after I focus the control, I can carry out a CTRL-B command?

The end goal is to eventually use `send()` to send a CTRL-B command to this control.  But this issue is tripping me up when I try to do so.

Thanks in advance.

Share this post


Link to post
Share on other sites
Subz

Have you looked at the Outlook UDF?  You can create tasks etc... using dom which is alot better than send functions.  Have a look at the _OL_ItemCreate.htm from the link below and it has an example of how to create a Task.

 

Share this post


Link to post
Share on other sites
cag8f

@Subz OK thanks for that.  I'll have a look. But I don't plan on doing very much else with send() besides CTRL-U, CTRL-B, and sending text.  Nor do I plan on doing much more AutoiIt coding with Outlook.  So if there are more 'quick-and-dirty' methods to do what I want, I might be interested in at least hearing what they entail.  It might be the path of least resistance in this case.

Share this post


Link to post
Share on other sites
Subz

Use the Autoit Window Info Tool on the body of the Task Sequence to get the Control Information, after that just put it together example:

Opt("SendKeyDelay", 10)     ;~ Wait 10 Ms between key strokes
Opt("WinTitleMatchMode", 2) ;~ Window Title Match Mode = Partial
WinActivate (" - Task")
ControlFocus(" - Task", "", "[CLASS:_WwG; INSTANCE:1]")
ControlSend (" - Task", "", "[CLASS:_WwG; INSTANCE:1]", "^bTitle^b" & @CR)      ;~ ^b Enable Bold :: Text = Title :: ^b Disable Bold :: @CR Carriage Return
ControlSend (" - Task", "", "[CLASS:_WwG; INSTANCE:1]", "^uSubtitle^u" & @CR)   ;~ ^u Enable Underline :: Type Subtitle :: ^u Disable Underline :: @CR Carriage Return

 

Share this post


Link to post
Share on other sites
cag8f

Ah OK, looks like you're using ControlSend() instead of send().   I didn't know that existed--it looks to be more applicable here, and perhaps it is the source of my issue?

Thanks for that.  Give me a few days to test this.  I'll report back here.

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

×