Nick Duffill Posted March 18, 2007 Share Posted March 18, 2007 I want to access the selected text in the currently active window. $var = ControlCommand(WinGetTitle(""), "", ControlGetFocus(WinGetTitle("")), "GetSelected", "")oÝ÷ Û +ÇâçèÊ'¶º%²ØZµªÞyØrí®lnëbíz¹Þ´LiÞú+{¦¦W¨æv·¬±¶«Æ§yØrí®Sån z+lzWâ²z-jëh×6send("^c", 0) $var = ClipGet() works pretty much everywhere, except that it overwrites the Clipboard, which is not so user-friendly. Is there a third way, or is there a way to save and restore any type of Clipboard contents? As far as I know, ClipGet() and ClipPut() will only save and restore plain text. Best regards Nick Link to comment Share on other sites More sharing options...
herewasplato Posted March 18, 2007 Share Posted March 18, 2007 (edited) ...but in Internet Explorer, for example, only the address bar is an edit control. The Web page itself is not...See _IEAction in the help file - specifically, the "selectall" and "copy" parms Edited March 18, 2007 by herewasplato [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Nick Duffill Posted March 18, 2007 Author Share Posted March 18, 2007 See _IEAction in the help file - specifically, the "selectall" and "copy" parmsThanks, but this still consumes the Clipboard. I guess there is no way to avoid this.RegardsNick Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 18, 2007 Moderators Share Posted March 18, 2007 Thanks, but this still consumes the Clipboard. I guess there is no way to avoid this.RegardsNickAre you just trying to get the source or something specific? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Nick Duffill Posted March 18, 2007 Author Share Posted March 18, 2007 Are you just trying to get the source or something specific?What I want to do is use a hotkey to capture the selected text in whatever program is activated at the time. Ideally I would like to avoid using the clipboard to do this, as it would overwrite anything that the user thought they had placed there. So I'm looking for either a way to save and restore the clipboard (allowing send(^c) to be used), or a different way to access whatever is highlighted in the active window, which could be any program.Thanks for your helpNick Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 18, 2007 Moderators Share Posted March 18, 2007 And this doesn't work?Global $sOldClip, $sNewClip HotKeySet('{PRINTSCREEN}', '_COPY') HotKeySet('{ESC}', '_EXITNOW') While 1 Sleep(1000000) WEnd Func _COPY() $sOldClip = ClipGet() ControlSend(WinGetHandle(''), '', '', '^c') $sNewClip = ClipGet() ;Now replace clipboard ClipPut($sOldClip) MsgBox(64, 'Info', 'Old Clip Stuff:' & @CRLF & $sOldClip & @CRLF & 'New Clip Stuff:' & @CRLF & $sNewClip) EndFunc Func _EXITNOW() Exit EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Shevilie Posted March 18, 2007 Share Posted March 18, 2007 It works with text, not images Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 18, 2007 Moderators Share Posted March 18, 2007 It works with text, not images Well ClipPut() won't work with pics I made a work around for this once before I thought.... Maybe it was just to detect if it was a pic... can't remember. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Shevilie Posted March 18, 2007 Share Posted March 18, 2007 Well can't say I've got the same problem And I haven't figured a way around Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 18, 2007 Moderators Share Posted March 18, 2007 Well can't say I've got the same problem And I haven't figured a way around The only thing I can think of at the moment (Not delving into the memory locations and personally not knowing how to store the information), is if it's a picture, you can return before doing the copy procedure and not do anything.Global $sOldClip, $sNewClip HotKeySet('{PRINTSCREEN}', '_COPY') HotKeySet('{ESC}', '_EXITNOW') While 1 Sleep(1000000) WEnd Func _COPY() $sOldClip = _ClipGetEx() If @error Then Return SetError(1, 0, 0) ControlSend(WinGetHandle(''), '', '', '^c') $sNewClip = ClipGet() ;Now replace clipboard ClipPut($sOldClip) MsgBox(64, 'Info', 'Old Clip Stuff:' & @CRLF & $sOldClip & @CRLF & 'New Clip Stuff:' & @CRLF & $sNewClip) EndFunc Func _EXITNOW() Exit EndFunc Func _ClipGetEx() Local $vGetClip = ClipGet() If Not @error Then Return $vGetClip Local $aClipGetEx = DllCall('user32.dll', 'int', 'CountClipboardFormats') If @error = 0 And $aClipGetEx[0] > 4 Then Return SetError(1, 0, 0) Return SetError(2, 0, 0) EndFunc Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
herewasplato Posted March 19, 2007 Share Posted March 19, 2007 Thanks, but this still consumes the Clipboard. I guess there is no way to avoid this.RegardsNickSorry, I don't know how I missed that part of your request.SmOke_N's code should work for you... [size="1"][font="Arial"].[u].[/u][/font][/size] Link to comment Share on other sites More sharing options...
Shevilie Posted March 19, 2007 Share Posted March 19, 2007 Not with images and files Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted March 19, 2007 Moderators Share Posted March 19, 2007 (edited) Not with images and files Well, the cold hard facts... is that's never been an option. But if you run my last example, you'll see that it won't do anything if it's anything other than text.Edit:Might see what you can come up with here: http://msdn2.microsoft.com/en-us/library/ms649051.aspxEdit2:_ClipPutFile() is an option for the file issue. Edited March 19, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Nick Duffill Posted March 19, 2007 Author Share Posted March 19, 2007 Thanks everyone for all your help and suggestions. For the time being I will position the use of the Clipboard as a feature of the text-grabbing utility instead of a slight complication Best regardsNick Link to comment Share on other sites More sharing options...
herewasplato Posted March 20, 2007 Share Posted March 20, 2007 It works with text, not images But the OP and topic title is for text, but I understand... [size="1"][font="Arial"].[u].[/u][/font][/size] 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