Jump to content

access to marked text


Recommended Posts

Welcome to the forums.

It all depends on the application and the control you're dealing with. (Some apps resist automation)

If it's an Edit box, you can get the selection range with _GUICtrlEdit_GetSel and then pull the text out with StringMid & _GUICtrlEdit_GetText.

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Thanks!

Im quite new to AutoIt. Can you explain me how to do what you meant?

For exapmle, how can I copy a that is selected in notpad?

Thanks,

Daniel

#include <GUIEdit.au3>
Global $hEdit, $aPos, $sText

$hEdit = ControlGetHandle("[CLASS:Notepad]", "", "Edit1")
If $hEdit Then
    $aPos = _GUICtrlEdit_GetSel($hEdit)
    If IsArray($aPos) Then
        $sText = StringMid(_GUICtrlEdit_GetText($hEdit), $aPos[0] + 1, $aPos[1] - $aPos[0])
        ClipPut($sText)
        MsgBox(0, "Text copied to clipboard", $sText)
    Else
        MsgBox(0, "Error", "Error reading selection")
    EndIf
Else
    MsgBox(0, "Error", "Couldn't find Notepad's control")
EndIf

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Link to comment
Share on other sites

Very nice! thank you.

Is there any way to copy the marked text without considering the window the text was written in?

I want to be able to do some actions on a marked text, where ever the user choose to write it. sort of like babylon....

possible?

Thanks again,

Daniel

Link to comment
Share on other sites

Very nice! thank you.

Is there any way to copy the marked text without considering the window the text was written in?

I want to be able to do some actions on a marked text, where ever the user choose to write it. sort of like babylon....

possible?

Thanks again,

Daniel

This may help.

Highlight some text, then press Ctrl + c.

;
Global $sCopied

HotKeySet("^c", "CopyHighLited"); Ctrl + c To get highlighted text
HotKeySet("{ESC}", "Terminate") ; Esc to exit

While 1
    Sleep(10)
WEnd

Func CopyHighLited()
    ControlSend("", "", "", "^c")
    $sCopied = ClipGet()
    MsgBox(4096, "", $sCopied)
EndFunc   ;==>CopyHighLited

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate
;
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...