Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex question, are you up to it?

Status
Not open for further replies.

Pendulum

Computer
Jan 28, 2003
2
0
0
CA
Just joined so I could ask this tough question. I work for a company and we use Zope. Problem with Zope is no IDE, you have to use a browser to access it. I'm trying to design a program in VB6 to speed up typing certain things.

Now the problem:

If you select text in a TextArea in the browser (IE, Mozilla, or Netscape) I'm trying to find a way to grab that selected text. As of right now I'll end up using keybd_event to send information so it gets inserted into that TextArea, and the clipboard (making a person copy the selected text there first) to get the selected text. If anyone knows a way to grab the selected text from the TextArea and possibly even write to the TextArea at the current cursor position I would really love to know.

I've searched the net and can't find anything online to help me at all.

Thanks in advance to anyone who responds!
 
Replies continue below

Recommended for you

Hi dyerger,

It's an idea, but it wouldn't work because of how Zope works. Say you have a page index_html, to edit that in Zope you point a browser to the management of that page. The text in the TextArea where you are typing (adding and changing code) doesn't save the page until you tell it to. So if you tried to grab the page that way you'd get the code as of the last save. I need something that can get into the browser, into that TextArea and work in there.

Thanks for trying though.
 
Have you tried using Window API's, all objects displayed are windows (your textbox is a window, inside your browser window), and each have their own 'handle'. Using this handle you can then access the text box in question.



 
One of the scripts copies into textarea and the other copies
from textarea (HTML page). Also there are a lot of scripts on the net regarding TEXTAREA.

***************************************************
The following script allows you to select text on a web page and then copy it into a text box.

<HEAD>
<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin
function copyit(theField) {
var selectedText = document.selection;
if (selectedText.type == 'Text') {
var newRange = selectedText.createRange();
theField.focus();
theField.value = newRange.text;
} else {
alert('select a text in the page and then press this button');
}
}
</script>
</HEAD>
<BODY>
<form name=&quot;it&quot;>
<div align=&quot;center&quot;>
<input onclick=&quot;copyit(this.form.select1)&quot; type=&quot;button&quot; value=&quot;Press to copy the highlighted text&quot; name=&quot;btnCopy&quot;>
<p>
<textarea name=&quot;select1&quot; rows=&quot;4&quot; cols=&quot;45&quot;></textarea>
</div>
</form>
</body>

************************************ OR
//Grab form field text
<HEAD>
<SCRIPT LANGUAGE='JavaScript'>
<!--
function aceGrabText(fieldName){
fieldName.focus();
fieldName.select();
}
-->
</SCRIPT>

</HEAD>
<BODY>
<A href=&quot;javascript:aceGrabText(document.form1.field1)&quot;>Click to Select</A>

<FORM name=&quot;form1&quot;>
<textarea rows=&quot;12&quot; cols=&quot;62&quot; name=&quot;field1&quot;>Text goes here.</textarea>
</FORM>

</BODY
 
Status
Not open for further replies.
Back
Top