Sign in to follow this  
Followers 0
ubberoinker

Need help with CmdLine

5 posts in this topic

#1 ·  Posted (edited)

I created a simple Browser GUI and have it set as my default browser. I found $CmdLine and which worked somewhat, with the following code whenever I click a link it'll open my compiled script and navigate to the link. 

If $CmdLine[0] > 0 Then
$oIE.navigate($CmdLine[2])
Else
$oIE.navigate("http://google.com")
EndIf

 

Problem is every time I click a link it opens a new instance of the program. How can I make it so it reuses the open instance instead of opening a new one?

Edited by ubberoinker

Share this post


Link to post
Share on other sites



hello ubberoinker, welcome to AutoIt and to the forum!

this is not a problem with $CmdLine (although i can't get why you use $CmdLine[2] instead of $CmdLine[1], but that's your business).

before you "navigate" with the IE object, you need to "attach" to existing browser instance. look at the IE UDF for _IEAttach() or _IECreate().

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hello ubberoinker, welcome to AutoIt and to the forum!

this is not a problem with $CmdLine (although i can't get why you use $CmdLine[2] instead of $CmdLine[1], but that's your business).

before you "navigate" with the IE object, you need to "attach" to existing browser instance. look at the IE UDF for _IEAttach() or _IECreate().

 

Thank you for the welcome! Long time user of AutoIt but have been stumped by this one. I'm probably either way off or missing something obvious.

_ArrayDisplay shows me the $CmdLine array is as follows

Row|Col 0
[0]|2
[1]|-url
 

I'm not having a problem with the Navigating part, When I click a link it will open my MyBrowser.exe and navigate to the URL I clicked on. 

The problem is that every time I click a link it opens a new instance of MyBrowser.exe and navigates to the link. I don't want it to open a new instance but rather reuse the active instance and just navigate to the URL I clicked..

Edited by ubberoinker

Share this post


Link to post
Share on other sites

the $oIE.navigate misled me to believe you are using IE. if that is incorrect, then ignore my previous post.

you need to have your MyBrowser handle the $CmdLine differently. flow like this:

if already another instance running (use _Singleon() ), then

  just write the url to a temp text file, and exit immediately.

endif

main part: instead of:

while running

  do what you do

wend

do this:

while running

  do what you do

  if a temp text file exists, read the url from it and do what you do with it (start new tab?) and delete the temp file

wend

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0