시스템 전체 핫키를 등록하는 작은 트레이 응용 프로그램이 있습니다. 사용자가 응용 프로그램에서 텍스트를 선택하고이 단축키를 누르면 선택한 텍스트를 캡처 할 수 있기를 원합니다. 나는 현재이 사용 AutomationElements을하고 있어요 :모든 창에서 선택한 텍스트를 가져 오는 방법 (UI 자동화 사용) - C#
이 (예 : 메모장, 비주얼 스튜디오 편집 상자와 같은)하지만 같은 워드, 파이어 폭스, 크롬과 같은 모든 (대한 등 일부 응용 프로그램 작동//Using FocusedElement (since the focused element should be the control with the selected text?)
AutomationElement ae = AutomationElement.FocusedElement;
AutomationElement txtElement = ae.FindFirst(TreeScope.Subtree,Condition.TrueCondition);
if(txtElement == null)
return;
TextPattern tp;
try
{
tp = txtElement.GetCurrentPattern(TextPattern.Pattern) as TextPattern;
}
catch(Exception ex)
{
return;
}
TextPatternRange[] trs;
if (tp.SupportedTextSelection == SupportedTextSelection.None)
{
return;
}
else
{
trs = tp.GetSelection();
string selectedText = trs[0].GetText(-1);
MessageBox.Show(selectedText);
}
.)
모든 응용 프로그램에서 선택한 텍스트를 검색하는 방법에 대한 아이디어가있는 사용자는 누구입니까?
아래에 언급 된 내용에도 불구하고 클립 보드는 응용 프로그램이 Ctrl-C (또는 무엇이든) 구현 한 경우에만 채워진다는 점을 기억하십시오. 클립 보드가 해결책이 아닙니다. – smirkingman