AutoHotkey Community

It is currently May 26th, 2012, 8:29 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: August 20th, 2009, 3:27 am 
Offline

Joined: April 29th, 2009, 12:08 pm
Posts: 45
hello guys, im trying to show what settings are set when my config utility is opened (whats 1 should be ticked, whats 0 shouldnt)

problem is, nothing is getting ticked, plz tell me what im doing wrong

the code:
Code:
Gui, Add, CheckBox, vNum x6 y7 w100 h30 , Numbers
Gui, Add, CheckBox, vSml x6 y57 w100 h30 , Small Letters
Gui, Add, CheckBox, vCpl x6 y107 w100 h30 , Capital letters
Gui, Add, Text, x126 y7 w130 h90 , Welcome to the Password Generator Utility, use the checkboxes on the left to configure what you want in your passwords, then click ok to save the changes
Gui, Add, Button,vSave gOk x126 y107 w60 h30 , Ok
Gui, Add, Button,gCancel x196 y107 w60 h30 , Cancel
Gui, Show, x131 y91 h147 w267, PGCU
IniRead, Numv, settings.ini, settings, numbers
IniRead, Smlv, settings.ini, settings, sletters
IniRead, Cplv, settings.ini, settings, cletters
Num = %Numv%
Sml = %Smlv%
Cpl = %Cplv%
return

Cancel:
ExitApp

Ok:
{
gui,submit
Num:
if Num = 1
{
iniwrite,1,settings.ini,settings,numbers
}
else if Num = 0
{
iniwrite,0,settings.ini,settings,numbers
}
Sml:
if Sml = 1
{
iniwrite,1,settings.ini,settings,sletters
}
else if Sml = 0
{
iniwrite,0,settings.ini,settings,sletters
}
Cpl:
If Cpl = 1
{
iniwrite,1,settings.ini,settings,cletters
}
Else if Cpl = 0
{
iniwrite,0,settings.ini,settings,cletters
}
ExitApp
}


the ini file:
Code:
[settings]
numbers=0
sletters=1
cletters=0

everything else works fine, just showing the settings in the ini file when the utility is launched

thanks in advance guys :)

*edit, this is for the password generator that i have recently released:
http://www.autohotkey.com/forum/viewtopic.php?t=47600

i have realized that certain sites dont like certain characters (numbers, for example) and that the password generator could be used for other things such as generating pin numbers and such so ill be remaking it so it can use the advanced configuration

_________________
frosty the snowman

Ex-AutoIt user

class: intermediate


Last edited by fro01 on August 20th, 2009, 9:01 am, edited 1 time in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 6:10 am 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
wrong order: make checkbox -> show gui -> get value

right order: get value -> make checkbox -> show gui

also, for Checkbox: vNum denotes the output variable 'Num' and Checked%Num% denotes the input variable (converted to a value)

Code:
IniRead, num, settings.ini, settings, numbers
*
*

Gui, Add, CheckBox, Checked%Num% vNum x6 y7 w100 h30 , Numbers
*
*
Gui, Show, x131 y91 h147 w267, PGCU

Num = %Numv%  ; what is this for?

return

*
*

IniWrite, %Num%, settings.ini, settings, numbers

Untested, Hope this helps


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 8:30 am 
Offline

Joined: April 29th, 2009, 12:08 pm
Posts: 45
Code:
 Num = %Numv%

trying to set Num (the checkbox) to Numv (thevalue from the ini file)
cosider the follwing if statement
Code:
 if Num = 1
{
<some iniwrite code>
}

which does work
since:
checked = 1
unchecked = 0
meaning that there must be a way to check a checkbox by assigning a 1 to it

found the solution, tx for your help, using Guicontrol, now it works like a charm :)

working code [full]
Code:
/* code for the config utility which will be used by the password generator

By: Frosty
*/
#singleinstance force

IniRead, Numv, settings.ini, settings, numbers
IniRead, Smlv, settings.ini, settings, sletters
IniRead, Cplv, settings.ini, settings, cletters

Gui, Add, CheckBox, vNum x6 y7 w100 h30 , Numbers
Gui, Add, CheckBox, vSml x6 y57 w100 h30 , Small Letters
Gui, Add, CheckBox, vCpl x6 y107 w100 h30 , Capital letters
Gui, Add, Text, x126 y7 w130 h90 , Welcome to the Password Generator Utility, use the checkboxes on the left to configure what you want in your passwords, then click ok to save the changes
Gui, Add, Button,vSave gOk x126 y107 w60 h30 , Ok
Gui, Add, Button,gCancel x196 y107 w60 h30 , Cancel
Gui, Show, x131 y91 h147 w267, PGCU
if Numv = 1
{
GuiControl, , Button1,1
}
if Smlv = 1
{
GuiControl, , Button2,1
}
if Cplv = 1
{
GuiControl, , Button3,1
}
return

Cancel:
ExitApp

Ok:
{
gui,submit
if Num = 0
{
if Sml = 0
{
if Cpl = 0
{
MsgBox,0,Warning, Config has detected that all checkboxes are unchecked, this means that the password generator will not work with the selected configuration! Please check your configuration before attempting to save again. Now returning you to the config utility
IniRead, Numv, settings.ini, settings, numbers
IniRead, Smlv, settings.ini, settings, sletters
IniRead, Cplv, settings.ini, settings, cletters
Gui, Show, x131 y91 h147 w267, PGCU
if Numv = 1
{
GuiControl, , Button1,1
}
if Smlv = 1
{
GuiControl, , Button2,1
}
if Cplv = 1
{
GuiControl, , Button3,1
}
return
}
}
}
Num:
if Num = 1
{
iniwrite,1,settings.ini,settings,numbers
}
else if Num = 0
{
iniwrite,0,settings.ini,settings,numbers
}
Sml:
if Sml = 1
{
iniwrite,1,settings.ini,settings,sletters
}
else if Sml = 0
{
iniwrite,0,settings.ini,settings,sletters
}
Cpl:
If Cpl = 1
{
iniwrite,1,settings.ini,settings,cletters
}
Else if Cpl = 0
{
iniwrite,0,settings.ini,settings,cletters
}
ExitApp
}

any questions with this code let me know, and ill tell you what it does ;)
no more problems here, just maybe some feedback/improvements

tx again

_________________
frosty the snowman

Ex-AutoIt user

class: intermediate


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 20th, 2009, 7:07 pm 
Offline

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Hi Frosty,

Congrats on getting your code working. I have a few suggestions. Simplify ...
Code:
if Cplv = 1
{
GuiControl, , Button3,1
}

If the value read from the INI file was written by this program, then the value read back has already been verified
Code:
GuiControl, , Button3,%Cplv% ; for all three controls




move 'show' AFTER all updates
Code:
Gui, Show, x131 y91 h147 w267, PGCU

Code:
if Num = 1
{
iniwrite,1,settings.ini,settings,numbers
}
else if Num = 0
{
iniwrite,0,settings.ini,settings,numbers
}

The value written to the INI file was verified by the ckeckbox
Code:
iniwrite,%Num%,settings.ini,settings,numbers


Using Num for both a label and a variable is confusing
Code:
Num:
if Num = 1
{


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, Pulover, tomoe_uehara and 51 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