Old 2nd August 2005, 18:51   #1
0001001
Junior Member
 
Join Date: Jul 2005
Posts: 6
Ask user for username and password and write to variable ?

Hi,

I need to ask the user for a username and a password and write that to two variables.
I need to do that because I need a customized shortcut to my software.

So how can I ask the user for a username and a password and save that in a variable?

Thanks in advance
0001001 is offline   Reply With Quote
Old 3rd August 2005, 00:20   #2
0001001
Junior Member
 
Join Date: Jul 2005
Posts: 6
I've found out that a custom page would fit my needs, but I have some trouble making one.

Thats my ini file I've created:
PHP Code:
[Settings]
NumFields=2

[Field 1]
Type=Text
State
=Text
Left
=173
Right
=296
Top
=45
Bottom
=58

[Field 2]
Type=Text
State
=Text
Left
=173
Right
=296
Top
=62
Bottom
=75 
But I don't have any clue how to create an custom page.
Can someone please help me creating a custom page, which reads the user input from the two textfields.

thanks in advance
0001001 is offline   Reply With Quote
Old 3rd August 2005, 05:37   #3
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
You seem to have a good start. But, I'd make Field #2 of type=Password. (and take remove the "state" statement--you probably want them blank.)

If you don't have it yet, I'd suggest downloading HM NIS Edit . It will make creating installoptions pages much easier.

The installoptions docs and examples included with NSIS should give you plenty of info about how to display the page and read the values.

Joel (aka Lobo Lunar) has a DiaglogsEx plugin that might also off another option. But, it's in the form of a dialog, though, not a custom page. (Just depends on your taste.)

It's on the wiki, which I can't get to at the moment, but maybe you can if you're curious...
Comperio is offline   Reply With Quote
Old 3rd August 2005, 07:00   #4
0001001
Junior Member
 
Join Date: Jul 2005
Posts: 6
i will give it a try. thanks a lot
0001001 is offline   Reply With Quote
Old 3rd August 2005, 11:03   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I wonder if it would be worth writing a plugin for this which can display different types of pages from username and password to say serial code boxes.

Some may argue a custom page will work fine, but it has no password security (the password or serial will be stored in the INI file).

-Stu
Afrow UK is offline   Reply With Quote
Old 3rd August 2005, 16:46   #6
Comperio
Major Dude
 
Comperio's Avatar
 
Join Date: Jan 2005
Location: Oregon Coast
Posts: 737
Interesting thought...
I guess it depends on how secure you need to be. But overall, I think this sounds like an excellenet idea.

Would it be possible for the plugin to integrate with the existing InstallOptions format? This would give the best of both worlds--the designer could still customize their page with the existing installoptions plus could keep things secure. (might require some more brainstorming....)

edit:
Just some more food for thought:
If there was just some way to grab the input string of the password while the user was typing, then you could either save the results in a variable or write them to the INI file in an encrypted form. (The 'encryption' could be done on the fly by a function in the install. It could be something very simple like outputting the characters in hex or more advanced like rearranging the ASCII codes for each character.)


The InstallOptionsEx plugin I noticed has something that would almost work: There is a speical notify for text and password boxes (ONTEXTCHANGE) that is supposed to trigger an event when
Quote:
when the user changes the state of the text on the control (i.e. when writing) before the change appears on screen.
.

Anyway, like I said, just some things to think about...

Last edited by Comperio; 3rd August 2005 at 19:12.
Comperio is offline   Reply With Quote
Old 4th August 2005, 00:35   #7
0001001
Junior Member
 
Join Date: Jul 2005
Posts: 6
Quote:
Originally posted by Comperio
You seem to have a good start. But, I'd make Field #2 of type=Password. (and take remove the "state" statement--you probably want them blank.)

If you don't have it yet, I'd suggest downloading HM NIS Edit . It will make creating installoptions pages much easier.

The installoptions docs and examples included with NSIS should give you plenty of info about how to display the page and read the values.

Joel (aka Lobo Lunar) has a DiaglogsEx plugin that might also off another option. But, it's in the form of a dialog, though, not a custom page. (Just depends on your taste.)

It's on the wiki, which I can't get to at the moment, but maybe you can if you're curious...
I've tried and tried and tried but it just doesn't work.
I don't need a user/pwd authentification I just need two textfields were the user enters his information and that info is stored in two variables.
So DialogsEx isn't the right thing for me. I've taken a look at the examples too but I can't find anything there that would fit my needs.
Can someone please give me a hint how to create a custom page based on my ini file.
thanks in advance
0001001 is offline   Reply With Quote
Old 4th August 2005, 11:29   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
It's quite simple:
code:

[Settings]
NumFields=2

[Field 1]
Type=Text
Left=173
Right=296
Top=45
Bottom=58

[Field 2]
Type=Password
Left=173
Right=296
Top=62
Bottom=75



You might also want to put some labels on there too.

You need to read the values in the page's Leave function with MUI_INSTALLOPTIONS_READ. There's an InstallOptions example in the Examples\Modern UI folder.

-Stu
Afrow UK is offline   Reply With Quote
Old 4th August 2005, 12:19   #9
0001001
Junior Member
 
Join Date: Jul 2005
Posts: 6
I've solved problem already:



Here's the code I use(Taken from some examples):

PHP Code:
!define TEMP1 $R0 ;Temp variable
!define TEMP2 $R1 ;Temp variable
.
.
.
!
insertmacro MUI_PAGE_WELCOME


;Things that need to be extracted on startup (keep these lines before any File command!)
;
Only useful for BZIP2 compression
;Use ReserveFile for your own InstallOptions INI files too!

ReserveFile "${NSISDIR}\Plugins\InstallOptions.dll"
ReserveFile "test.ini"

;Order of pages
Page custom SetCustom ValidateCustom 
": Testing InstallOptions" ;Custom pageInstallOptions gets called in SetCustom.




Function .
onInit

  
;Extract InstallOptions files
  
;$PLUGINSDIR will automatically be removed when the installer closes

  InitPluginsDir
  File 
/oname=$PLUGINSDIR\test.ini "test.ini"

FunctionEnd

Function SetCustom

  
;Display the InstallOptions dialog

  Push 
${TEMP1}

    
InstallOptions::dialog "$PLUGINSDIR\test.ini"
    
Pop ${TEMP1}

  
Pop ${TEMP1}
FunctionEnd
.
.
.
Section "Software"
  
;Get Install Options dialog user input

  ReadINIStr 
${TEMP1"$PLUGINSDIR\test.ini" "Field 1" "State"
  
ReadINIStr ${TEMP2"$PLUGINSDIR\test.ini" "Field 2" "State"
.
.

0001001 is offline   Reply With Quote
Old 22nd August 2005, 14:59   #10
Thomas1982
Guest
 
Posts: n/a
Hi,

I'm sorry; I am an NSIS newbie an I want to create a custom page in which the user is being asked several values, e.g. username etc.
I can generate this custom page easily, using an ini-file called customPage.ini. But at the moment I try to read out the values the user entered I fail. And since I am failing for ~4 hours now, I ask you to explain to me how I can do this. I have studied the examples at the NSIS homepage, I have read (almost) the whole forum, and I have tried to understand and reuse the code example posted above - but failed.
If somebody could explain the last example or write a few lines of code which tell me what is to be done, I would be very thankful!
  Reply With Quote
Old 22nd August 2005, 15:23   #11
Thomas1982
Guest
 
Posts: n/a
Alright, I got it. Finally *sigh*
  Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump