Jump to content

FINALLY SWB IS HERE


JustinReno
 Share

Recommended Posts

yeah, thats an case limitation, you have to wait for autoit to finsh one thing until you can do another thing..thx, you guys like it?

Since you are merely embedding a IE browser inside a GUI you simply are using IELoadWait. But if you take a look at the IELoadWait function you can see how it works, thus being able to add in the GUIGetMsg register for the exit message. I'm sure Dale wouldn't mind you adding in a If then statement into IELoadWait for your specific use but you may want to check with him. It is easily possible to program it yourself as well. Not only could you just modify IELoadWait but you might be able to do it yourself. Since the IE window is embedded why not check out IEPropertyGet, and look at statustext. I'm not sure but once IE loads a page it says complete or done. Now if you were to do a check instead of using _IELoadWait, and make your own do a check until the status bar text is complete this would allow you to check if the close button was clicked.

yeah, i was thinking about how hard it would have been for tabbed browsing, but i might wait awhile and look around on the tabs function.

Valuater tried, and it is very difficult.

Link to comment
Share on other sites

I have been working on this for a few hours now, this is what I have been doing.. Working on active favorites list (like IE), for the moment if you add a page to favorites using the button on the bottom, you have to exit the browser then reload it to have the favorite in the top menu.. more on this later in this post.. added menu options to print, print to default printer, save web page, Also it actually updates the url on the bottom to the page you are visiting, because before now it stays whatever you type, even of you go back, etc. now it shows actual url of page visiting, it also resolves the url as well, if you type www.google.com, it resolves to http://www.google.com, if you type www.filemirrors.com it resolves to http://www.findfiles.com/ ...it also now does not lock up the browser from doing anything if it is stuck trying to load the page.. before if it was on "loading", you could not do anything, now you can leave that page, or anything else.. Mind you there is alot of extra slop in there for the moment, I was using it to keep track of ideas and test changes I was making at the time, easily cleaned up though.. working on next making the changes ACTIVE, like if you set the home page in prefs, you needed to close browser to have the home button work after the change.. favs are the same for now, should be an easy fix, but haven't got to that yet.. Let me know what you think of the changes I have introduced.. :) Be careful of the word wrapping in the code box!

CODE

#NoTrayIcon

#RequireAdmin

#include <GUIConstants.au3>

#include <IE.au3>

#include <INet.au3>

_IEErrorHandlerRegister()

Global $oIE = ObjCreate("Shell.Explorer.2")

Global $ini = @ScriptDir & "\swb.ini"

Global $favs = @ScriptDir & "\favs.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", "")

;Global $fav_menu = IniRead($favs, "Links", "Link1", "")

;Global $fav_menu = IniReadSectionNames(@ScriptDir & "Favs.ini")

;Global $i = $fav_menu

$filez = FileOpen("Favs.ini", 0)

;$linez = FileReadLine($filez)

Global $fav_menu = FileReadLine($filez)

FileClose($filez)

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.google.com"

EndIf

If $read_starthomepage = "0" Then $read_homepage = "about:blank"

$gui_main = GUICreate("Simple Web Browser", $read_width, $read_height + 20, -1, -1, $WS_CLIPSIBLINGS + $WS_OVERLAPPEDWINDOW)

$file_menu = GUICtrlCreateMenu("File")

$fm_open = GUICtrlCreateMenuItem("Open...", $file_menu)

$fm_print = GUICtrlCreateMenuItem("Print...", $file_menu)

$fm_defprint = GUICtrlCreateMenuItem("Print to Default Printer...", $file_menu)

$fm_SaveSource = GUICtrlCreateMenuItem("Save Source", $file_menu)

$fm_SavePage = GUICtrlCreateMenuItem("Save Page...", $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, $GUI_CHECKED)

$tool_menu = GUICtrlCreateMenu("Tools")

$tm_pref = GUICtrlCreateMenuItem("Preferences...", $tool_menu)

$favorite_menu = GUICtrlCreateMenu("Favorites")

$tm_fave = GUICtrlCreateMenuItem($fav_menu , $favorite_menu)

$about_menu = GUICtrlCreateMenu("Help")

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

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

GUICtrlSetResizing($gui_iewindow, $GUI_DOCKAUTO)

$address_bar_label = GUICtrlCreateLabel("Enter Address: ", 0, 562, 85, -1)

;$urlz = _IEPropertyGet($oIE, "locationurl")

$address_bar_input = GUICtrlCreateInput($read_homepage, 76, 559, 200, -1)

;$address_bar_input = GUICtrlCreateInput($urlz, 76, 559, 200, -1)

$address_bar_go = GUICtrlCreateButton("Go >>", 280, 557, 50, -1, $BS_DEFPUSHBUTTON)

$address_bar_stop = GUICtrlCreateButton("Stop", 332, 557, 50, -1)

$address_bar_back = GUICtrlCreateButton("Back", 383, 557, 50, -1)

$address_bar_home = GUICtrlCreateButton("Home", 434, 557, 50, -1)

$address_bar_favsadd = GUICtrlCreateButton("Add to Favorites", 485, 557, 95, -1)

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

GUISetState(@SW_SHOW, $gui_main)

Fadein()

SoundPlay("C:\WINDOWS\Media\notify.wav", 0)

_IENavigate($oIE, $read_homepage)

_IELoadWaitTimeout (500)

_IELoadWait ($oIE)

$startz = _IEPropertyGet($oIE, "locationurl")

GUICtrlSetData ($address_bar_input , $startz)

$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 Blank Page", "Start with Blank Page")

Else

GUICtrlSetData(-1, "Start with Homepage|Start with Blank Page", "Start with Homepage")

EndIf

$pref_width_label = 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)

$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

If _IEPropertyGet($oIE, "busy") Then

$url = _IEPropertyGet($oIE, "locationurl")

_StatusChange("Loading: " & $url & "...")

Else

;$addyz = _IEPropertyGet($oIE, "locationurl")

;GUICtrlSetData ($address_bar_input , $addyz)

_StatusChange("Done..")

;$url = _IEPropertyGet($oIE, "locationurl")

;GUICtrlSetState($status_bar,$GUI_HIDE)

;GUICtrlSetData($status_bar, $url)

EndIf

$msg = GUIGetMsg()

Switch $msg

Case $GUI_EVENT_CLOSE

If WinGetHandle('') = $gui_main Then

;MsgBox(0, "Simple Web Browser", "Thank you for using Simple Web Browser")

;SoundPlay("C:\WINDOWS\Media\Windows XP Recycle.wav")

FadeOut()

Exit

Else

GUISetState(@SW_HIDE, WinGetHandle(''))

EndIf

;File Menu

Case $fm_exit

;MsgBox(0, "Simple Web Browser", "Thank you for using Simple Web Browser")

;SoundPlay("C:\WINDOWS\Media\Windows XP Recycle.wav")

FadeOut()

Exit

Case $fm_open

Local $file = FileOpenDialog("Select file...", @ScriptDir, "All Files (*.*)")

If @error <> 1 Then

_StatusChange("Loading: " & $file & "...")

_IENavigate($oIE, $file)

EndIf

Case $fm_print

_IEAction ($oIE, "print")

Case $fm_defprint

_IEAction ($oIE, "printdefault")

Case $fm_SavePage

_IEAction ($oIE, "saveas")

Case $fm_SaveSource

$source = InputBox("Simple Web Browser", "Whats is the Website URL you want to save the source from?")

$IE = _INetGetSource("" & $source & "")

FileWrite(@DesktopDir & "\websource.html", $IE)

MsgBox(0, "Simple Web Browser", "Saved to desktop as websource.html")

;View Menu

Case $vm_status

$size = WinGetPos("Simple Web Browser")

If BitAND(GUICtrlRead($vm_status), $GUI_CHECKED) = $GUI_CHECKED Then

GUICtrlSetState($vm_status, $GUI_UNCHECKED)

GUICtrlSetState($status_bar, $GUI_HIDE)

WinMove("Simple Web Browser", "", $size[0], $size[1], $size[2], $size[3] - 15)

Else

GUICtrlSetState($vm_status, $GUI_CHECKED)

GUICtrlSetState($status_bar, $GUI_SHOW)

WinMove("Simple Web Browser", "", $size[0], $size[1], $size[2], $size[3] + 15)

EndIf

; Favorites Menu

Case $tm_fave

_StatusChange("Loading: " & $fav_menu & "...")

_IENavigate($oIE, $fav_menu)

_IELoadWaitTimeout (500)

_IELoadWait ($oIE)

$addyz = _IEPropertyGet($oIE, "locationurl")

GUICtrlSetData ($address_bar_input , $addyz)

_StatusChange("Done.")

; Tools Menu

Case $tm_pref

GUISetState(@SW_SHOW, $gui_pref)

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

MsgBox(0, "Simple Web Browser", "Simple Web Browser was created purely in AutoitV3.")

; Address Bar Buttons

Case $address_bar_go

$addy = GUICtrlRead($address_bar_input)

_StatusChange("Loading: " & $addy & "...")

_IENavigate($oIE, $addy, 0)

_IELoadWaitTimeout (500)

_IELoadWait ($oIE)

$goz = _IEPropertyGet($oIE, "locationurl")

GUICtrlSetData ($address_bar_input , $goz)

_StatusChange("Done.")

Case $address_bar_stop

_IEAction($oIE, "stop")

Case $address_bar_favsadd

$addy = GUICtrlRead($address_bar_input)

$file = FileOpen("Favs.ini", 1)

FileWriteLine($file, $addy)

;IniWrite($favs, "Links", "Link1", $addy)

Case $address_bar_back

_IEAction($oIE, "back")

_IELoadWaitTimeout (500)

_IELoadWait ($oIE)

$backz = _IEPropertyGet($oIE, "locationurl")

GUICtrlSetData ($address_bar_input , $backz)

Case $address_bar_home

_IENavigate($oIE, $read_homepage)

_IELoadWaitTimeout (500)

_IELoadWait ($oIE)

$homez = _IEPropertyGet($oIE, "locationurl")

GUICtrlSetData ($address_bar_input , $homez)

;GUICtrlSetData($address_bar_input, $read_homepage)

;Case $address_bar_speak

;$txt = InputBox("Simple Web Browser", "Text to Speech is still very limited. For now you have to enter text in here. Easy way is to copy and paste the text.")

;Dim $voice = ObjCreate("Sapi.SpVoice")

;$empty = ""

;$txt2 = "" & $txt & ""

;If $txt2 = $empty Then

;Speak("You did not put input.", 0, 100)

;Else

;Speak($txt2, 0, 100)

;EndIf

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 FadeOut()

For $i = 250 To 0 Step - 10

WinSetTrans("Simple Web Browser", "", $i)

Next

EndFunc ;==>FadeOut

Func Fadein()

For $i = 0 To 250 Step 10

WinSetTrans("Simple Web Browser", "", $i)

Next

EndFunc ;==>Fadein

Edited by Stealth111
Link to comment
Share on other sites

cool! what all does your websuite have, sounds interesting!

Hopefully Web Browser, FTP, POP3 and SMTP Email, maybe IRC Chat... Mind helping code? (Check PM box)

Edit: Just wanted to say that all ive pretty much done is rename and give creds, probably going to copy the about message and update it =)

Edited by Bradness
My Programs:Rock Paper ScissorsMy UDFs:NONE
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...