Sign in to follow this  
Followers 0
Vladi243

ini issues

15 posts in this topic

Hey,

I created a script that writes an ini file, and I wrote a script that reads the ini file before the GUI starts.

The problem is that I don't know how to set the values in the GUI.

I tried to set it by GUICtrlSetData(), but it's not working. May be I did something wrong.

Can someone give me a simple example or a short guide?

Share this post


Link to post
Share on other sites



FileRead() first to open & read what you need


[quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
$file = "something.ini"
if FileExists($file) = 0 then IniWrite($file, "Section1", "Key1", "Value23")
$Read = IniRead($file, "Section1", "Key1", "")
$Form1 = GUICreate("Form1", 250, 150, 193, 125)
$Label1 = GUICtrlCreateLabel($Read, 24, 32, 400, 81)
GUICtrlSetFont(-1, 50, 800, 0, "CityBlueprint")
GUISetState(@SW_SHOW)
do
    $nMsg = GUIGetMsg()
Until $nMsg = $GUI_EVENT_CLOSE
I tried it, and I got an error: "Variable used without being declared".

Share this post


Link to post
Share on other sites

The script that you wrote working well. I tried it on my own script.

It's wtriting an error in line 1 but not writing which variable.

Share this post


Link to post
Share on other sites

It's the working script. When I trying to put the iniread variables in the GUI settings, I get error.

BTW, it's not the whole script. I don't want to show the whole script.

#include <GUIConstants.au3>
#include <IE.au3>
#NoTrayIcon

_IEErrorHandlerRegister ()

Global $oIE1 = _IECreateEmbedded ()
Global $oIE2 = _IECreateEmbedded ()
Global $oIE3 = _IECreateEmbedded ()
;ActiveX Sizes
Global $Left=20 , $Top=65 , $Width=585 , $Height=305

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.
TrayCreateItem("")
$RestoreItem = TrayCreateItem("Restore")
TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")
TraySetState()

$IniFile = "Settings.ini"
If FileExists ($IniFile) = 1 Then
    $IniRead_First_Link_Input = IniRead ("Settings.ini", "Links", "Link1", "")
    $IniRead_Second_Link_Input = IniRead ("Settings.ini", "Links", "Link2", "")
    $IniRead_Third_Link_Input = IniRead ("Settings.ini", "Links", "Link3", "")
    $IniRead_Run_On_Startup = IniRead ("Settings.ini", "General", "Run on startup", "")
    $IniRead_Refrsh_Every_Input = IniRead ("Settings.ini", "General", "Refresh every", "")
    $IniRead_Run_Minimized = IniRead ("Settings.ini", "General", "Run minimized", "")
    $IniRead_Run_On_Hidden_Mode = IniRead ("Settings.ini", "General", "Run on hidden mode", "")
EndIf
    
#Region ### START Koda GUI section ### Form=d:\vladik\autoit\koda_1.7.0.1\forms\browser new gui.kxf
$Browser = GUICreate("Browser", 631, 450, 191, 121)
$PageControl1 = GUICtrlCreateTab(8, 8, 612, 370)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("First Page")
$First_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$First_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf1_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX1 = GUICtrlCreateObj($oIE1, $Left, $Top, $Width, $Height)
$TabSheet2 = GUICtrlCreateTabItem("Second Page")
$Second_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Second_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf2_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX2 = GUICtrlCreateObj($oIE2, $Left, $Top, $Width, $Height)
$TabSheet3 = GUICtrlCreateTabItem("Third Page")
$Third_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Third_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf3_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX3 = GUICtrlCreateObj($oIE3, $Left, $Top, $Width, $Height)
GUICtrlCreateTabItem("")
$Minimize_To_Tray = GUICtrlCreateButton("Minimize to tray", 525, 385, 95, 25, 0)
$Hide = GUICtrlCreateButton("Hide", 420, 385, 95, 25, 0)
$Options_Group = GUICtrlCreateGroup("Options", 8, 376, 384, 66)
$Run_On_Startup = GUICtrlCreateCheckbox("Run on startup", 16, 390, 89, 17)
$Refresh_Time = GUICtrlCreateLabel("Refresh every", 138, 418, 70, 17)
$Refrsh_Every_Input = GUICtrlCreateInput("", 214, 411, 40, 21)
$Save_Settings_Button = GUICtrlCreateButton("Save Settings", 278, 389, 98, 45, 0)
$Run_Minimized = GUICtrlCreateCheckbox("Run minimized", 16, 416, 89, 17)
$Run_On_Hidden_Mode = GUICtrlCreateCheckbox("Run on hidden mode", 138, 390, 121, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

HotKeySet ("{F5}", "ShowGUI")

While 1
    $GUIGetMsg = GUIGetMsg()
    $TrayGetMsg = TrayGetMsg()
    Select
        Case $GUIGetMsg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $GUIGetMsg = $Surf1_Button
            $GUICtrlReadFirstLink = GUICtrlRead ($First_Link_Input)
            IniWrite ("Settings.ini", "Links", "Link1", $GUICtrlReadFirstLink)
            _IENavigate ($oIE1, $GUICtrlReadFirstLink)
        Case $GUIGetMsg = $Surf2_Button
            $GUICtrlReadSecondLink = GUICtrlRead ($Second_Link_Input)
            IniWrite ("Settings.ini", "Links", "Link2", $GUICtrlReadSecondLink)
            _IENavigate ($oIE2, $GUICtrlReadSecondLink)
        Case $GUIGetMsg = $Surf3_Button
            $GUICtrlReadThirdLink = GUICtrlRead ($Third_Link_Input)
            IniWrite ("Settings.ini", "Links", "Link3", $GUICtrlReadThirdLink)
            _IENavigate ($oIE3, $GUICtrlReadThirdLink)
        Case $GUIGetMsg = $Hide
            GUISetState(@SW_MINIMIZE)
            GUISetState(@SW_HIDE)
            TraySetState (2)
            MsgBox (1, "Hidden Browser", "Your Browser is hidden. Press F5 to show it again")
        Case $GUIGetMsg = $Minimize_To_Tray
            GUISetState(@SW_MINIMIZE)
            GUISetState(@SW_HIDE)
        Case $GUIGetMsg = $Save_Settings_Button
            $Read_Run_On_Startup= GUICtrlRead ($Run_On_Startup)
            $Read_Refrsh_Every_Input= GUICtrlRead ($Refrsh_Every_Input)
            $Read_Run_Minimized= GUICtrlRead ($Run_Minimized)
            $Read_Run_On_Hidden_Mode= GUICtrlRead ($Run_On_Hidden_Mode)
            IniWrite ("Settings.ini", "General", "Run on startup", $Read_Run_On_Startup)
            IniWrite ("Settings.ini", "General", "Refresh every", $Read_Refrsh_Every_Input)
            IniWrite ("Settings.ini", "General", "Run minimized", $Read_Run_Minimized)
            IniWrite ("Settings.ini", "General", "Run on hidden mode", $Read_Run_On_Hidden_Mode)
        Case $TrayGetMsg = $ExitItem
            ExitLoop
        Case $TrayGetMsg = $RestoreItem
            ShowGUI()
    EndSelect
WEnd

GUIDelete()
exit

;Shows and restores the GUI from the tray/hidden mode.
Func ShowGUI()
    GUISetState(@SW_SHOW)
    GUISetState(@SW_RESTORE)
    TraySetState (1)
EndFunc

Share this post


Link to post
Share on other sites

I get the same error that I said above.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <IE.au3>
#NoTrayIcon

_IEErrorHandlerRegister ()

Global $oIE1 = _IECreateEmbedded ()
Global $oIE2 = _IECreateEmbedded ()
Global $oIE3 = _IECreateEmbedded ()
;ActiveX Sizes
Global $Left=20 , $Top=65 , $Width=585 , $Height=305

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.
TrayCreateItem("")
$RestoreItem = TrayCreateItem("Restore")
TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")
TraySetState()

$IniFile = "Settings.ini"
If FileExists ($IniFile) = 1 Then
    $IniRead_First_Link_Input = IniRead ("Settings.ini", "Links", "Link1", "")
    $IniRead_Second_Link_Input = IniRead ("Settings.ini", "Links", "Link2", "")
    $IniRead_Third_Link_Input = IniRead ("Settings.ini", "Links", "Link3", "")
    $IniRead_Run_On_Startup = IniRead ("Settings.ini", "General", "Run on startup", "")
    $IniRead_Refrsh_Every_Input = IniRead ("Settings.ini", "General", "Refresh every", "")
    $IniRead_Run_Minimized = IniRead ("Settings.ini", "General", "Run minimized", "")
    $IniRead_Run_On_Hidden_Mode = IniRead ("Settings.ini", "General", "Run on hidden mode", "")
EndIf
   
#Region ### START Koda GUI section ### Form=d:\vladik\autoit\koda_1.7.0.1\forms\browser new gui.kxf
$Browser = GUICreate("Browser", 631, 450, 191, 121)
$PageControl1 = GUICtrlCreateTab(8, 8, 612, 370)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("First Page")
$First_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$First_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf1_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX1 = GUICtrlCreateObj($oIE1, $Left, $Top, $Width, $Height)
$TabSheet2 = GUICtrlCreateTabItem("Second Page")
$Second_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Second_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf2_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX2 = GUICtrlCreateObj($oIE2, $Left, $Top, $Width, $Height)
$TabSheet3 = GUICtrlCreateTabItem("Third Page")
$Third_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Third_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf3_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX3 = GUICtrlCreateObj($oIE3, $Left, $Top, $Width, $Height)
GUICtrlCreateTabItem("")
$Minimize_To_Tray = GUICtrlCreateButton("Minimize to tray", 525, 385, 95, 25, 0)
$Hide = GUICtrlCreateButton("Hide", 420, 385, 95, 25, 0)
$Options_Group = GUICtrlCreateGroup("Options", 8, 376, 384, 66)
$Run_On_Startup = GUICtrlCreateCheckbox("Run on startup", 16, 390, 89, 17)
$Refresh_Time = GUICtrlCreateLabel("Refresh every", 138, 418, 70, 17)
$Refrsh_Every_Input = GUICtrlCreateInput($IniRead_Refrsh_Every_Input, 214, 411, 40, 21)
$Save_Settings_Button = GUICtrlCreateButton("Save Settings", 278, 389, 98, 45, 0)
$Run_Minimized = GUICtrlCreateCheckbox("Run minimized", 16, 416, 89, 17)
$Run_On_Hidden_Mode = GUICtrlCreateCheckbox("Run on hidden mode", 138, 390, 121, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
do 
    $nmsg = GUIGetMsg()
Until $nmsg = $GUI_EVENT_CLOSE

if this is working for you then error is not in the GUI, it's somewhere else in your script

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
#include <IE.au3>
#NoTrayIcon

_IEErrorHandlerRegister ()

Global $oIE1 = _IECreateEmbedded ()
Global $oIE2 = _IECreateEmbedded ()
Global $oIE3 = _IECreateEmbedded ()
;ActiveX Sizes
Global $Left=20 , $Top=65 , $Width=585 , $Height=305

Opt("TrayMenuMode",1)   ; Default tray menu items (Script Paused/Exit) will not be shown.
TrayCreateItem("")
$RestoreItem = TrayCreateItem("Restore")
TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")
TraySetState()

$IniFile = "Settings.ini"
If FileExists ($IniFile) = 1 Then
    $IniRead_First_Link_Input = IniRead ("Settings.ini", "Links", "Link1", "")
    $IniRead_Second_Link_Input = IniRead ("Settings.ini", "Links", "Link2", "")
    $IniRead_Third_Link_Input = IniRead ("Settings.ini", "Links", "Link3", "")
    $IniRead_Run_On_Startup = IniRead ("Settings.ini", "General", "Run on startup", "")
    $IniRead_Refrsh_Every_Input = IniRead ("Settings.ini", "General", "Refresh every", "")
    $IniRead_Run_Minimized = IniRead ("Settings.ini", "General", "Run minimized", "")
    $IniRead_Run_On_Hidden_Mode = IniRead ("Settings.ini", "General", "Run on hidden mode", "")
EndIf
   
#Region ### START Koda GUI section ### Form=d:\vladik\autoit\koda_1.7.0.1\forms\browser new gui.kxf
$Browser = GUICreate("Browser", 631, 450, 191, 121)
$PageControl1 = GUICtrlCreateTab(8, 8, 612, 370)
GUICtrlSetResizing(-1, $GUI_DOCKWIDTH+$GUI_DOCKHEIGHT)
$TabSheet1 = GUICtrlCreateTabItem("First Page")
$First_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$First_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf1_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX1 = GUICtrlCreateObj($oIE1, $Left, $Top, $Width, $Height)
$TabSheet2 = GUICtrlCreateTabItem("Second Page")
$Second_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Second_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf2_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX2 = GUICtrlCreateObj($oIE2, $Left, $Top, $Width, $Height)
$TabSheet3 = GUICtrlCreateTabItem("Third Page")
$Third_Link_Label = GUICtrlCreateLabel("Link", 22, 40, 28, 20)
GUICtrlSetFont(-1, 10, 400, 0, "Arial")
$Third_Link_Input = GUICtrlCreateInput("", 56, 39, 300, 22)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$Surf3_Button = GUICtrlCreateButton("Surf", 368, 38, 80, 23, 0)
GUICtrlSetFont(-1, 8, 400, 0, "Arial")
$GUIActiveX3 = GUICtrlCreateObj($oIE3, $Left, $Top, $Width, $Height)
GUICtrlCreateTabItem("")
$Minimize_To_Tray = GUICtrlCreateButton("Minimize to tray", 525, 385, 95, 25, 0)
$Hide = GUICtrlCreateButton("Hide", 420, 385, 95, 25, 0)
$Options_Group = GUICtrlCreateGroup("Options", 8, 376, 384, 66)
$Run_On_Startup = GUICtrlCreateCheckbox("Run on startup", 16, 390, 89, 17)
$Refresh_Time = GUICtrlCreateLabel("Refresh every", 138, 418, 70, 17)
$Refrsh_Every_Input = GUICtrlCreateInput($IniRead_Refrsh_Every_Input, 214, 411, 40, 21)
$Save_Settings_Button = GUICtrlCreateButton("Save Settings", 278, 389, 98, 45, 0)
$Run_Minimized = GUICtrlCreateCheckbox("Run minimized", 16, 416, 89, 17)
$Run_On_Hidden_Mode = GUICtrlCreateCheckbox("Run on hidden mode", 138, 390, 121, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
do 
    $nmsg = GUIGetMsg()
Until $nmsg = $GUI_EVENT_CLOSE

if this is working for you then error is not in the GUI, it's somewhere else in your script

This script doesn't work for me. I get this error:

post-35029-1213361765_thumb.png

Share this post


Link to post
Share on other sites

Bump...

Please help me.

Share this post


Link to post
Share on other sites

lol, if you get that error, that means you don't have Settings.ini file

make ELSE on If FileExists ($IniFile) = 1 Then for FileExists ($IniFile) = 0

I Got the problem... Now I have to make some changes in the script.

Thanks :)

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