Jump to content

Open links in any web browser


 Share

Go to solution Solved by mikell,

Recommended Posts

Hi All,
 
I have created a GUI interface tool that launched a bunch of different tasks for the employees here at my office. One of the buttons launches an HTML page that that takes them to an IE page with a bunch of links on them. This was scripted using the IE.au3. However, recently I was asked if I could have it open in their default browser, I.E, Chrome, FireFox, etc. Is there a simple way I can make this conversion. I have seen that there are other UDF files for FireFox and Chrome, but I am not quite sure the easiest way to do this would be. Do I need to make 3 separate source pages, one for each browser or is there a way I can use my existing code to open up the default browser?
 
I know running ShellExecute() will do this but maybe I just have my code wrong as I don't see where I could implement the ShellExecute function with my current code.
 
I stripped down my GUI to just include the button in question and placed some dummy data into the links I would be opening. I also included the same sample as an attachment. Any help on this would be greatly appriciated.
 

#NoTrayIcon
#RequireAdmin
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2013 All Rights Reserved. AutoIt v3
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
;~ #AutoIt3Wrapper_Run_Tidy=y
;~ #Tidy_Parameters=/pr=1 /bdir /rerc
#endregion

#region #include ;**** #include .au3 files
#include <GuiConstants.au3>
#include <EditConstants.au3 >
#include <GuiButton.au3>
#include <IE.au3>
#include <Array.au3>
#include <Misc.au3>
#include <Process.au3>
#include <GuiToolBar.au3>
#include <RefreshSystemTray.au3>
#endregion

#region Opt ;**** Script Option settings
Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled
#endregion

#region Global Variables ;**** Global Environment Variable Callouts and Script Settings
; ---------
; Global Variables called out in all functions
; ---------
Global $Username = @UserName ;****Looks for logged in user on computer

#endregion

#region Runtime
; -------
; Runtime
; -------
_MainMenu()


While 1
    Sleep(50)
WEnd
#endregion

#region Functions ;**** Triggered by #Region Runtime
;~ ---------
;~ Functions
;~ ---------
Func _MainMenu()
;~ GUI Interface Dimensions
    $GUIWidth = 450 ; Width of GUI _MainMenu() Box
    $GUIHeight = 250 ; Height of GUI _MainMenu() Box

;~ GUI Interface Controls
    $GUI = GUICreate("CS Tool - " & $Username & "", $GUIWidth, $GUIHeight, (@DesktopWidth - $GUIWidth) / 2, (@DesktopHeight - $GUIHeight) / 2) ;Create GUI _MainMenu() Box
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;Closes GUI _MainMenu()
    ; ===================================================================
;~ **** GUI Button Layout
;~ GUI Button for displaying AllSiteManagement Links
    GUICtrlCreateLabel("Site Management Links", 220, 140, 175, 25)
    $ButtonCurrentEV = GUICtrlCreateButton("All Site Links", 220, 160, 150, 25)
    GUICtrlSetOnEvent(-1, "_AllSiteManagement")
    GUISetState(@SW_SHOW, $GUI)
    ; ===================================================================
EndFunc ;==>_MainMenu

Func _Exit() ;Exits Application
    Exit
EndFunc   ;==>_Exit

#region HTML Site Management Page List
;~ ****HTML SITE MANAGEMENT LIST
Func _AllSiteManagement() ;Opens a web page list of all the Site Management Pages to navigate to. Located in File Menu
    Local $s_html = "", $o_object
    $s_html &= "<HTML>" & @CR
    $s_html &= "<HEAD>"
    $s_html &= "<TITLE>Site Management List</TITLE>"
    $s_html &= "<STYLE>body {font-family: Arial}</STYLE>"
    $s_html &= "</HEAD>"
    $s_html &= "<BODY>"
    $s_html &= "<table border=0 id='tableOne' cellspacing=5>"
    $s_html &= "<tr>"
    $s_html &= "    <td align=center><b>Site Management Page & External Link</b></td>"
    $s_html &= "</tr><tr></tr><tr></tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td>Google</td>"
    $s_html &= "</tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td><a href='http://espn.go.com/sports/' target=_blank>ESPN Site 1</a></td>"
    $s_html &= "    <td><a href='http://espn.go.com/nfl/' target=_blank>ESPN Site 2</a></td>"
    $s_html &= "</tr><tr></tr><tr></tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td>Yahoo</td>"
    $s_html &= "</tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td><a href='http://yahoo.com' target=_blank>Yahoo Site 1</a></td>"
    $s_html &= "    <td><a href='http://sports.yahoo.com/' target=_blank>Yahoo Site 2</a></td>"
    $s_html &= "</tr><tr></tr><tr></tr>"
    $s_html &= "</table>"
    $s_html &= "</BODY>"
    $s_html &= "</HTML>"
    $o_object = _IECreate()
    _IEDocWriteHTML($o_object, $s_html)
EndFunc   ;==>_AllSiteManagement
;~ ****END HTML SITE MANAGEMENT LIST
#endregion

Sample GUI.au3

Link to comment
Share on other sites

  • Solution

You could use a tempfile to put your html code and shellexecute it

#NoTrayIcon
#RequireAdmin
#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Res_LegalCopyright=Copyright 2013 All Rights Reserved. AutoIt v3
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
;~ #AutoIt3Wrapper_Run_Tidy=y
;~ #Tidy_Parameters=/pr=1 /bdir /rerc
#endregion

#region #include ;**** #include .au3 files
#include <GuiConstants.au3>
#include <EditConstants.au3 >
#include <GuiButton.au3>
#include <IE.au3>
#include <Array.au3>
#include <Misc.au3>
#include <Process.au3>
#include <GuiToolBar.au3>
;#include <RefreshSystemTray.au3>
#endregion

#region Opt ;**** Script Option settings
Opt("GUIOnEventMode", 1) ;0=disabled, 1=OnEvent mode enabled
#endregion

#region Global Variables ;**** Global Environment Variable Callouts and Script Settings
; ---------
; Global Variables called out in all functions
; ---------
Global $Username = @UserName ;****Looks for logged in user on computer

#endregion

#region Runtime
; -------
; Runtime
; -------
_MainMenu()


While 1
    Sleep(50)
WEnd
#endregion

#region Functions ;**** Triggered by #Region Runtime
;~ ---------
;~ Functions
;~ ---------
Func _MainMenu()
;~ GUI Interface Dimensions
    $GUIWidth = 450 ; Width of GUI _MainMenu() Box
    $GUIHeight = 250 ; Height of GUI _MainMenu() Box

;~ GUI Interface Controls
    $GUI = GUICreate("CS Tool - " & $Username & "", $GUIWidth, $GUIHeight, (@DesktopWidth - $GUIWidth) / 2, (@DesktopHeight - $GUIHeight) / 2) ;Create GUI _MainMenu() Box
    GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") ;Closes GUI _MainMenu()
    ; ===================================================================
;~ **** GUI Button Layout
;~ GUI Button for displaying AllSiteManagement Links
    GUICtrlCreateLabel("Site Management Links", 220, 140, 175, 25)
    $ButtonCurrentEV = GUICtrlCreateButton("All Site Links", 220, 160, 150, 25)
    GUICtrlSetOnEvent(-1, "_AllSiteManagement")
    GUISetState(@SW_SHOW, $GUI)
    ; ===================================================================
EndFunc ;==>_MainMenu

Func _Exit() ;Exits Application
    Exit
EndFunc   ;==>_Exit

#region HTML Site Management Page List
;~ ****HTML SITE MANAGEMENT LIST
Func _AllSiteManagement() ;Opens a web page list of all the Site Management Pages to navigate to. Located in File Menu
    Local $s_html = ""
    $s_html &= "<HTML>" & @CR
    $s_html &= "<HEAD>"
    $s_html &= "<TITLE>Site Management List</TITLE>"
    $s_html &= "<STYLE>body {font-family: Arial}</STYLE>"
    $s_html &= "</HEAD>"
    $s_html &= "<BODY>"
    $s_html &= "<table border=0 id='tableOne' cellspacing=5>"
    $s_html &= "<tr>"
    $s_html &= "    <td align=center><b>Site Management Page & External Link</b></td>"
    $s_html &= "</tr><tr></tr><tr></tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td>Google</td>"
    $s_html &= "</tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td><a href='http://espn.go.com/sports/' target=_blank>ESPN Site 1</a></td>"
    $s_html &= "    <td><a href='http://espn.go.com/nfl/' target=_blank>ESPN Site 2</a></td>"
    $s_html &= "</tr><tr></tr><tr></tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td>Yahoo</td>"
    $s_html &= "</tr>"
    $s_html &= "<tr>"
    $s_html &= "    <td><a href='http://yahoo.com' target=_blank>Yahoo Site 1</a></td>"
    $s_html &= "    <td><a href='http://sports.yahoo.com/' target=_blank>Yahoo Site 2</a></td>"
    $s_html &= "</tr><tr></tr><tr></tr>"
    $s_html &= "</table>"
    $s_html &= "</BODY>"
    $s_html &= "</HTML>"
    FileDelete(@tempdir & "\test.htm")
    FileWrite(@tempdir & "\test.htm", $s_html)
    ShellExecute(@tempdir & "\test.htm")
EndFunc   ;==>_AllSiteManagement
;~ ****END HTML SITE MANAGEMENT LIST
#endregion
Edited by mikell
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...