Jump to content

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


cag8f
 Share

Recommended Posts

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.

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 2 weeks later...

@Subz sorry for the delay.  Here are my follow ups. 

I had a look with the AutoIt Window Info Tool, and what you indicated for CLASS and INSTANCE seem to be accurate (screenshot).  I then entered your code and ran it. But the same issue occurs.  Namely, the text `Title` and `Subtitle` are entered into the control, as well as the carriage returns.  But the bold and underline don't occur--instead are two audible Windows 'error' prompts (not sure of the correct term).

Thoughts on that?  Maybe I specify something different for the `controlID` parameter in `controlsend()`?

Edited by cag8f
Link to comment
Share on other sites

does Outlook allow inline html formatting? <b><ins>this text is in bold and underlined</ins></b>

If @error Then
    MsgBox(262192, "", @ComputerName & " slaps " & @UserName & " around a bit with a large trout!")
EndIf

"Yeah yeah yeah patience, how long will that take?"  -Ed Gruberman

REAL search results  |  SciTE4AutoIt3 Editor Full Version

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...