ubberoinker Posted March 28, 2014 Posted March 28, 2014 (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 March 28, 2014 by ubberoinker
orbs Posted March 28, 2014 Posted March 28, 2014 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(). Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
ubberoinker Posted March 28, 2014 Author Posted March 28, 2014 (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 [2]|http://urliclicked.com 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 March 28, 2014 by ubberoinker
Solution orbs Posted March 28, 2014 Solution Posted March 28, 2014 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 Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
ubberoinker Posted March 28, 2014 Author Posted March 28, 2014 So simple yet exactly what I needed. I had played with _Singleton never thought to write a temp file. If _Singleton("MyBrowser", 1) = 0 Then FileWrite("temp.txt", $CmdLine[2]) Exit EndIf If FileExists("temp.txt") Then $oIE.navigate(FileRead("temp.txt")) FileDelete("temp.txt") EndIf Thank you, orbs!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now