-2

rendered output

markdown

-1

votes

Comment: code alignment

Clear the text value in other App's edit control by using Excel VBA with Windows API

hTarget is a handle value of other application. [Failed]

  • ret = SendMessage(hTarget, WM_SETFOCUS, 0&, 0&)
    • ret = SendMessage(hTarget, WM_KEYDOWN, VK_CONTROL, 0) -ret = SendMessage(hTarget, WM_KEYDOWN, 97, 0)
    • ret = SendMessage(hTarget, WM_KEYDOWN, VK_DELETE, 0)
    • Sleep (300)
    • ret = SendMessage(hTarget, WM_KEYUP, VK_DELETE, 0)
    • ret = SendMessage(hTarget, WM_KEYUP, 97, 0) -ret = SendMessage(hTarget, WM_KEYUP, VK_CONTROL, 0)

[Failed]
-Const EM_SETSEL = &HB1

-Const EM_REPLACESEL = &HC2

-Const EM_GETSEL = &HB0

-hTarget = FindWindowEx(hTarget, 0&, "TPlusMemoU", vbNullString)

-Call SendMessage(hTarget, EM_SETSEL, 0, -1)

-Call SendMessage(hTarget, EM_REPLACESEL, 1, "")

[Failed]
-Call SendMessage(hTarget, WM_KEYDOWN, VK_BACK, 0) -Call SendMessage(hTarget, WM_CHAR, 8, 0)

hTarget is a handle value of other application. [Failed] ret = SendMessage(hTarget, WM_SETFOCUS, 0&, 0&)
ret = SendMessage(hTarget, WM_KEYDOWN, VK_CONTROL, 0)
ret = SendMessage(hTarget, WM_KEYDOWN, 97, 0)
ret = SendMessage(hTarget, WM_KEYDOWN, VK_DELETE, 0)
Sleep (300)
ret = SendMessage(hTarget, WM_KEYUP, VK_DELETE, 0)
ret = SendMessage(hTarget, WM_KEYUP, 97, 0)
ret = SendMessage(hTarget, WM_KEYUP, VK_CONTROL, 0)

[Failed] Const EM_SETSEL = &HB1

Const EM_REPLACESEL = &HC2 Const EM_GETSEL = &HB0

hTarget = FindWindowEx(hTarget, 0&, "TPlusMemoU", vbNullString)

Call SendMessage(hTarget, EM_SETSEL, 0, -1) Call SendMessage(hTarget, EM_REPLACESEL, 1, "")

[Failed] Call SendMessage(hTarget, WM_KEYDOWN, VK_BACK, 0) Call SendMessage(hTarget, WM_CHAR, 8, 0)

Latestarter
  • 39
  • 1
  • 7
  • 1
    The question is of very low quality. You appear to have pasted some code into the question box and made no attempt to format it. There's no explanation or question. Please improve with an edit. – David Heffernan May 14 '15 at 07:18

1 Answers1

0

You can't. The specs say you areprevented fropm getting the text from another process's edit control.

GetWindowText Function

The GetWindowText function copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application.

  • GetWindowText is not mentioned in the question. There is WM_GETTEXT for cross process. – David Heffernan May 14 '15 at 05:28
  • Question is not getting the text of other App's edit control. – Latestarter May 14 '15 at 06:20
  • Question is how to select the text of other App's edit control and to replace the selected text with the blank of "". EM_GETTEXT, EM_SELTEXT, EM_SELREPLACE.....This is really difficult, and almost impossible to find out proper explanation. – Latestarter May 14 '15 at 06:22