AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Readini file issues

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
BradleyS



Joined: 20 Sep 2005
Posts: 100

PostPosted: Sat Aug 09, 2008 2:01 pm    Post subject: Readini file issues Reply with quote

I'm having a problem trying to get the DDL and Checkbox to read the information from the ini file.

It writes to the ini file OK and the edit boxes work fine, it just doesn't retain(Read) the last state from the ini file with regards to the DDL and Checkbox.

Could somebody give me an idea of what I am doing wrong.

Code:
#NoEnv
#SingleInstance force

IfNotExist C:\MyFiles
   FileCreateDir, C:\MyFiles
SetWorkingDir, C:\MyFiles

IniRead, FirstNum, MySettings.ini, 1stNum, FirstNum, %A_space%
Gui, Add, Edit, x12 y18 w135 h20 vFirstNum, %FirstNum%

IniRead, SecondNum, MySettings.ini, 2ndNum, SecondNum, %A_space%
Gui, Add, Edit, x12 y38 w135 h20 vSecondNum, %SecondNum%

IniRead, MyItems, MySettings.ini, DDLs, MyItems,%A_space%
Gui, Add, DDL, vMyItems, Item 1|Item 2|Item 3

IniRead, MyBox, MySettings.ini, DDLs, MyBox, Tickbox
Gui, Add, Checkbox, vMyBox %MyBox%

Gui, Add, Button, w50 h20 gOK, OK
Gui, Show

!b::
OK:
Gui, Submit  ; Save the input from the user to each control's associated variable.
Iniwrite, %FirstNum%, MySettings.ini, 1stNum, FirstNum
Iniwrite, %SecondNum%, MySettings.ini, 2ndNum, SecondNum
Iniwrite, %MyItems%, MySettings.ini, DDL, MyItems
Iniwrite, %MyBox%, MySettings.ini, Tickbox, MyBox



ExitApp


Thank you
Back to top
View user's profile Send private message
Guest






PostPosted: Sat Aug 09, 2008 2:21 pm    Post subject: Reply with quote

Code:
#NoEnv
#SingleInstance force

IfNotExist C:\MyFiles
   FileCreateDir, C:\MyFiles
SetWorkingDir, C:\MyFiles

IniRead, FirstNum, MySettings.ini, 1stNum, FirstNum, %A_space%
Gui, Add, Edit, x12 y18 w135 h20 vFirstNum, %FirstNum%

IniRead, SecondNum, MySettings.ini, 2ndNum, SecondNum, %A_space%
Gui, Add, Edit, x12 y38 w135 h20 vSecondNum, %SecondNum%

IniRead, MyItems, MySettings.ini, DDL, MyItems, 0
Gui, Add, DDL, vMyItems AltSubmit Choose%MyItems%, Item 1|Item 2|Item 3

IniRead, MyBox, MySettings.ini, Tickbox, MyBox, 0
Gui, Add, Checkbox, vMyBox Checked%MyBox%

Gui, Add, Button, w50 h20 gOK, OK
Gui, Show

!b::
OK:
Gui, Submit  ; Save the input from the user to each control's associated variable.
Iniwrite, %FirstNum%, MySettings.ini, 1stNum, FirstNum
Iniwrite, %SecondNum%, MySettings.ini, 2ndNum, SecondNum
Iniwrite, %MyItems%, MySettings.ini, DDL, MyItems
Iniwrite, %MyBox%, MySettings.ini, Tickbox, MyBox



ExitApp
Back to top
BradleyS



Joined: 20 Sep 2005
Posts: 100

PostPosted: Sat Aug 09, 2008 2:54 pm    Post subject: Reply with quote

Brilliant!!!

Thank you it works a treat now.
Back to top
View user's profile Send private message
BradleyS



Joined: 20 Sep 2005
Posts: 100

PostPosted: Sun Aug 10, 2008 8:19 am    Post subject: Reply with quote

Just when I thought it was all over Rolling Eyes

The previous code is great, but the DDL code uses a position number and after reading the help file, I noticed that if I removed "Altsubmit" it would enter the actual DDL text entry into the ini file.

I need the text entry in the ini file, as I will be using %MyItems% later on in a SendInput command, so having the DDL position number won't work, I need the text shown in the DDL.

However, because I have removed "Altsubmit" it won't read the text entry from the ini file, it always appears blank.
I can't seem to find an alternative in the help file.
Is it possible for IniRead to read the Value written as text for a DDL?

My current code is
Code:
#NoEnv
#SingleInstance force

IfNotExist C:\MyFiles
   FileCreateDir, C:\MyFiles
SetWorkingDir, C:\MyFiles

IniRead, FirstNum, MySettings.ini, 1stNum, FirstNum, %A_space%
Gui, Add, Edit, x12 y18 w135 h20 vFirstNum, %FirstNum%

IniRead, SecondNum, MySettings.ini, 2ndNum, SecondNum, %A_space%
Gui, Add, Edit, x12 y38 w135 h20 vSecondNum, %SecondNum%

IniRead, MyItems, MySettings.ini, DDL, MyItems, 0
Gui, Add, DDL, vMyItems Choose%MyItems%, Item 1|Item 2|Item 3

IniRead, MyBox, MySettings.ini, Tickbox, MyBox, 0
Gui, Add, Checkbox, gMyBox vMyBox Checked%MyBox%

Gui, Add, Button, w50 h20 gOK, OK
Gui, Show

MyBox:
GuiControlGet, MyBox, , MyBox
If MyBox=1
{
Gui, Submit, NoHide
GuiControl, Enable%MyBox%, MyItems
return
}
If MyBox=0
{
GuiControl, Enable%MyBox%, MyItems
return
}
return

!b::
OK:
Gui, Submit  ; Save the input from the user to each control's associated variable.
Iniwrite, %FirstNum%, MySettings.ini, 1stNum, FirstNum
Iniwrite, %SecondNum%, MySettings.ini, 2ndNum, SecondNum
Iniwrite, %MyItems%, MySettings.ini, DDL, MyItems
Iniwrite, %MyBox%, MySettings.ini, Tickbox, MyBox

ExitApp
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group