Send data to webpage

I have an AppleScript that will send two strings to an active Webpage with the assumption being they are a username and password.

Does anyone have code that will do the same thing via WIN7?

I haven’t done this for a long time but why wouldn’t you use an http or httpsecure socket to post to your webpage script?
That would be a cross platform solution.

You should use something like php on the server which receives your xojo socket posted data.

This is not a matter of POST or GET… this is having my application TYPE data in .

You can only use POST if the webpage has Javascript, PHP or something similar to accept URL based parameters.

This is the same function that most Password managers have. You call up the webpage… click the mouse in the APP, and the username and password are “typed” into the webpage…

For clarity… I am writing the APP… the webpages are NOT written by, hosted by or controlled by me

[quote=42785:@Dave S]This is not a matter of POST or GET… this is having my application TYPE data in .

You can only use POST if the webpage has Javascript, PHP or something similar to accept URL based parameters.

This is the same function that most Password managers have. You call up the webpage… click the mouse in the APP, and the username and password are “typed” into the webpage…

For clarity… I am writing the APP… the webpages are NOT written by, hosted by or controlled by me[/quote]

Just a thought. If Internet Explorer is OLE aware, could you not do what you want through OLE ?

I don’t think you understand… I need it to be something like “SendKeys”…

Anyone have any insight?

I found this
https://forum.xojo.com/6009-sendkey-function

which looks like it might work… IF I could automatically figure out where the browser window is.

In AppleScript it is each

Tell Application 'Safari'
Activate
keystroke 'this is the data I want to have typed'
keystroke (ASCII character 13)
end tell

[quote=84863:@Dave S]Anyone have any insight?

I found this
https://forum.xojo.com/6009-sendkey-function

which looks like it might work… IF I could automatically figure out where the browser window is.[/quote]

Sendkey refers to the window by its title and works the same as it would in VB. In the example given, “Untitled - Notepad”. You want to launch the browser and see what is the title of the window to send keystrokes to. For a browser, it could often be “Google”.

It is tricky if you want to make it a generic app that works with every configuration. If I remember right, Xojo has a way of detecting all the windows displayed on the user computer at a given time, but I could not find that in the documentation.

Yes… that is the issue… AppleScript “knows” where the browser window is (not sure what happens if you have multiple… but it seems for Window … YOU have to know… (or have some way for the app to figure it out ahead of the sendkeys)

AppleScript addresses the program by name. Windows addresses the program by the title of its window.

You could use this trick :

  • Prepare an html document with your token title “DSTitle” or something unique.
  • Folderitem.launch the file to open the default browser
  • send keys to “DSTitle”

You can make your page an iFrame to make sure to keep the same title throughout the browsing session.

Great Idea… but won’t fit the paradigm of the app.

It is a password manager (actually it is a LOT more than just that…but this feature is for the PW part).

Given a URL, Username and Password (in strings).
Launch the users default Browser (outside of my app), go to the webpage (easy with ShowURL)
[it is at this point I would need Windows to find the NAME of the window it just opened]
then send the Username/Password (of course the assumption will be that UN and PW are the first two fields as the app will be “blind”)

I have code in AppleScript to do this already…

[quote=84900:@Dave S]Great Idea… but won’t fit the paradigm of the app.

It is a password manager (actually it is a LOT more than just that…but this feature is for the PW part).

Given a URL, Username and Password (in strings).
Launch the users default Browser (outside of my app), go to the webpage (easy with ShowURL)
[it is at this point I would need Windows to find the NAME of the window it just opened]
then send the Username/Password (of course the assumption will be that UN and PW are the first two fields as the app will be “blind”)

I have code in AppleScript to do this already…[/quote]

If the PW site you go to has a fixed title, open it in your browser, note the title and readily use it. Right ?

I see several problems, though, all related to the address by titlebar :

  • What is the titlebar for a tabbed application such as Chrome ? Is it the current tab title, or something else ? Hopefully it is the tab title and the current tab will receive the sendkeys. You need to experiment.
  • How are you going to move into the site ? Usually, title changes with navigation. This would break the sendkeys.
  • Even if you carefully plan your navigation and all the titles that come with it, any dynamic title will break your code.

Apparently VB has a way to send to the active application, described here :
http://msdn.microsoft.com/en-us/library/ms172702.aspx

Now how to do that in Xojo is a whole other story. Maybe a C plugin ?

I have no idea ahead of time what websites the user might add to the database… nor do I know what browser they may have installed…

So how do you know which keys will have to be sent ? Are you recording them for later replay ? Just curious…

the keys to be sent are the USERNAME and PASSWORD the the user previously entered in the database, along with the URL for the website.

So… I have a URL , and Username and a Password…
I can launch the website… and with Applescript I can send the username and password … there is the assumption that those are the first two fields on the webpage… and I’m good with that assumption.

[quote=84972:@Dave S]the keys to be sent are the USERNAME and PASSWORD the the user previously entered in the database, along with the URL for the website.

So… I have a URL , and Username and a Password…
I can launch the website… and with Applescript I can send the username and password … there is the assumption that those are the first two fields on the webpage… and I’m good with that assumption.[/quote]

You could use the URL to download the source of the page, fetch the title, and assume it will be the title of the browser when you launch the browser. Then sendkeys to the browser.

I just did a quick test : the code posted at https://forum.xojo.com/6009-sendkey-function works just as the VB SendKeys and correctly activates the app window. The app must already be running. I used one of my sites for the test : the title of Chrome is indeed the title of the page, and Chrome window title is the title of the current tab. It works, at the condition that the web form sets the focus correctly. For some pages, you may need to send a tab character first to position the carret into the first field.

Seems that IE8 or whatever comes with Win7 has no “visible” title…

I use Win 7 64 bit and IE is 11. 8 sounds very old.

I ran a test with IE11, though : the name of the window is not just the title of the site. They add " - Internet Explorer" to it. So “Google” becomes “Google - Internet Explorer”. Your IE 8 probably does the same. A test will show you if the window is correctly activated.

The “Internet Explorer” suffix could be an issue since Chrome does not append anything to the page title. Don’t know about Firefox. Then the problem becomes to be able to know what the title of the window will be according to the default browser program. Maybe you can check in the registry which browser is default and then decide accordingly ?

Turns out I have IE11.08 (but the top of the screen area has the Min/Max/Close buttons in the right… but no TITLE (unless you count a small white box to the right of the address bar)…

But I have decided that downloading the page, scraping the title, hoping that is the correct value to find the window and then MAYBE being able to send the UN and PW to the right place is not worth doing that way.

I cannot believe there is not a simpler way, I mean almost every commerical Password Manager out there seems to be able to do this with a high degree of accuracy (or am I just “assuming” the accuracy is high???)

Keep in mind that the fields that are used by web developers for username and password are not necessarily named as such and are often not the only fields on the page. Also, these things tend to change when a site gets a redesign.