Using internal browser as a tool

Started by Theno, April 12, 2010, 04:02:17 PM

Previous topic - Next topic

Theno

Hi,

How can I use internal browser as a tool? I want to open the file that I am working on, in the internal browser, with adding some addtional address before the file name. I did it like this for external firefox, but I don't know the command to call the internal browser.

<TOOLS>
<Tool name="firefox" arguments="http://localhost/%Document%" initial_dir="C:\\Program Files (x86)\\Firefox" context_menu="true" key="70" alt="true" command="C:\\Program Files (x86)\\Firefox\\firefox.exe"/>
</TOOLS>


Thanks...

Arthur

Hi Theno,

why don't you use the command line to run a browser of your choice using Tools like:

C:\"Program Files\Internet Explorer"\iexplore.exe -k http://www.somesite.com

the needed extra parameter (the additional address in your case) can come in as something you can configure through the "arguments" using the tool config dialog.
FYI, there is an assortment of options available for the arguments e.g. selected text, selected line, and even interactive inputs.

alex

Just use Context Help items instead : Help -> Syntax Help -> Manage ... to create.
This is a little bit misuse, but will do what you want. You can assign a shortcut, but there will be no toolbar item for it.

Also the way: create a project and add to it URL item. Also shortcut is available and you can then use it icon.

This is relevant if you want to get a preview in internal browser. If this is not important use advise from Arthur.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Theno

#3
@Arthur

Thanks Arthur but I did it already for firefox as you can see at the attachment. I can do the same for ie as well but I want to use internal browser for IE preview.

@Alex

Yes, "syntax help" worked, I created something like at the attachment2. But as you said this is a misuse :)
Can internal browser be assigned to a variable to use as a tool?

Also I need some other variables too. Or it can help if there is a way to do this without additional parameters.

I need a part of the directory structure of the current file.

For example let's say my project main folder is c:\inetpub\wwwroot
and my file's path is c:\inetpub\wwwroot\myproject\myfolder\myasp.asp
So I need the "myproject\myfolder" part as a variable as well and the orientation of slash must be changed. "\" signs must be "/". So my variable must return "myproject/myfolder"

Because, for me to test this file using the server on my pc I need to open this address in any browser.

http://localhost/myproject/myfolder/myasp.asp

I can take the file name with %Document% variable but I couldn't find a variable that will give me the folder structure up to the main project folder with changing the slashes.

Is there a way to do this. Or otherwise can this be added as a variable?

Thanks...

Stefan

This looks like an issue for the upcoming scripting feature.

Right now i guess you can just call an VBScript
with an %HE var%  like %FileName% as parameter
as tool instead of firefox.exe directly

and do the modification of the path inside this script
and at the end do run firefox.exe.
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

alex

QuoteCan internal browser be assigned to a variable to use as a tool?
I do not think this is a good idea. Use internal browser flag is browser specific and  have nothing to do with tools in general. So I do not think that this is a good idea to place it to configuration UI of tools.

QuoteFor example let's say my project main folder is c:\inetpub\wwwroot
and my file's path is c:\inetpub\wwwroot\myproject\myfolder\myasp.asp
So I need the "myproject\myfolder" part as a variable as well and the orientation of slash must be changed. "\" signs must be "/". So my variable must return "myproject/myfolder"
This request is rather specific and it purpose only to give you possibility to view your script server related.
I do not want to add a template for any specific case user have. Taken into account that I plan to introduce functionality to define server in future releases (maybe in 1.5x but not in 1.4x) and tag you request will not be used.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]

Theno

Ok I see, then I hope define server future will be in 1.5 :) In the meantime I try to work around using Stefan's idea.

Thanks...

Stefan

#7
Quote from: Theno on April 12, 2010, 10:06:16 PM
In the meantime I try to work around using Stefan's idea.
Good boy  ;D

If someone is interested:

Start an script with current path\file as parameter,
modify or just use this parameter inside this script:

Example HE tool setting:
Title: you choose one
Command: cScript
Arguments:path\to\your\script.vbs  %FileName%

Example VBS script:
If Wscript.Arguments.Count > 0 Then
strPara = Wscript.Arguments.Item(0)
replaced = replace(strPara,"\","/")
MsgBox "Start FireFox with " & chr(34) & replaced & chr(34)
Else
MsgBox "No parameter given."
End If


Why is the font of the [C O D E] tag always that small?
QuoteIf Wscript.Arguments.Count > 0 Then
   strPara = Wscript.Arguments.Item(0)
   replaced = replace(strPara,"\","/")
   MsgBox "Start FireFox with " & chr(34) & replaced & chr(34)
Else
   MsgBox "No parameter given."
End If

-----------------

Additional tip for testings:

Use %?% somewhere in the Argument field to get prompted the whole command line.
That way you can see if all works as you has expected while you have composed the tool command.

Arguments:path\to\your\script.vbs  %FileName% %?%

-----------------


Picture of working example:
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Theno

Hi Stefan,

Thank you for your interest. Your code was a good start point. I wrote the necessary code but I have a small issue that I wonder if you have an opinion.

I send the file to ie with changing the file path but I don't want to open a new ie window, if the older one is still open. I find and refresh same window but I couldn't find how to restore and bring to front that window if it is minimized.

Do you have an idea?

Also I wonder if I can pass the result of a script to HE as an argument in a way, to use with a tool for example?

Thanks...

Stefan

Quote from: Theno on April 16, 2010, 11:59:23 PMI send the file to ie with changing the file path but I don't want to open a new ie window, if the older one is still open.
I find and refresh same window but I couldn't find how to restore and bring to front that window if it is minimized.

Do you have an idea?
Not right now how to do this with VBS, thought it would be possible, but i would just use AHK AutoHotkey for such tasks.
I will reply with an AHK script later.

Pseudo code:
Command: path\to\AutoHotkey.exe
Arguments:path\to\your\script.ahk  %FileName%

If Arguments.Count > 0 Then
   strPara = Arguments.Item(0)
   replaced = replace(strPara,"\","/")
        If is active iE
             focus iE
             launch URL
        ElseIf
             start iE
             launch URL
Else
   MsgBox "No parameter given."
End If

Quote
Also I wonder if I can pass the result of a script to HE as an argument in a way, to use with a tool for example?
Yes, you can do something like
- putting the result to the clipboard and using HE's var %Clipboard% in the next tool to read the clipboard content, or
- writing the result into an temp file and read this from -,  or use it as parameter for next tool

Maybe Alex want to add this here  > Tools parameter: Output
as an another possibility Output feature as e.g.
Argument: %StoreResult%  in memory for reuse
and reuse this with e.g.
Argument: %StoredResult%


Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Stefan

Hi, sorry for the delay, now back to your request:

If not already known, AutoHotkey (AHK for short) is an scripting tool like DOS batch or VBscript or JavaScript.
An alternative is AutoIt, or KixArt at that time.
You can download it for free. There is an installer for your convenience as an zip archive too for portable use.
IT's only an 300 kB exe ( plus an MB help file and some tools)
If you are not familiar with such things download the installer (www.AutoHotkey.com)
and install it, then you can run an *.ahk script
from everywhere without dealing with the correct path to the AutoHotkey.exe



*I* have just the autohotkey.exe in my HippoEDIT folder and launch it as shown here:

(not tested yet, but should work as expected. I hope i have think about everything?)

Example HE tool setting:
Title: you choose one
Command: %AppDir%\Tools\AutoHotkey.exe
Arguments: %AppDir%\Theno.ahk %FileName%
Init Directory: %FileDir%



Here is an AutoHotkey script for your request:
Quote
/*
For example let's say my project main folder is c:\inetpub\wwwroot
and my file's path is c:\inetpub\wwwroot\myproject\myfolder\myasp.asp
So I need the "myproject\myfolder" part as a variable as well
and the orientation of slash must be changed. "\" signs must be "/".
So my variable must return "myproject/myfolder"

Because, for me to test this file using the server on my pc I need to open this address in any browser.
http://localhost/myproject/myfolder/myasp.asp
*/

;Semicolons indicates comments

; AHK parameter:
#SingleInstance, force
;//////////////////////////////////////////////////////////////////////////////////////////////////



;//Get the parameter given to THIS script by the tool from HippoEDIT
;Example:
;FileName in HippoEDIT:       c:\inetpub\wwwroot\myproject\myfolder\myasp.asp
;HippoEDIT tool Arguments:  path\to\your\script.ahk  "%FileName%"

;TEST only:
myParameter = "c:\inetpub\wwwroot\myproject\myfolder\myasp.asp"

;remove the semicolon from next line to get the real parameter:
; myParameter = %1% 
msgbox ONE: %myParameter%
;//////////////////////////////////////////////////////////////////////////////////////////////////


;//////  do some modifications on that parameter
;//AHK Syntax: StringReplace, OutputVar, InputVar, SearchText [, ReplaceText, ReplaceAll?]

;// remove "c:\inetpub\wwwroot\"
StringReplace, OutputVar, myParameter, c:\inetpub\wwwroot\
msgbox TWO: %OutputVar%

;// replace "\" by "/"
StringReplace, OutputVar, OutputVar,\, /, All

;// remove the quotes
StringReplace, OutputVar, OutputVar,", , All

;// add "http://localhost/"
OutputVar = http://localhost/%OutputVar%
msgbox THREE: %OutputVar%
;///////////////////////////////////////////////////////////////////////////////////////////////////////


;////// decide if there is an iE for reuse or launch an new instance,
;////// then put in the URL and press Enter

;//AHK Syntax: SetTitleMatchMode 2: A window's title can contain 'WinTitle' anywhere
;                       inside it to be a match, like here 'Windows Internet Explorer'.
SetTitleMatchMode, 2

;//AHK Syntax: IfWinExist, 'WinTitle'
IfWinExist, Windows Internet Explorer
{
   ;// uses Last Found Window
   WinActivate
   WinMaximize
   Send, {F4}                  ;focus address bar
   Sleep, 500
   Send, +{Home}           ;select whole last URL for overwriting
   Sleep, 500
   Send {DEL}                ;remove explicit last URL, for correct working
   Send, %OutputVar%   ;paste in new URL
   Send {Enter}              ; press Enter-Key
   return
}

;//ELSE: If no iE runs, launch it:
Run, iexplore.exe  %OutputVar%
WinMaximize
return

; <EOF>
Stefan, HippoEDIT beta tester 
HippoEDIT - the editor programmers wants to code thyself when they are dreaming.        -Don't just edit. HippoEDIT!-

Theno

#11
Hi Stefan,

Thank you but I don't want to use an external tool since I want it to be useful for other web programmers here too. Also I can do the same thing with shell already with SendKeys method.

Code (vb) Select
WshShell.AppActivate "Windows Internet Explorer"
WshShell.SendKeys "(% )X"
WshShell.SendKeys "{F5}"


(% )X maximizes the window and F5 refreshes it. And this works but if the page is not shown as a tab. If it is, this method fails. Maybe it is a Win 7 issue I don't know. Maybe AHK can do it better, I will try it too it seems as an useful tool. But as I said since I want these scripts to be used by other web programmers like ASP, ASP.NET, PHP, JSP etc. I want to keep it simple and not need any other thing to install. So I find and close the older ie page, instead of working on it. But I can use AHK for firefox.

I will publish the scripts in scripting forum.
http://forum.hippoedit.com/index.php/topic,750.msg3287.html#new

Thanks to both of you.

alex

Hi Guys,

just do not spend too much time on this.

As I have said, I will add extra server root that can be used for executing server side scripts and then will check this automatically for preview in Browser (this is not too complex, but it is development request and so it will be done only in 1.50).
Also with scripting in HE it will be possible to configure this better. I hope.

Best regards,
Alex.
HippoEDIT team
[url="http://www.hippoedit.com/"]http://www.hippoedit.com/[/url]