Sign in to follow this  
Followers 0
trickytroy

How do i creat an ini file

6 posts in this topic

hello, i'm creating a favorites list for my web browser i'm currently working on and when i open the fav gui, i want it to open the fav.ini file and read the websites i put in there and put them in the text list on the fav gui. i just dont know how to write an ini file. heres my code

$gui = GUICreate("Troyzilla 1.0", @DesktopWidth, @DesktopHeight, -1, -1, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_MAXIMIZE)
        GUISetState( @SW_MAXIMIZE )
    
    $back = GUICtrlCreateButton("Back", 10, 20, 40, 30,  $BS_BITMAP)
    $forward = GUICtrlCreateButton("Forward", 55, 20, 40, 30, $BS_BITMAP)
    $refresh = GUICtrlCreateButton("Refresh", 100, 20, 40, 30, $BS_BITMAP)
    $GO = GUICtrlCreateButton("GO", 810, 20, 50, 30, $BS_BITMAP)
    $Combo_5 = GUICtrlCreateCombo("http://www.google.com", 150, 25, 640, 21, $GUI_DEFBUTTON)
    $pic = GUICtrlCreatePic("images\troyzilla.jpg", 890, 5, 85, 53)
    
    $filemenu = GUICtrlCreateMenu ("&File")  ;creates the file menu
        $fileitem = GUICtrlCreateMenuitem ("Open",$filemenu)  ;creates open in the file menu
            GUICtrlSetState(-1,$GUI_DEFBUTTON)
        $exititem = GUICtrlCreateMenuitem ("Exit",$filemenu)    ;Creates exit in the file menu
        $saveitem = GUICtrlCreateMenuitem ("Save",$filemenu);Creates Save in the file menu
            GUICtrlSetState(-1, $GUI_DEFBUTTON)
        $recentfilesmenu = GUICtrlCreateMenu ("Recent Files",$filemenu,1)   ;Creates recent items in the file menu
        $separator1 = GUICtrlCreateMenuitem ("",$filemenu,2);creates a separator line
        
    
    $helpmenu = GUICtrlCreateMenu ("Help")   ;Creates the help menu
        $infoitem = GUICtrlCreateMenuitem ("Info",$helpmenu)    ;Creates info in the help menu
    
    $viewmenu = GUICtrlCreateMenu("View",-1,1);Creates view menu
        $viewfavitem = GUICtrlCreateMenuitem ("Favorites",$viewmenu) ;Creates Favorites in the view menu

;Sets the picture of the buttons on the page
    GUICtrlSetImage ( $back, "images\back.bmp") 
    GUICtrlSetImage ( $Forward, "images\forward.bmp")
    GUICtrlSetImage ( $refresh, "images\refresh.bmp")
    GUICtrlSetImage ( $GO, "images\go.bmp")
    
    
;Creates the info gui
$info = GUICreate("About Troyzilla", 290, 382,(@DesktopWidth-290)/2, (@DesktopHeight-382)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE, $WS_EX_TOOLWINDOW)
    $OK = GuiCtrlCreateButton("OK", 80, 330, 120, 40)
    $Pic_2 = GuiCtrlCreatePic("images/info.jpg", 0, 0, 290, 310)
    GUISetState( @SW_HIDE, $info )  
    
$fav = GuiCreate("Projects" , 235, 670,2, 80 , $WS_CHILD + $WS_VISIBLE + $WS_SIZEBOX + $WS_EX_TOOLWINDOW ,"", $gui)

    $Button_1 = GuiCtrlCreateButton("Add", 20, 50, 70, 30)
    $Button_2 = GuiCtrlCreateButton("Delete", 130, 50, 70, 30)
    $Label_3 = GuiCtrlCreateLabel("Favorites", 20, 20, 210, 20)
    $Close = GuiCtrlCreateButton("Close", 70, 630, 70, 30)
        GUICtrlCreateList("", 2, 85, 230, 550)
        
        GuiSetState(@SW_HIDE, $fav)

;creates the child gui that the dll will be held in.
$internetgui = GUICreate("", @DesktopWidth -15, @DesktopHeight - 190, 3, 78, $WS_CHILD + $WS_BORDER, "", $gui)
    GUISetState()

;opens dll then calls it.
$dll = DllOpen("cwebpage.dll")
    DllCall($dll, "long", "EmbedBrowserObject", "hwnd", $internetgui)
    DllCall($dll, "long", "DisplayHTMLPage", "hwnd", $internetgui, "str", "http://www.google.com")




While 1
    $msg = GUIGetMsg() 
    
    Select
        Case $msg = $GUI_EVENT_CLOSE; states that if the close button is it the script will exit
            if WinActive($info) Then
                GUISetState(@SW_HIDE)
                Else
            Exit
        EndIf
        Case $msg = $GO 
            DllCall($dll, "long", "DisplayHTMLPage", "hwnd", $internetgui, "str", GUICtrlRead($Combo_5)); tells the dll to go to the web page thats in the combobox
        
        Case  $msg = $back 
            DLLCall($dll,"none","DoPageAction","hwnd",$internetgui,"int", 0);tells the webpage to go back
        
        Case $msg = $forward
            DLLCall($dll,"none","DoPageAction","hwnd",$internetgui,"int", 1);tells the webpage to go forward
        
        Case $msg = $refresh 
            DLLCall($dll,"none","DoPageAction","hwnd",$internetgui,"int", 4);tells the webpage to refresh
        
        Case $msg = $exititem; sets the exit item in the menu to exit
            Exit
        
        Case $msg = $OK 
            GUISetState( @SW_HIDE, $info ); tells the info gui to hide
    
    ; makes the open file box and makes it open the file in the webpage dll
        Case $msg = $fileitem  
            $file = FileOpenDialog("Open","C:","HTML (*.html;*.htm)")
            If @error <> 1 Then GUICtrlCreateMenuitem ($file ,$recentfilesmenu)
            If $msg = $fileitem Then DllCall($dll, "long", "DisplayHTMLPage", "hwnd", $internetgui, "str", $file)
        
    ;makes the save file box and saves the current page 
        Case $msg = $saveitem
            $save = FileSaveDialog ("Save", @DesktopDir, "Html (*.html)", 3, "")
                InetGet(GUICtrlRead($Combo_5), $save & ".html", 1,0)

        Case $msg = $infoitem               
            GuiSetState(@SW_SHOW, $info); shows the info gui
        
        Case $msg = $viewfavitem
            WinMove($internetgui, "", 245, 78,@DesktopWidth - 250, @DesktopHeight - 190)
            
            GuiSetState(@SW_SHOW, $fav); shows the fav gui
        
        Case $msg = $Close
                GuiSetState(@SW_HIDE, $fav); shows the fav gui
                WinMove($internetgui, "", 3, 78,@DesktopWidth -15, @DesktopHeight - 190)
                
                EndSelect
        WEnd
Exit

[quote]Randy:This is for what?! Arresting me for what?! I'm not allowed to stand up for myself?! I thought this was America! Huh? Isn't this America?! I'm sorry! I thought this was America![/quote]

Share this post


Link to post
Share on other sites



#3 ·  Posted (edited)

Autoit makes this real easy for you...

$Var = IniRead($IniFile, 'AutoIt', 'version', 'dam Error reading file')

first argument is the ini file you want to read from, second is param string to look for...

There's also some corresponding fixed variables like @InetGetActive and IniWrite etc. but as I sayd this could not be easier thanks to autoit...

kjactive :(

Edited by kjactive

Share this post


Link to post
Share on other sites

hmm do you guys know how to read multiple lines in the

command FileReadLine ( filehandle or "filename" [, line] )


[quote]Randy:This is for what?! Arresting me for what?! I'm not allowed to stand up for myself?! I thought this was America! Huh? Isn't this America?! I'm sorry! I thought this was America![/quote]

Share this post


Link to post
Share on other sites

The help file has an example in it reading an entire text file...


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

ya but it doesnt display the spaces beetween words

Edited by trickytroy

[quote]Randy:This is for what?! Arresting me for what?! I'm not allowed to stand up for myself?! I thought this was America! Huh? Isn't this America?! I'm sorry! I thought this was America![/quote]

Share this post


Link to post
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
Sign in to follow this  
Followers 0