wyattbiker Posted October 24, 2013 Share Posted October 24, 2013 Hi, My specific need is to be able to highlight the phone number under the mouse cursor in applications such as PDFs, Office, Notepad, etc (just text, not on images) and then paste it in to the clipboard and pass it on to an application. An example of a phone number would be 800-555-1212 or 1-800-callthisnumber or some other pattern that I can define using regex. Here is the logic. #1) Highlight text up to a space in directions of the word under the mouse cursor. #2) Capture it into the clipboard #3) Do a pattern match for phone number. #4) Pass it on to an external application (to a browser or something else) The problem is double click alone will not do it since double click only highlights alphanumeric text but not special characters such as (-) and (@) and (.) and () for example. Any ideas? Thank you! TomasRedwewZembews 1 Link to comment Share on other sites More sharing options...
l3ill Posted October 24, 2013 Share Posted October 24, 2013 You could drag and highlight or triple-click highlights the entire line of text. Depends on how much control you have over the doc being used. My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
jdelaney Posted October 24, 2013 Share Posted October 24, 2013 (edited) Try this out...mouse over the number, and send Control+g...will only work on application inputs, word docs, etc: expandcollapse popup; control g AutoItSetOption("SendKeyDownDelay",15) AutoItSetOption("SendKeyDelay",15) HotKeySet("^g", "GetPhoneNumber") While True WEnd Func GetPhoneNumber() ClipPut("") MouseClick("Primary") $hwnd = WinGetHandle("[ACTIVE]") ; Select text backwards until space is found While True ;~ ControlSend($hwnd, "", "", "{SHIFTDOWN}") ControlSend($hwnd, "", "", "+{LEFT}") ;~ ControlSend($hwnd, "", "", "{SHIFTUP}") ControlSend($hwnd, "", "", "^c") Sleep(15) ConsoleWrite(StringRegExp(ClipGet(),"[^\w|^-]+",0) & " " & ClipGet()& @CRLF) If StringRegExp(ClipGet(),"[^\w|^-]",0) Then ControlSend($hwnd, "", "", "{RIGHT}") ExitLoop EndIf WEnd ; Select text forwards until space is found While True ;~ ControlSend($hwnd, "", "", "{SHIFTDOWN}") ControlSend($hwnd, "", "", "+{RIGHT}") ;~ ControlSend($hwnd, "", "", "{SHIFTUP}") ControlSend($hwnd, "", "", "^c") Sleep(15) ConsoleWrite(ClipGet()& @CRLF) If StringRegExp(ClipGet(),"[^\w-]",0) Then ControlSend($hwnd, "", "", "+{LEFT}") ExitLoop EndIf WEnd ConsoleWrite("FINAL........." & ClipGet() & @CRLF) EndFunc For things like web pages, you would have to loop mouseclick moves, with shift down, to highlight more or less Edited October 24, 2013 by jdelaney wyattbiker 1 IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window. Link to comment Share on other sites More sharing options...
Solution wyattbiker Posted October 28, 2013 Author Solution Share Posted October 28, 2013 (edited) It logic works but autoit is not reliable (throws in c character sometimes and also very slow). But it is a good starting point. Thank you. Edited October 28, 2013 by wyattbiker Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now