Jump to content

Can autoscript help me clipboard text under the cursor in any application


Go to solution Solved by wyattbiker,

Recommended Posts

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!

 

Link to comment
Share on other sites

Try this out...mouse over the number, and send Control+g...will only work on application inputs, word docs, etc:

; 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 by jdelaney
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

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