Jump to content

Open URL in Firefox or Opera (New Tab)


eagle51
 Share

Recommended Posts

Hello together,

I am using Opera and Firefox.

Now I would like to know whether it's possible with autoit to open a URL in a NEW tab.

For Firefox I found:

Run(@ProgramFilesDir & "\Mozilla Firefox\firefox.exe " & $url, "", @SW_MAXIMIZE)

But that command opens every time a new instance of firefox... - I want all the websites in different Tabs :)

Hope you guys can help me.

Thanks in advance,

e51

Link to comment
Share on other sites

Thanks for the great website :)

Okey... Now

Run("c:\FF\ff.exe new-tab " & $url1, "", @SW_MAXIMIZE)oÝ÷ Ú+0¢¹"nµú+{-jw¯{.Í7êêå×Múº¹vÓ~®®]ôß««7êêåäÚ0òÅç.µæ®¶­se'VâgV÷C¶3¢b3#´dbb3#¶fbæWRæWr×F"gV÷C²fײb33c·W&ÃÂgV÷C²gV÷C²Â5uôÔÔ¤R¥'VâgV÷C¶3¢b3#´dbb3#¶fbæWRæWr×F"gV÷C²fײb33c·W&Ã"ÂgV÷C²gV÷C²Â5uôÔÔ¤R¥'VâgV÷C¶3¢b3#´dbb3#¶fbæWRæWr×F"gV÷C²fײb33c·W&Ã2ÂgV÷C²gV÷C²Â5uôÔÔ¤R¥'VâgV÷C¶3¢b3#´dbb3#¶fbæWRæWr×F"gV÷C²fײb33c·W&ÃBÂgV÷C²gV÷C²Â5uôÔÔ¤R¥'VâgV÷C¶3¢b3#´dbb3#¶fbæWRæWr×F"gV÷C²fײb33c·W&ÃRÂgV÷C²gV÷C²Â5uôÔÔ¤R

But that opens five FireFox instances... - sure, I call the Run-command five times.

But I want them ALL in a SINGLE instance :P

Hope you guys know what I mean.

Furthermore, please apologize my bad english :blink:

Have a nice day,

Kesandal

Link to comment
Share on other sites

You aren'y using the command correctly, its (-new-tab) NOT (new-tab):

$command = @ProgramFilesDir & "\Mozilla Firefox\firefox.exe -new-tab "
$url = "http://www.google.com"
Run($command & $url, "", @SW_MAXIMIZE)
Run($command & $url, "", @SW_MAXIMIZE)
Run($command & $url, "", @SW_MAXIMIZE)
Run($command & $url, "", @SW_MAXIMIZE)
Run($command & $url, "", @SW_MAXIMIZE)
Link to comment
Share on other sites

Try to set them in one line...

Run("c:\FF\ff.exe -new-tab " & $url1 & " " & $url2 & " " & $url3 & " " & $url4 & " " & $url5, "", @SW_MAXIMIZE)

 

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

Link to comment
Share on other sites

Seems to be working.. but...

$url1 (the first argument) is opend in a single instance, while the other arguments (urls) are opend together in one instance.....

So I get now 2 instances.. doesn't matter how URLs I want to open...

1st instance:

$url1

2nd instance:

$url2 , $url3, $url4 ......

and second question...

What if I don't know how many urls I have?

The problem could be solved with For ..... and then Run($command & $url, "", @SW_MAXIMIZE)

but this doesn't work as mentioned above.

Thanks :)

Link to comment
Share on other sites

Try to set them in one line...

Run("c:\FF\ff.exe -new-tab " & $url1 & " " & $url2 & " " & $url3 & " " & $url4 & " " & $url5, "", @SW_MAXIMIZE)oÝ÷ Ûú®¢×jh¶Ø§éé­çbrÖêÞ²ém²ë"è¶azÇ+H¦-yÖ§vØb²Þ"ÚâyÖ®¶­sd÷BgV÷CµvåFFÆTÖF6ÖöFRgV÷C²Â" ¢b33c·FÒ&öw&ÔfÆW4F"fײgV÷C²b3#´Ö÷¦ÆÆf&Vf÷b3#¶f&Vf÷æWRgV÷C°¢b33c·W&ÃÒgV÷C¶GG¢ò÷wwrævöövÆRæ6öÒ÷6V&6÷Öw&VVâgV÷C°¢b33c·W&Ã"ÒgV÷C¶GG¢ò÷wwrævöövÆRæ6öÒ÷6V&6÷Ö&ÇVRgV÷C°¢b33c·W&Ã2ÒgV÷C¶GG¢ò÷wwrævöövÆRæ6öÒ÷6V&6÷Ö÷&ævRgV÷C°¢b33c·W&ÃBÒgV÷C¶GG¢ò÷wwrævöövÆRæ6öÒ÷6V&6÷×VÆÆ÷rgV÷C°¢b33c·W&ÃRÒgV÷C¶GG¢ò÷wwrævöövÆRæ6öÒ÷6V&6÷×&VBgV÷C° ¥'Vâb33c·FfײgV÷C²ÖæWr×F"gV÷C²fײb33c·W&ÃfײgV÷C²gV÷C²fײb33c·W&Ã"fײgV÷C²gV÷C²fײb33c·W&Ã2fײgV÷C²gV÷C²fײb33c·W&ÃBfײgV÷C²gV÷C²fײb33c·W&ÃRÂgV÷C²gV÷C²Â5uôÔÔ¤R

This opened the first link in its own window, then opened the following four in a new window as tabs. :)

Edited by weaponx
Link to comment
Share on other sites

Ok, it's not working... then use DDE...

If Not ProcessExists("Firefox.exe") Then
    Run(@ProgramFilesDir & "\Mozilla Firefox\firefox.exe", "", @SW_MAXIMIZE)
    WinWaitActive("[CLASS:MozillaUIWindowClass]")
EndIf

OpenGetURL("http://google.com", 0, 0, "firefox")
OpenGetURL("http://autoitscript.com", 0, 0, "firefox")

;===============================================================================
;
; Function Name:  OpenGetURL()
;
; Parameter(s):     $sURL           [optional] Address of page to open,
;                                   if this is empty string (default), then returned Url from address field of particular tab.
;                   $hWin           [optional] Number of tab:
;                                       -1 = Current tab.
;                                       0 = New tab (when opening).
;                   $RetType        [optional] Definds returned value:
;                                       0 = String with Title and URL address.
;                                       1 = Array with 3 elements...
;                                           [0] = Title
;                                           [1] = URL address
;                                           [2] = String with Title And URL address.
;                   $Server         [optional] Serever to open/get Url in/from.
;                   $iWait          [optional] Waiting Timeout in milliseconds, on overload will return an error.
;
; Requirement(s):   None
; Return Value(s):  On Success -  See 'Parameter(s)'.
;                   On Failure -  Empty string and set @error as following:
;                       1 = Error to open Dll (user32.dll)
;                       2 = Error Initializing DDE (@extended include more details about the returned value from DllCall).
;                       3 = Othe DDE Errors (@extended include more details about the returned value from DllCall).
; Author(s):        amel27
;
;=====================================================================
Func OpenGetURL($sURL = "", $hWin = -1, $RetType = 0, $Server="IExplore", $iWait = 10000)
    Local $ret, $err, $uIdInst = DllStructCreate("int")
    Local $hServer[1], $hTopic[1], $hItem[1], $hConv[1], $hData[1], $sData[1]
    Local $sTopic = "WWW_OpenURL", $sItem = $sURL & ',,0x' & Hex($hWin)
    If $sURL = '' Then
        $sTopic = "WWW_GetWindowInfo"
        $sItem = "0x" & Hex($hWin)
    EndIf
    Local $hDll = DllOpen("user32.dll")
    If $hDll=-1 Then Return SetError(1, 0, "") ; Error to open Dll
    $ret = DllCall("user32.dll", "int", "DdeInitialize", "ptr", DllStructGetPtr($uIdInst), "ptr", 0, "int", 0, "int", 0)
    If $ret[0] Then Return SetError(2, $ret[0], "") ; Error Initializing DDE
    $hServer = DllCall($hDll, "int", "DdeCreateStringHandle", "int", DllStructGetData($uIdInst,1), "str", $Server, "int", 1004)
    If $hServer[0] Then
        $hTopic = DllCall($hDll, "int", "DdeCreateStringHandle", "int", DllStructGetData($uIdInst,1), "str", $sTopic, "int", 1004)
        If $hTopic[0] Then
            $hItem = DllCall($hDll, "int", "DdeCreateStringHandle", "int", DllStructGetData($uIdInst,1), "str", $sItem, "int", 1004)
            If $hItem[0] Then
                $hConv = DllCall($hDll, "int", "DdeConnect", "int", _
                    DllStructGetData($uIdInst,1), "int", $hServer[0], "int", $hTopic[0], "int", 0)
                If $hConv[0] Then
                    $hData = DllCall($hDll, "int", "DdeClientTransaction", "ptr", 0, "int", 0, _
                        "int", $hConv[0], "int", $hItem[0], "int", 1, "int", 0x20B0, "int", $iWait, "ptr", 0)
                    If $hData[0] Then $sData = DllCall($hDll, "str", "DdeAccessData", "int", $hData[0], "ptr", 0)
                EndIf
            EndIf
        EndIf
    EndIf
    $iErr = DllCall($hDll, "int", "DdeGetLastError", "int", DllStructGetData($uIdInst, 1))
    If $hData[0] Then DllCall($hDll, "int", "DdeFreeDataHandle", "int", $hData[0])
    If $hConv[0] Then DllCall($hDll, "int", "DdeFreeDataHandle", "int", $hConv[0])
    If $hItem[0] Then DllCall($hDll, "int", "DdeFreeDataHandle", "int", $hItem[0])
    If $hTopic[0] Then DllCall($hDll, "int", "DdeFreeDataHandle", "int", $hTopic[0])
    If $hServer[0] Then DllCall($hDll, "int", "DdeFreeDataHandle", "int", $hServer[0])
    If $iErr[0] Then Return SetError(3, $iErr[0], "") ; Othe DDE Errors
    DllCall($hDll, "int", "DdeUninitialize", "int", DllStructGetData($uIdInst, 1))
    DllClose($hDll)
    
    If StringRight($sData[0], 3) = ',""' Then $sData[0] = StringTrimRight($sData[0], 3)
    If $sURL = '' Then $sURL = StringRegExpReplace($sData[0], '^"([^"]*?)".*','"\1"')
    
    If $RetType = 1 Then
        Local $iRetTitle = StringReplace(StringTrimLeft($sData[0], StringLen($sURL)+1), '\"', '"')
        Local $RetURL[3] = [StringReplace($sData[0], '\"', '"'), $sURL, $iRetTitle]
        Return $RetURL
    EndIf
    
    Return $sURL
EndFunc

For Opera replace "firefox" with "Opera" in the last used parameter.

Edited by MsCreatoR

 

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

Link to comment
Share on other sites

Opt("WinTitleMatchMode", 2)

$path = @ProgramFilesDir & "\Mozilla Firefox\firefox.exe"
$url1 = "http://www.google.com/search?q=green"
$url2 = "http://www.google.com/search?q=blue"
$url3 = "http://www.google.com/search?q=orange"
$url4 = "http://www.google.com/search?q=yellow"
$url5 = "http://www.google.com/search?q=red"

Run($path & " " & $url1 & " " & $url2 & " " & $url3 & " " & $url4 & " " & $url5, "", @SW_MAXIMIZE)

I removed the "-new-tab" and on 2 different systems it is working fine.

I was thinking that the -new switch was telling it to create a new $path, I am a brand new to AutoIt, so please correct me if I am reading/doing something wrong.

Edited by fletch33
Link to comment
Share on other sites

My search bar includes a very non complex way of using FF:

#NoTrayIcon
If WinExists("DansMainSearchMenu") Then
    ProcessClose("HomeMenu.exe")
    Exit
EndIf
If Not FileExists(@ScriptDir & "\menu.ini") Then IniWrite(@ScriptDir & "\menu.ini", "websites", "google", "http://www.google.com/search?hl=en&q=|&btnG=Google+Search| |+")
#include<GUIConstants.au3>

HotKeySet("!q", "leave")
HotKeySet("{enter}", "enter")
HotKeySet("!t", "test")
Opt("GUIOnEventMode", 1)



Global $skipread = 0
Global $addtosite
Global $tog = False
Global $replacements[1]
Global $uvar = 0
Global $var
$tp2 = GUICreate("transparent parent2", (@DesktopWidth / 2) + 20, (@DesktopHeight / 2) + 22, -1, -1, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
WinSetTrans("transparent parent2", "", 150)
$editGUI = GUICreate("Edit INI", @DesktopWidth / 2, @DesktopHeight / 2, -1, -1, $WS_POPUPWINDOW, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
GUICtrlCreateGroup("", (@DesktopWidth / 7.5), 10, @DesktopWidth / 2.78, @DesktopHeight / 2.1)
GUICtrlCreateLabel("-Website-", @DesktopWidth / 100, 0, (@DesktopWidth / 8) - 10, 30)
GUICtrlSetFont(-1, 16)
$weblist = GUICtrlCreateList("", @DesktopWidth / 100, @DesktopHeight / 28, @DesktopWidth / 10, @DesktopHeight / 3)
GUICtrlSetOnEvent(-1, "updatedisplay")
GUICtrlCreateLabel("-URL LEFT of Search String-", @DesktopWidth / 6, @DesktopHeight / 28, @DesktopWidth / 3, 30)
GUICtrlSetFont(-1, 16)
$leftofURL = GUICtrlCreateInput("", @DesktopWidth / 7, @DesktopHeight / 15, (@DesktopWidth / 2) - ((@DesktopWidth / 8) + 40), 20)
GUICtrlCreateLabel("-URL RIGHT of Search String-", @DesktopWidth / 6, @DesktopHeight / 10, @DesktopWidth / 3, 30)
GUICtrlSetFont(-1, 16)
$rightofURL = GUICtrlCreateInput("", @DesktopWidth / 7, @DesktopHeight / 7, (@DesktopWidth / 2) - (@DesktopWidth / 8) + 40, 20)
$listview = GUICtrlCreateListView("Replace This|With This", @DesktopWidth / 7, @DesktopHeight / 4.75, @DesktopWidth / 4, @DesktopHeight / 5)
GUICtrlCreateLabel("-Search String Replacements-", @DesktopWidth / 7, @DesktopHeight / 5.75, @DesktopWidth / 3, 30)
GUICtrlSetFont(-1, 16)
GUICtrlCreateButton("Save Changes", @DesktopWidth / 7, @DesktopHeight / 2.3, @DesktopWidth / 2.9, @DesktopHeight / 20)
GUICtrlSetOnEvent(-1, "saveini")
GUICtrlCreateButton("Add Website", @DesktopWidth / 100, @DesktopHeight / 2.75, @DesktopWidth / 10, @DesktopHeight / 20)
GUICtrlSetOnEvent(-1, "addwebsite")
GUICtrlCreateButton("Remove Website", @DesktopWidth / 100, @DesktopHeight / 2.3, @DesktopWidth / 10, @DesktopHeight / 20)
GUICtrlSetOnEvent(-1, "removewebsite")
GUICtrlCreateButton("Add", @DesktopWidth / 2.5, @DesktopHeight / 4, @DesktopWidth / 15, @DesktopWidth / 20)
GUICtrlSetOnEvent(-1, "addreplace")
GUICtrlCreateButton("Remove", @DesktopWidth / 2.5, @DesktopHeight / 3, @DesktopWidth / 15, @DesktopWidth / 20)
GUICtrlSetOnEvent(-1, "killreplace")
initload()



GUICreate("transparent parent", (@DesktopWidth / 2) + 20, 42, (@DesktopWidth / 4) - 10, 0, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
GUICtrlCreateButton("+", (@DesktopWidth / 2) + 10, 0, 10, 21)
GUICtrlSetOnEvent(-1, "toggleedit")
GUICtrlSetColor( -1, 0x000000 )
GUICtrlSetBkColor( -1, 0x00FF00 )
GUICtrlCreateButton("X", 0, 0, 10, 21)
GUICtrlSetOnEvent(-1, "leave")
GUICtrlSetColor( -1, 0x000000 )
GUICtrlSetBkColor( -1, 0xFF0000 )
WinSetTrans("transparent parent", "", 150)
GUISetState()
$maingui = GUICreate("DansMainSearchMenu", @DesktopWidth / 2, 21, @DesktopWidth / 4, 10, $WS_POPUP, BitOR($WS_EX_TOOLWINDOW, $WS_EX_TOPMOST))
$searchstring = GUICtrlCreateInput("", 0, 0, @DesktopWidth / 4 + @DesktopWidth / 16, 21)
GUICtrlCreateButton("Search", (@DesktopWidth / 2) - @DesktopWidth / 16, 0, @DesktopWidth / 16, 22)
GUICtrlSetOnEvent(-1, "Combo")
Global $array = IniReadSection(@ScriptDir & "\menu.ini", "websites")
$combobox = GUICtrlCreateCombo($array[1][0], (@DesktopWidth / 2) - (3 * @DesktopWidth) / 16, 0, @DesktopWidth / 8)
reloadcombo()




GUISetState()
While 1
    WinSetOnTop("DansMainSearchMenu", "", 1)
    Sleep(10)
WEnd




Func combo() ; Pointers to proper function from Combobox
    If GUICtrlRead($combobox) = "" Then Return
    For $avar = 1 To $array[0][0]
        If GUICtrlRead($combobox) = $array[$avar][0] And GUICtrlRead($searchstring) <> "" Then Firefox($array[$avar][1], GUICtrlRead($searchstring))
    Next
EndFunc   ;==>combo
Func Firefox($start, $search)
    $split = StringSplit($start, "|")
    If $split[0] > 2 Then
        For $avar = 3 To $split[0] Step 2
            $search = StringReplace($search, $split[$avar], $split[$avar + 1])
        Next
    EndIf
    $goto = $split[1] & $search & $split[2]
    If WinExists("Mozilla Firefox") Then
        ShellExecute("C:\Program Files\Mozilla Firefox\firefox.exe","-new-tab " & $goto ) 
    Else
        ShellExecute("C:\Program Files\Mozilla Firefox\firefox.exe", $goto)
    EndIf
EndFunc   ;==>Firefox
Func enter()
    If WinActive("DansMainSearchMenu") Then
        HotKeySet("{enter}")
        combo()
        HotKeySet("{Enter}", "enter")
    Else
        HotKeySet("{enter}")
        Send("{Enter}")
        HotKeySet("{Enter}", "enter")
    EndIf
EndFunc   ;==>enter
Func addwebsite()
    HotKeySet("{enter}")
    GUISetState(@SW_HIDE, $editGUI)
    GUISetState(@SW_HIDE, $tp2)
    $name = InputBox("Add Website", "What is the name of the search site to add?", "", " M")
    If @error = 0 Then
        $left = InputBox("Add Website", "What is the URL to the LEFT of the search string?")
        If @error = 0 Then
            $right = InputBox("Add Website", "What is the URL to the RIGHT of the search string?" & @CRLF & @CRLF & "If nothing then leave blank")
            If @error = 2 Or @error = 3 Then Return
            $replace = ""
            While MsgBox(36, "String Replacement?", "Do you need to add a(nother) string replacement for the search string?" & @CRLF & @CRLF & "For example, most search requests need to replace ' ' (spacebar) with '+'" & @CRLF & "Please do not use quotes") = 6
                $what = InputBox("String replace", "String replace what?")
                If @error = 2 Or @error = 3 Then Return
                $with = InputBox("String replace", "String replace '" & $what & "' with what?")
                If @error = 2 Or @error = 3 Then Return
                $replace = $replace & "|" & $what & "|" & $with
            WEnd
            IniWrite(@ScriptDir & "\menu.ini", "websites", $name, $left & "|" & $right & $replace)
            GUISwitch($editGUI)
            initload()
            GUISwitch($maingui)
            reloadcombo()
            GUISwitch($editGUI)
            HotKeySet("{Enter}", "enter")
            GUISetState(@SW_SHOW, $tp2)
            GUISetState(@SW_SHOW, $editGUI)
            GUICtrlSetData($weblist, $name)
            updatedisplay()
            Return
        Else
            HotKeySet("{Enter}", "enter")
            GUISetState(@SW_SHOW, $tp2)
            GUISetState(@SW_SHOW, $editGUI)
            Return
        EndIf
    Else
        HotKeySet("{Enter}", "enter")
        GUISetState(@SW_SHOW, $tp2)
        GUISetState(@SW_SHOW, $editGUI)
        Return
    EndIf
    Return
EndFunc   ;==>addwebsite
Func removewebsite()
    HotKeySet("{Enter}")
    GUISetState(@SW_HIDE, $tp2)
    GUISetState(@SW_HIDE, $editGUI)
    $rem = GUICtrlRead($weblist)
    If $rem <> "" Then
        $ans = MsgBox(292, "Remove Website...", "Are you sure you want to remove" & @CRLF & $rem & " from the list?")
        If $ans = 6 Then
            IniDelete(@ScriptDir & "\menu.ini", "websites", $rem)
            GUISwitch($editGUI)
            initload()
            GUISwitch($maingui)
            reloadcombo()
            GUISwitch($editGUI)
            GUICtrlSetData($leftofURL, "")
            GUICtrlSetData($rightofURL, "")
            GUICtrlDelete($listview)
            $listview = GUICtrlCreateListView("Replace This|With This", @DesktopWidth / 7, @DesktopHeight / 4.75, @DesktopWidth / 4, @DesktopHeight / 5)
        EndIf
        HotKeySet("{Enter}", "enter")
        GUISetState(@SW_SHOW, $tp2)
        GUISetState(@SW_SHOW, $editGUI)
        Return
    EndIf
    MsgBox(48, "Remove Website...", "You have not selected a website to remove")
    HotKeySet("{Enter}", "enter")
    GUISetState(@SW_SHOW, $tp2)
    GUISetState(@SW_SHOW, $editGUI)
EndFunc   ;==>removewebsite
Func reloadcombo()
    Global $array = IniReadSection(@ScriptDir & "\menu.ini", "websites")
    GUICtrlDelete($combobox)
    $combobox = GUICtrlCreateCombo($array[1][0], (@DesktopWidth / 2) - (3 * @DesktopWidth) / 16, 0, @DesktopWidth / 8)
    If $array[0][0] > 1 Then
        $list = ""
        For $avar = 2 To $array[0][0]
            If $avar = 2 Then
                $list = $array[$avar][0]
            Else
                $list = $list & "|" & $array[$avar][0]
            EndIf
        Next
        GUICtrlSetData($combobox, $list, $array[1][0])
    EndIf
EndFunc   ;==>reloadcombo
Func initload()
    $array = IniReadSection(@ScriptDir & "\menu.ini", "websites")
    $var = IniReadSection(@ScriptDir & "\menu.ini", "websites")
    If @error Then
        MsgBox(4096, "", "Error occurred, probably no INI file.")
    Else
        GUICtrlDelete($weblist)
        $weblist = GUICtrlCreateList("", @DesktopWidth / 100, @DesktopHeight / 28, @DesktopWidth / 10, (@DesktopHeight / 3))
        GUICtrlSetOnEvent(-1, "updatedisplay")
        For $i = 1 To $var[0][0]
            GUICtrlSetData($weblist, $var[$i][0])
        Next
    EndIf
EndFunc   ;==>initload
Func updatedisplay()
    $num = ""
    For $i = 1 To $var[0][0]
        If $var[$i][0] = GUICtrlRead($weblist) Then
            $num = $i
            ExitLoop
        EndIf
    Next
    If $num = "" Then
        GUISetState($editGUI, @SW_HIDE)
        GUISetState($tp2, @SW_HIDE)
        MsgBox(0, "error", "Error # 1, tell danny about this")
        Exit
    EndIf
    $temprepstring = StringSplit($var[$num][1], "|")
    GUICtrlDelete($listview)
    $listview = GUICtrlCreateListView("Replace This|With This", @DesktopWidth / 7, @DesktopHeight / 4.75, @DesktopWidth / 4, @DesktopHeight / 5)
    Global $replacements[1]
    Global $uvar = -1
    If UBound($temprepstring) >= 4 Then
        For $avar = 3 To $temprepstring[0] Step 2
            If $avar <> 3 Then ReDim $replacements[UBound($replacements) + 1]
            $uvar += 1
            $replacements[$uvar] = GUICtrlCreateListViewItem($temprepstring[$avar] & "|" & $temprepstring[$avar + 1], $listview)
        Next
    EndIf
    GUICtrlSetData($leftofURL, $temprepstring[1])
    GUICtrlSetData($rightofURL, $temprepstring[2])
EndFunc   ;==>updatedisplay
Func test()
    ;nothing to test for now :)
EndFunc   ;==>test
Func saveini()
    $read = GUICtrlRead($weblist)
    If $read = "" Then Return
    $line = ""
    If $uvar >= 0 Then
        For $avar = 0 To $uvar
            If $avar = 0 Then $line = "|"
            $line = $line & GUICtrlRead($replacements[$avar])
            If $avar <> $uvar Then $line = $line & "|"
        Next
    EndIf
    $line = GUICtrlRead($leftofURL) & "|" & GUICtrlRead($rightofURL) & $line
    IniWrite(@ScriptDir & "\menu.ini", "websites", $read, $line)
    initload()
    GUISwitch($maingui)
    reloadcombo()
    GUISwitch($editGUI)
    GUICtrlSetData($weblist, $read)
EndFunc   ;==>saveini
Func toggleedit()
;~  MsgBox(0, "test", "toggle" )
    If $tog = False Then
        GUISwitch($tp2)
        GUISetState()
        GUISwitch($editGUI)
        GUISetState()
        $tog = True
        Return
    EndIf
    If $tog = True Then
        GUISetState(@SW_HIDE, $tp2)
        GUISetState(@SW_HIDE, $editGUI)
        GUISwitch($maingui)
        $tog = False
        Return
    EndIf
EndFunc   ;==>toggleedit
Func leave()
    Exit
EndFunc   ;==>leave
Func addreplace()
    HotKeySet("{Enter}")
    GUISetState(@SW_HIDE, $tp2)
    GUISetState(@SW_HIDE, $editGUI)
    $addtosite = GUICtrlRead($weblist)
    If $addtosite = "" Then
        MsgBox(0, "Add Replacement", "You have not selected a website yet")
    Else
        $replace = ""
        $what = InputBox("String replace", "String replace what?")
        If @error = 2 Or @error = 3 Then Return
        $with = InputBox("String replace", "String replace '" & $what & "' with what?")
        If @error = 2 Or @error = 3 Then Return
        $uvar += 1
        ReDim $replacements[ UBound($replacements) + 1 ]
        $replacements[$uvar] = GUICtrlCreateListViewItem($what & "|" & $with, $listview)
        IniWrite( @ScriptDir & "\menu.ini", "websites", $addtosite, IniRead( @ScriptDir & "\menu.ini", "websites", $addtosite, "" ) & "|" & $what & "|" & $with )
    EndIf
    GUISwitch($editGUI)
    initload()
    GUISwitch($maingui)
    reloadcombo()
    GUISwitch($editGUI)
    HotKeySet("{Enter}", "enter")
    GUISetState(@SW_SHOW, $tp2)
    GUISetState(@SW_SHOW, $editGUI)
    GUICtrlSetData($weblist, $addtosite)
EndFunc   ;==>addreplace
Func killreplace()
    $addtosite = GUICtrlRead($weblist)
    If $addtosite = "" Then Return
        HotKeySet("{Enter}")
    GUISetState(@SW_HIDE, $tp2)
    GUISetState(@SW_HIDE, $editGUI)
    If GUICtrlRead( $listview ) <> 0 Then
        
        
        ; are you sure???
        $damned = GUICtrlRead( GUICtrlRead ( $listview ))
        GUICtrlDelete( GUICtrlRead( $listview ) )
        $uvar -= 1
        ReDim $replacements[UBound($replacements)]
        IniWrite( @ScriptDir & "\menu.ini", "websites", $addtosite, StringReplace(IniRead( @ScriptDir & "\menu.ini", "websites", $addtosite, "" ), "|" & $damned, ""  ))
    Else
        MsgBox( 48, "Remove Replacement", "You need to select a replacement first" )
    EndIf
    GUISwitch($editGUI)
    initload()
    GUISwitch($maingui)
    reloadcombo()
    GUISwitch($editGUI)
    HotKeySet("{Enter}", "enter")
    GUISetState(@SW_SHOW, $tp2)
    GUISetState(@SW_SHOW, $editGUI)
    GUICtrlSetData($weblist, $addtosite)
EndFunc   ;==>killreplace
#cs

TO DO LIST:
    -Add buttons to move ListView Items up/down in the stack-



#ce
Link to comment
Share on other sites

  • 1 year later...

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...