Jump to content

Recommended Posts

Posted (edited)

Ok, in another thread, I said I'll try to get Simple Web Browser to work without have to use the IE UDF. And I managed to get GuiConstants.au3 out too.

Source:

#NoTrayIcon
#Include <INet.au3>
#Include <String.au3>

Global $oIE = ObjCreate("Shell.Explorer.2")
Global $ini = @ScriptDir & "\swb.ini"

Global $read_height = IniRead($ini, "Display", "Height", "")
Global $read_width = IniRead($ini, "Display", "Width", "")
Global $read_homepage = IniRead($ini, "Settings", "Homepage", "")
Global $read_starthomepage = IniRead($ini, "Settings", "StartHomepage", "")

If $read_height = "" Then
    IniWrite($ini, "Display", "Height", "600")
    IniWrite($ini, "Display", "Width", "800")
    $read_height = 600
    $read_width = 800
EndIf

If $read_starthomepage = "" Then
    $read_starthomepage = "1"
    $read_homepage = "www.autoitscript.com/forum"
EndIf

$iniread = IniRead($ini, "URL", "LAST URL", " ")
If $read_starthomepage = "0" Then $read_homepage = $iniread


$gui_main = GUICreate("", $read_width, $read_height + 20, -1, -1, 0x04000000 + 0x00CF0000)

$file_menu = GUICtrlCreateMenu("File")
$fm_newwind = GUICtrlCreateMenuItem("New Window", $file_menu)
$fm_sep = GUICtrlCreateMenuItem("", $file_menu)
$fm_open = GUICtrlCreateMenuItem("Open", $file_menu)
$fm_sep = GUICtrlCreateMenuItem("", $file_menu)
$fm_print = GUICtrlCreateMenuItem("Print", $file_menu)
$fm_sep = GUICtrlCreateMenuItem("", $file_menu)
$fm_savas = GUICtrlCreateMenuItem("Save As", $file_menu)
$fm_SaveSource = GUICtrlCreateMenuItem("Save Source", $file_menu)
$fm_sep = GUICtrlCreateMenuItem("", $file_menu)
$fm_exit = GUICtrlCreateMenuItem("Exit", $file_menu)

$view_menu = GUICtrlCreateMenu("View")
$vm_status = GUICtrlCreateMenuItem("Status Bar", $view_menu)
GUICtrlSetState(-1, 1)

$tool_menu = GUICtrlCreateMenu("Tools")
$tm_pref = GUICtrlCreateMenuItem("Preferences", $tool_menu)
$tm_sep = GUICtrlCreateMenuItem("", $tool_menu)
$tm_ru = GUICtrlCreateMenuItem("Random URL", $tool_menu)
$tm_sep = GUICtrlCreateMenuItem("", $tool_menu)
$tm_gu = GUICtrlCreateMenuItem("Get Current URL", $tool_menu)

$about_menu = GUICtrlCreateMenu("About")
$am_about = GUICtrlCreateMenuItem("About", $about_menu)

$gui_iewindow = GUICtrlCreateObj($oIE, 0, 0, $read_width, $read_height - 45)
GUICtrlSetResizing($gui_iewindow, 0x0001)

$address_bar_label = GUICtrlCreateLabel("Enter Address: ", 0, 562, 85, -1)
$address_bar_input = GUICtrlCreateInput($read_homepage, 76, 559, 200, -1)
$address_bar_go = GUICtrlCreateButton("Go >>", 280, 557, 50, -1, 0x0001)
$address_bar_stop = GUICtrlCreateButton("Stop", 330, 557, 50, -1)
$address_bar_back = GUICtrlCreateButton("Back", 380, 557, 50, -1)
$address_bar_forward = GUICtrlCreateButton("Forward", 430, 557, 50, -1)
$address_bar_refresh = GUICtrlCreateButton("Refresh", 480, 557, 50, -1)
$address_bar_home = GUICtrlCreateButton("Home", 530, 557, 50, -1)
$address_bar_speak = GUICtrlCreateButton("Speak", 580, 557, 50, -1)

$status_bar = GUICtrlCreateLabel("Loading: " & $read_homepage & "...", 0, 584, $read_width, $read_height, BitOR(11, 0x1000))

GUISetState()

AnimateTitle($gui_main, "Simple Web Browser 3.0 - Created by Justin Reno", 100)
$oIE.Navigate ($read_homepage)

$gui_pref = GUICreate("Preferences", 298, 230, 359, 233)
$group1 = GUICtrlCreateGroup("Settings", 16, 16, 265, 170)
$label_home = GUICtrlCreateLabel("Homepage:", 32, 40, 59, 17)
$input_add = GUICtrlCreateInput($read_homepage, 96, 40, 161, 21)
$label_start = GUICtrlCreateLabel("On Startup:", 32, 80, 58, 17)
$combo_startup = GUICtrlCreateCombo("", 96, 80, 161, 25)
If $read_starthomepage = "0" Then
    GUICtrlSetData(-1, "Start with Homepage|Start with Last Visited", "Start with Last Visited")
Else
    GUICtrlSetData(-1, "Start with Homepage|Start with Last Visited", "Start with Homepage")
EndIf
#cs
    $pref_Status_Status = GUICtrlCreateLabel("Display Width", 32, 110, 58, 71)
    $pref_width_input = GUICtrlCreateInput($read_width, 80, 115, 58, 20)
    $pref_height_label = GUICtrlCreateLabel("Display Height", 32, 140, 58, 71)
    $pref_height_input = GUICtrlCreateInput($read_height, 80, 145, 58, 20)
#ce
$button_apply = GUICtrlCreateButton("Apply", 120, 190, 75, 25, 0)
$button_close = GUICtrlCreateButton("Close", 208, 190, 75, 25, 0)
GUISetState(@SW_HIDE, $gui_pref)

While 1
    WinSetTitle($gui_main, "", "Simple Web Browser 3.0 - Created by Justin Reno - " & $oIE.locationURL ())
    
    If $oIE.Busy () Then
        $url = $oIE.LocationURL ()
        _StatusChange("Loading: " & $url & "...")
    Else
        _StatusChange("Done.")
    EndIf

    $msg = GUIGetMsg(1)
    Switch $msg[0]
        Case - 3
            $update = $oIE.LocationURL ()
            IniWrite($ini, "URL", "LAST URL", $update)
            FileDelete(@TempDir & "\SWBHelpFile.exe")
            Exit
            ;File Menu
        Case $fm_newwind
            ShellExecute(@ScriptFullPath)
        Case $fm_open
            Local $file = FileOpenDialog("Simple Web Browser 3.0 : Select file", @ScriptDir, "All Files (*.*)")
            If @error <> 1 Then
                _StatusChange("Loading: " & $file & "...")
                $oIE.Navigate ($file)
            EndIf
        Case $fm_print
            $oIE.document.parentwindow.Print ()
        Case $fm_savas
            $oIE.document.execCommand ("SaveAs")
        Case $fm_SaveSource
            $IE = _INetGetSource("" & $update & "")
            FileWrite(@DesktopDir & "\websource.html", $IE)
            MsgBox(0, "Simple Web Browser 3.0", "Saved to desktop as websource.html")
        Case $fm_exit
            $update = $oIE.LocationURL ()
            IniWrite($ini, "URL", "LAST URL", $update)
            Exit
            ;View Menu
        Case $vm_status
            $size = WinGetPos("Simple Web Browser")
            If BitAND(GUICtrlRead($vm_status), 1) = 4 Then
                GUICtrlSetState($vm_status, 4)
                GUICtrlSetState($status_bar, 32)
                WinMove("Simple Web Browser", "", $size[0], $size[1], $size[2], $size[3] - 15)
            Else
                GUICtrlSetState($vm_status, 1)
                GUICtrlSetState($status_bar, 16)
                WinMove("Simple Web Browser", "", $size[0], $size[1], $size[2], $size[3] + 15)
            EndIf
        Case $tm_pref
            GUISetState(@SW_SHOW, $gui_pref)
        Case $tm_ru
            _Random()
        Case $tm_gu
            $update = $oIE.LocationURL ()
            MsgBox(0, "Simple Web Browser 3.0", "URL:" & $update & "")
            ClipPut($update)
        Case $button_close
            GUISetState(@SW_HIDE, $gui_pref)
        Case $button_apply
            ;$getwidth = GUICtrlRead($pref_width_input)
            ;$getheight = GUICtrlRead($pref_height_input)
            ;IniWrite($ini, "Display", "Width", $getwidth)
            ;IniWrite($ini, "Display", "Height", $getheight)
            $gethome = GUICtrlRead($input_add)
            $getstarthome = GUICtrlRead($combo_startup)
            If $getstarthome = "Start with Homepage" Then
                IniWrite($ini, "Settings", "StartHomepage", "1")
            Else
                IniWrite($ini, "Settings", "StartHomepage", "0")
            EndIf
            IniWrite($ini, "Settings", "Homepage", $gethome)
            GUISetState(@SW_HIDE, $gui_pref)
            _StatusChange("Configuration written successfully.")
            sleep(1000)
            ;About Menu
        Case $am_about
            FileDelete(@TempDir & "\SWBHelpFile.exe")
            InetGet("http://h1.ripway.com/mrreno/SWBHelpFile.exe", @TempDir & "\SWBHelpFile.exe", 1, 0)
            ShellExecute(@TempDir & "\SWBHelpFile.exe")
            ;Address Bar Buttons
        Case $address_bar_go
            $addy = GUICtrlRead($address_bar_input)
            _StatusChange("Loading: " & $addy & "...")
            $oIE.Navigate ($addy)
            _StatusChange("Done.")
        Case $address_bar_stop
            $oIE.Stop ()
        Case $address_bar_back
            $oIE.GoBack ()
        Case $address_bar_forward
            $oIE.GoForward ()
        Case $address_bar_refresh
            $oIE.document.execCommand ("Refresh")
        Case $address_bar_home
            $read_homepageini = IniRead($ini, "Settings", "Homepage", "")
            $oIE.Navigate ($read_homepageini)
            GUICtrlSetData($address_bar_input, $read_homepage)
        Case $address_bar_speak
            Dim $voice = ObjCreate("Sapi.SpVoice")
            Speak($oIE.document.selection.createRange.text & @CR, 0, 100)
    EndSwitch
WEnd

Func _StatusChange($message)
    GUICtrlSetData($status_bar, $message)
EndFunc   ;==>_StatusChange

Func Speak($text, $Rate, $Volme)
    $voice.Rate = $Rate
    $voice.Volume = $Volme
    $voice.Speak($text)
EndFunc   ;==>Speak

Func _Random()
    $Ranpg = Random(1, 18, 1)
    Switch $Ranpg
        Case 1
            $oIE.Navigate ("www.google.com")
        Case 2
            $oIE.Navigate ("www.youtube.com")
        Case 3
            $oIE.Navigate ("www.justinreno.tk")
        Case 4
            $oIE.Navigate ("www.autoitscript.com")
        Case 3
            $oIE.Navigate ("www.autoitscript.com/forum")
        Case 6
            $oIE.Navigate ("www.answers.com")
        Case 7
            $oIE.Navigate ("www.swbforum.tk")
        Case 8
            $oIE.Navigate ("http://www.youtube.com/watch?v=0dBu5X3TvNw")
        Case 9
            $oIE.Navigate ("http://www.youtube.com/watch?v=PSYxT9GM0fQ")
        Case 10
            $oIE.Navigate ("www.familyguy.com")
        Case 11
            $oIE.Navigate ("www.jareno18forums.tk")
        Case 12
            $oIE.Navigate ("about:blank")
        Case 13
            $oIE.Navigate ("www.msn.com")
        Case 14
            $oIE.Navigate ("www.microsoft.com")
        Case 15
            $oIE.Navigate ("www.apple.com")
        Case 16
            $oIE.Navigate ("http://www.youtube.com/watch?v=nsCXZczTQXo")
        Case 17
            $oIE.Navigate ("http://www.youtube.com/watch?v=qmVn6b7DdpA")
        Case 18
            $oIE.Navigate ("http://www.youtube.com/watch?v=O7txeOlujTc")
    EndSwitch
EndFunc   ;==>_Random

Func AnimateTitle($hGUI, $sTitle, $iBuf)
    $sTitle = StringSplit($sTitle, "")
    For $i = $iBuf To 0 Step - 1
        WinSetTitle($hGUI, "", _StringRepeat(" ", $i) & $sTitle[1])
    Next
    Local $s
    For $i = 1 To $sTitle[0]
        $s &= $sTitle[$i]
        WinSetTitle($hGUI, "", $s)
        Sleep(5)
    Next
EndFunc   ;==>AnimateTitle

And yes, I finally released Simple Web Browser's Source. :)

Edited by JustinReno
Posted

Great application !

[size="2"]SFXMaker[/size] - The most complete switchless installer creator software[indent][/indent]
Posted (edited)

Yes, but I met my goal on not using IE.au3.

It was a challenge from another thread and I exceeded suceeded. I prefer IE.au3 still.

Edited by JustinReno
Posted

I have on question. Would it be possible for me to be able to create a web browser without haveing to branch off of other browsers. Like firefox is different from IE and doesnt require IE to be installed on the host computer. I need to know if this is doable or should I not even try in autoit?

Spoiler

 

"If a vegetarian eats vegetables,What the heck does a humanitarian eat?"

"I hear voices in my head, but I ignore them and continue on killing."

"You have forced me to raise the indifference warning to beige, it's a beige alert people. As with all beige alerts please prepare to think about the possibility of caring."

An optimist says that giving someone power DOESN'T immediately turn them into a sadist. A pessimist says that giving someone power doesn't IMMEDIATELY turn them into a sadist.

 

 
Posted

Nice browser...

But not so CPU friendly :)

Just replace all lines in main loop before GuiGetMsg by this:

If $oIE.Busy() Then
        $url = $oIE.LocationURL()
        If GUICtrlRead($status_bar) <> "Loading: " & $url & "..." Then _StatusChange("Loading: " & $url & "...")
    ElseIf GUICtrlRead($status_bar) <> "Done." Then
        WinSetTitle($gui_main, "", "Simple Web Browser 3.0 - Created by Justin Reno - " & $oIE.locationURL())
        _StatusChange("Done.")
    EndIf

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 5 weeks later...
Posted

There`s a problem when i clicking the back button right when it is open...

What i wanna say is that if u didn`t see any pages or hit any links...and directly push the back button it crashes

Posted

Justin, didn't we say no more browsers?

Its good to know, that you know another way around it but still!

Look at the date when this was posted. :P

_Kurt and I tried cwebpage.dll for a while. I had trouble using it... At last check it wasn't really documented.

Doesn't cwebpage.dll use IE? I found the source(I think) and it was all IE.

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
  • Recently Browsing   0 members

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