By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,780 Members | 1,549 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,780 IT Pros & Developers. It's quick & easy.

controlling another application via VBA or javascript code in Excell & sending keystrokes & mouse clicks

P: n/a
I am running Excel2000 under WIN98 2nd edition, and I am writing a VBA
code (I will consider using javascript if I have to) that does the
following, at the user command:
1- Start MS Explorer and go to my website. Login (enter ID and
Password)
2- It will go and update some prices of some products that I sell
3- It will add new products or cancel some product

I already have someone who wrote me in JavaScript a web form (no
documentation what so ever) residing at my wensite, that I enter the
product ID then I press the enter key. Then it will take me to another
web form with multiple hyperlinks and buttons. Each is for certain
task, so I will click with the mouse (no keyboard shortcut, but focus
can be done with Tab key) on the hyperlink with price update. So it
takes me to another web form where there is a small box with the
price, so I click at it with the mouse and change the price. Then with
the mouse I click on a button "FINISHED" (there are three buttons,
none of which uses key board). This takes me to another web form where
I can select other tasks, such as change product limited time
discount, or some description etc. At the bottom of this form there
are two buttons "Cancel" "Update" so I click on "Update". All this is
to change one thing, I have to do this about 40 times a day since I
have added more products and I keep changing the prices or change time
driven special discounts, and others as needed.
I have read under DDE how to pass KEYSTROKES, which seems to be a
crude way, but might be ok. I know that if I pass the TAB key until
the button is highlighted, then send the "enter" keystroke, will work.
But this will not work with clicking on a hyperlink. I also, checked
sending mouse click with (x, y) coordinates, but I think it is not
reliable. There is also the timing issue whether the web form is
completely loaded or not, whether I send the keystrokes too fast. Or
even the wed form is taking too much time to load, where it is best to
terminate it and start another one.

So my question is, is there a way that I can reliably and effectively
get my task done. I read about OLE & ActiveX, and all they explain
about how to control my MS explorer, which is really not what I want.
I want to control the form (the code inside the web page), to make it
think I have clicked on this button or that hyperlink, or entered data
in a text box.

Sorry for the lengthy details.
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
There is no real good way of doing this in JavaScript. Maybe through
the MS scripting host, but I'm not sure.

However if you have access to that webserver, it is not at all
weird to make a webpage that inserts the codes you want.

1. From Excel start IE and direct it to a webpage with the parameters
to insert. for example:

explore.exe http://www.mysite.com/enter.html?productId=xyz&price=1

2. Now enter.html will read those parameters and put them in a hidden
form. The form complies to the normal form you would use to enter
the values, except that this form would read the values that come
with the query (productId=xyz&price=1) and put them in the right fields.

This could easly be done with ASP, JSP, PHP and could even be done in
JavaScript.

3. After the page is complete you submit it to the page that would
normally store the input on the site after the submit.

Though ofcourse, there must be easier ways of doing this.

Good luck,
Vincent
Zaidan wrote:
I am running Excel2000 under WIN98 2nd edition, and I am writing a VBA
code (I will consider using javascript if I have to) that does the
following, at the user command:
1- Start MS Explorer and go to my website. Login (enter ID and
Password)
2- It will go and update some prices of some products that I sell
3- It will add new products or cancel some product

I already have someone who wrote me in JavaScript a web form (no
documentation what so ever) residing at my wensite, that I enter the
product ID then I press the enter key. Then it will take me to another
web form with multiple hyperlinks and buttons. Each is for certain
task, so I will click with the mouse (no keyboard shortcut, but focus
can be done with Tab key) on the hyperlink with price update. So it
takes me to another web form where there is a small box with the
price, so I click at it with the mouse and change the price. Then with
the mouse I click on a button "FINISHED" (there are three buttons,
none of which uses key board). This takes me to another web form where
I can select other tasks, such as change product limited time
discount, or some description etc. At the bottom of this form there
are two buttons "Cancel" "Update" so I click on "Update". All this is
to change one thing, I have to do this about 40 times a day since I
have added more products and I keep changing the prices or change time
driven special discounts, and others as needed.
I have read under DDE how to pass KEYSTROKES, which seems to be a
crude way, but might be ok. I know that if I pass the TAB key until
the button is highlighted, then send the "enter" keystroke, will work.
But this will not work with clicking on a hyperlink. I also, checked
sending mouse click with (x, y) coordinates, but I think it is not
reliable. There is also the timing issue whether the web form is
completely loaded or not, whether I send the keystrokes too fast. Or
even the wed form is taking too much time to load, where it is best to
terminate it and start another one.

So my question is, is there a way that I can reliably and effectively
get my task done. I read about OLE & ActiveX, and all they explain
about how to control my MS explorer, which is really not what I want.
I want to control the form (the code inside the web page), to make it
think I have clicked on this button or that hyperlink, or entered data
in a text box.

Sorry for the lengthy details.


Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.