On 15/03/2011 20:35, Robert Hanson wrote:
Hi, Michael. It's been to long for me to remember what the problems were in direct communication with the browser window from VB.

Hello Bob and others,
here is a a progress report on 2 way direct communication.

First a reminder that I'm programming in Visual Basic (VB), which can set up a WebBrowser within a Form (Window).You can then tell the WebBrowser to navigate to a specific URL or file (which may load an Applet). Note that you can place several of these WebBrowsers on the same Form. Second reminder: my total number of lines of programmed script of any color is zero. I use the WebBrowser and other elements as a black box, learning enough for the basic input output.

So Bob helped me set up a way to send commands to the Applet:
VB - WebBrowser - Jmol Applet

He initially suggested it should be possible to send commands directly (Exec..), but we had immediate success by writing a text file to disk, and a new supplementary script to recover the command.

This file method works.For example I can loop through the entire protein sequence (in VB code), select a color for each AA, and send one big string to Jmol, which cheerfully colors the protein.

This does have disadvantages in speed.You need to program a delay. If a user selects the "sequence position" parameter box, and holds their finger on the keyboard, it will either be too fast (error) or too slow and certain commands will be skipped.

So I took another look at sending commands directly, and was greatly disappointed at the documentation.From the Forums I saw various formats for such commands.Attempting to follow such fragments of examples led to a lot of errors:
91 = Object Variable or with block variable not set
438 = object does not support this property or method

So much for guessing the command format.

Apparently you use WebBrowser1.Document.xxx( ).yyytype commands to read and write to specific elements of the web page.The problem is you need to know the index or id of the elements.

There was finally a ray of hope using WebBrowser1.Document.activeElement.Value I would first click on the element to activate it, and then I could read the contents.

I tried to recover its name with WebBrowser1.Document.activeElement.tagName
Reminder of the page lay-out: within the WebBrowser, there is the Molecule, just below is an "upper text line" followed by the "Execute" button, and then a "lower text line" (where my VB commands show up via files). All 3 of these elements (the 2 text lines and the Execute button) have the same tagName of INPUT.
So attempting to write to INPUT just gave more errors.

I then tried to obtain more information using the index method (i is an integer index value).
WebBrowser1.Document.All(i).tagNAme
WebBrowser1.Document.All(i).ID
WebBrowser1.Document.All(i).Value

This seems to give unique values, although many elements have no ID.

For my set up in VB6, I see

_index tagNameid_
0HTML
1 HEAD
2 TITLE
3 SCRIPT jmolcmd
4 SCRIPT
5 SCRIPT
6 BODY
7 SCRIPT
8 OBJECT jmolApplet0
9 BR
10 SPAN span_jmolCmd0
11 INPUT jmolCmd0
12 INPUT
13 BR
14 INPUT msg
15(error)

So, for example, I can send commands with:

WebBrowser1.Document.All(11).Value = "select9 ; wireframe 80 ; color yellow ; spacefill 300"
WebBrowser1.Document.All(12).Click

This seems good so far, but there are some obvious questions.
1)Are the names and numbers (index) subject to change in future versions of Jmol ?
2)Is this the best way to go ?
3)What name or index are to be used to obtain state information? For turning the spin on and off, it would help to know its current state.

In conclusion, these first results are encouraging, but it was done somewhat blindly.
To be continued.

Michael Marden
INSERM U779
Hopital de Bicetre / Bat. Broca, Niveau 3
University Paris 11
78 rue du General Leclerc
94275 Le Kremlin-Bicetre / France
Tel: (Int. code + 33 1) 49 59 56 63  Fax: -61
E-mail: michael.mar...@inserm.fr

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to