danibar Posted August 6, 2009 Share Posted August 6, 2009 hi all, I want to put inside a variable the text I'm currently marking. theoreticaly it should be possible by stimulatin CTRL+C, but I want to know if there is any other way. Thanks, Daniel Link to comment Share on other sites More sharing options...
Skruge Posted August 6, 2009 Share Posted August 6, 2009 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 More sharing options...
danibar Posted August 6, 2009 Author Share Posted August 6, 2009 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 Link to comment Share on other sites More sharing options...
Skruge Posted August 6, 2009 Share Posted August 6, 2009 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 More sharing options...
danibar Posted August 7, 2009 Author Share Posted August 7, 2009 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 More sharing options...
Malkey Posted August 7, 2009 Share Posted August 7, 2009 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 More sharing options...
danibar Posted August 7, 2009 Author Share Posted August 7, 2009 thank you very much! I didn't now the control send function... Thanks Daniel 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