AutoHotkey Community

It is currently May 27th, 2012, 12:15 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: GUI config file.
PostPosted: October 15th, 2009, 8:48 pm 
Offline

Joined: October 15th, 2009, 8:45 pm
Posts: 1
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 ]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2009, 8:49 pm 
Offline
User avatar

Joined: December 26th, 2005, 4:40 pm
Posts: 8776
Please refer AHK Documentation for IniRead / IniWrite commands.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: October 15th, 2009, 10:18 pm 
Offline

Joined: September 21st, 2009, 1:25 am
Posts: 10
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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, Google [Bot], Leef_me, Pulover, rjgatito, XstatyK, Yahoo [Bot] and 20 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group