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 

GUI config file.

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



Joined: 15 Oct 2009
Posts: 1

PostPosted: Thu Oct 15, 2009 7:48 pm    Post subject: GUI config file. Reply with quote

is there anyway to save or store my variables from a gui to a text file or configuration file?

In other words, I have a gui that asks the user to input data. If I want it to always retain that information based on a config file that is generated, how do I do that?

[ Moderator!: Moved from Scripts and Functions ]
Back to top
View user's profile Send private message
SKAN



Joined: 26 Dec 2005
Posts: 8688

PostPosted: Thu Oct 15, 2009 7:49 pm    Post subject: Reply with quote

Please refer AHK Documentation for IniRead / IniWrite commands.
Back to top
View user's profile Send private message Send e-mail
mstorey20



Joined: 21 Sep 2009
Posts: 10

PostPosted: Thu Oct 15, 2009 9:18 pm    Post subject: Reply with quote

Here is some code with an example - it is only a piece so it won't "work" but it should help along with the documentation. I had trouble until I found an example.

Code:

#Persistent
#SingleInstance Force
;----------------^^^ Ignore / Do Not Change Above Here ^^^----------------------------------


;***************************************************************************
; READ SETTINGS FROM INI FILE OR BUILD A NEW INI FILE
;***************************************************************************

OnExit, ExitSub
Goto, StoreyQuickNotesInitialize
   



;********************************************************************
; INITIALIZE THE SCRIPT FUNCTION
;********************************************************************

StoreyQuickNotesInitialize:
{

;*************************************************************************************
; IMAGE GRABBER DEFAULT CONFIGURATION OPTIONS
;*************************************************************************************

IMAGECAPTUREFOLDER=c:\StoreyQuickNotes\Images         ; Default Path
IMAGEPROMPT=Patient Name (Last_First - No Commas or Spaces):   ; Default folder prompt

SS_FileType=jpg                     ; Options jpg,png,gif,tif,bmp
SS_ScreenSize=Active                  ; Full, Active, Contents


;****************************************
;Initialize a few Variables each run
;****************************************
SS_FileName=
n=0

;****************************************
;Create a standard path for images
;****************************************
FileCreateDir, %IMAGECAPTUREFOLDER%
if (ErrorLevel)
{
   MsgBox Error Building Default Directory`nPlease verify IMAGECAPTUREFOLDER path in the configuration section.
   return
}
SetWorkingDir, %IMAGECAPTUREFOLDER%
n=0
FileCreateDir, %IMAGECAPTUREFOLDER%\Test_Folder

If (FileExist("C:\StoreyQuickNotes\SQN.ini"))
{
   IniRead, Count_start, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_start
   IniRead, Count_total, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_total
   IniRead, Count_p, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_p
   IniRead, Count_b, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_b
   IniRead, Count_r, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_r
   IniRead, Count_d, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_d
   IniRead, Count_m, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_m
   IniRead, Count_g, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_g

   IniRead, PASSWORD, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, PASSWORD
   IniRead, Name, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Name
   IniRead, MileStone, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Milestone
   SIGNATURE=Electronically Approved: %NAME%

   if (Count_total>MileStone)
   {
      MsgBox Milestone Reached! Please Update your stats on the Support Forum
      Milestone:=IncrementMilestone(Milestone)
      IniWrite, %Milestone%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Milestone
   }
}
else
{
Ini_file=
(
[StoreyQuickNotes]

Install_Date=%A_MM%/%A_DD%/%A_YYYY%
Version=%Version%

PASSWORD=
NAME=

MileStone=500

count_start=0
count_total=0
count_p=0
count_b=0
count_r=0
count_d=0
count_m=0
count_g=0
)
FileAppend, %Ini_file%, c:\StoreyQuickNotes\SQN.ini

   ; DEFINE VARIABLES
   Install_Date=%A_MM%/%A_DD%/%A_YYYY%
   Version=%Version%

   count_start=0
   count_total=0
   count_p=0
   count_b=0
   count_r=0
   count_d=0
   count_m=0
   count_g=0
}

count_start:=count_start+1


;*************************************************************************************
; ON EXITING PROGRAM, UPDATE THE INI FILE
;*************************************************************************************

ExitSub:
{
   If (FileExist("C:\StoreyQuickNotes\SQN.ini"))
   {
      IniWrite, %count_start%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_start
      IniWrite, %count_total%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_total
      IniWrite, %count_p%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_p
      IniWrite, %count_b%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_b
      IniWrite, %count_r%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_r
      IniWrite, %count_d%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_d
      IniWrite, %count_m%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_m
      IniWrite, %count_g%, C:\StoreyQuickNotes\SQN.ini, StoreyQuickNotes, Count_g
   }
   ExitApp
}

_________________
StoreyQuickNotes - An AutoHotkey Project for Radiation Oncology
Back to top
View user's profile Send private message
Display posts from previous:   
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