open default browser with a post in Delphi
Asked Answered
C

3

8

I know in delphi you can open the default browser with:

ShellExecute(self.WindowHandle,'open','www.website.com',nil,nil, SW_SHOWNORMAL);

but I'm wanting to know if there is a way to automatically post data on the new opened brower window OR auto fill the login data (even in firefox, safari,etc)

Thanks

-Brad

Compulsion answered 16/5, 2010 at 3:4 Comment(0)
G
5

You can launch your browser with OLE, and use the navigate function to pass data and context to the url.

Open IE with OLE

MyBrowser := CreateOleObject('InternetExplorer.Application') as IWebBrowser2;

Send data to url

MyBrowser.Navigate('http://mysite.com', Flags, EmptyParam, PostData, Headers);

See here for an example of navigate function: http://forums.devshed.com/showpost.php?p=2408145&postcount=2

I hope this will help !

Garygarza answered 16/5, 2010 at 6:59 Comment(1)
Didn't want IE only, but that might be my only choice. Thank you for the info.Compulsion
K
2

You need to add "Http://" before the name of the website, otherwise the OS doesn't know what application to open.

ShellExecute(Application.Handle,'open','http://www.bjmsoftware.com',nil,nil, SW_SHOWNORMAL);

works for me in a console application.

Kyat answered 16/5, 2010 at 12:1 Comment(2)
Correct, but his question was if he could specify what data should be POSTed or what fields to fill in.Gaspard
@Lars, yep, saw that after hitting enter and tried to delete my own answer, but it just registers a "vote to delete"...Kyat
G
1

No, it is not possible to POST data with the url or fill in fields using ShellExecute. There is no general API all browsers have to be remote controlled. Alternatives are using GET (encode in the url itself) or talking to specific browsers directly, like TridenT suggests.

Gaspard answered 16/5, 2010 at 12:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.