Jump to content



Photo

_LoginBox


  • Please log in to reply
48 replies to this topic

#1 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 10 October 2007 - 08:54 AM

_LoginBox UDF


:) A simple script that shows a customizable login box, with User, Password, Prompt etc ;)

Current Version: 4

Last Updated: 6 Febuary 2009

Download Link
(Direct)

This script is fairly simple. It shows a customizable "login box", housing a username and password field, along with user-defined options. It can easily be added to you script. The download includes the function along with the example.

PLEASE NOTE: THIS FUNCTION IS NOT DESIGNED TO DO ANY OF THE FOLLOWING; AUTOMATICALLY LOG YOU INTO A WEBPAGE/PROGRAM/WINDOWS/ETC, STORE YOUR PASSWORDS (THIS FUNCTION RECEIVES THE USERNAME AND PASSWORD, THEN PASSES IT TO THE SCRIPT USING THE RETURN VALUE). IT IS NOT DESIGNED TO DO ANY OF THESE THINGS, SO THEY WILL NOT BE IMPLEMENTED.

Comment Appreciated. Enjoy :P

Thanks To:
JerryD
GEOSoft

Changelog:
UPDATED 3! Thanks GeoSoft, a whole ton of updates to the function. (August 20 2008)
UPDATED 2! I think I have a way to stop the errors from popping up. Just a nuther parameter... (October 11 2007)
UPDATED! Thanks to JerryD's ideas, this is so much better. The timeout does get annoying though... Comments on how that part could be better appreciated. (October 11 2007)
INITIAL VERSION! October 10 2007

Edited by BrettF, 02 August 2009 - 08:57 AM.








#2 ashley

ashley

    Universalist

  • Banned (NOT IN USE)
  • 1,044 posts

Posted 10 October 2007 - 11:28 AM

No offence...

BUT if you use koda the gui is already made for you!

#3 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 10 October 2007 - 11:30 AM

It Is? Where? I don't see one. Never have... No offence taken... And tell me. Does KODA do anything else with the GUI? Create the functions... Set the errors... I think not.

#4 JerryD

JerryD

    Polymath

  • Active Members
  • PipPipPipPip
  • 247 posts

Posted 10 October 2007 - 02:16 PM

It Is? Where? I don't see one. Never have... No offence taken... And tell me. Does KODA do anything else with the GUI? Create the functions... Set the errors... I think not.

Bert - don't worry about that (and I don't know what ashley means by the gui is already made for you anyway). It's a nice enough function that I'm planning on using it soon, although with a few modifications...
  • Your default values in the function declaration for $left and $top set the values to 0 and put the login box in the top left corner of the screen, but the default -1 centers it on the screen. It doesn't really matter which it is, it's just inconsistent (using no parameter should behave the same as using the -1 parameter).
  • Once the password is typed in, hitting [Enter] doesn't do anything - you have to hit [OK]. Adding the line GUICtrlSetState($okbtn, $GUI_DEFBUTTON) makes the OK button the default action when [Enter] is hit.
  • I would use seterror differently. Right now the function returns a value (array) if it works, but returns ??? if Cancel or Exit is returned. I would return 0 in those lines. Your SetError(0, 1) is setting @error to 0, and @extended to 1 (or 2 if timed out). It would be more effective if you used SetError(1, 1,0) for returning Cancel/Exit and SetError(1, 2,0) for the function timing out. That way, you can use either If NOT _LoginBox() or If @error.
On my enhancement list:
  • rework the GUI to use all relative positioning so that buttons, labels, etc. are more dynamic relative to the size of the size of the form
  • Restrict the minimum size allowed for all dimenstions (along with item above)
  • allow setting the active control to either the username field or the password field
  • change the default timeout to 0 and change the line to Case TimerDiff($time) > $timeout And $timeout (I think it would be a tad quicker)
And please keep in mind, I wouldn't even waste my time posting if the function wasn't worth the trouble - it's fundamentally a very nice funtion. And I will NOT be offended if you couldn't care less about what I think of it either. My only intent is to compliment your work.

#5 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 10 October 2007 - 08:45 PM

Bert - don't worry about that (and I don't know what ashley means by the gui is already made for you anyway). It's a nice enough function that I'm planning on using it soon, although with a few modifications...

  • Your default values in the function declaration for $left and $top set the values to 0 and put the login box in the top left corner of the screen, but the default -1 centers it on the screen. It doesn't really matter which it is, it's just inconsistent (using no parameter should behave the same as using the -1 parameter).
  • Once the password is typed in, hitting [Enter] doesn't do anything - you have to hit [OK]. Adding the line GUICtrlSetState($okbtn, $GUI_DEFBUTTON) makes the OK button the default action when [Enter] is hit.
  • I would use seterror differently. Right now the function returns a value (array) if it works, but returns ??? if Cancel or Exit is returned. I would return 0 in those lines. Your SetError(0, 1) is setting @error to 0, and @extended to 1 (or 2 if timed out). It would be more effective if you used SetError(1, 1,0) for returning Cancel/Exit and SetError(1, 2,0) for the function timing out. That way, you can use either If NOT _LoginBox() or If @error.
On my enhancement list:
  • rework the GUI to use all relative positioning so that buttons, labels, etc. are more dynamic relative to the size of the size of the form
  • Restrict the minimum size allowed for all dimenstions (along with item above)
  • allow setting the active control to either the username field or the password field
  • change the default timeout to 0 and change the line to Case TimerDiff($time) > $timeout And $timeout (I think it would be a tad quicker)
And please keep in mind, I wouldn't even waste my time posting if the function wasn't worth the trouble - it's fundamentally a very nice funtion. And I will NOT be offended if you couldn't care less about what I think of it either. My only intent is to compliment your work.

Thankyou Jerry :) That's the type of feedback I like. :P I will take that all on board, and when I get out of bed, I will fix it up when I am at school. Thankyou ;)

#6 Nahuel

Nahuel

    To Err is human, to Arr is pirate.

  • Active Members
  • PipPipPipPipPipPip
  • 1,841 posts

Posted 10 October 2007 - 09:09 PM

very nice Bert. I love all the options it has, very professional.

#7 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 10 October 2007 - 09:11 PM

Thankyou :)

#8 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 10 October 2007 - 09:17 PM

I like the layout, add those great suggestions by JerryD and the UDF will be a lot better. :)
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.

#9 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 10 October 2007 - 10:46 PM

Ok. I have added some of JerryD's request. First Post Updated.

#10 zFrank

zFrank

    Polymath

  • Banned (NOT IN USE)
  • 225 posts

Posted 01 August 2008 - 09:20 AM

you have done really a good job. i am going to use it in my program. Thanks!
GSM Expert but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy" If @Error Then $Life = "Risk"

#11 smartee

smartee

    Hippies.They're everywhere.

  • Active Members
  • PipPipPipPipPipPip
  • 653 posts

Posted 02 August 2008 - 02:13 PM

great work man you should add in call authentication too.

#12 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,563 posts

Posted 02 August 2008 - 03:58 PM

Good work Brett.
Tidy is reporting errors but I don't see any in the script so I suspect it's just Tidy.

Edit. Why are you allowing defaults for the username and password? Isn't the purpose of a login dialog to force the user to enter those values? Personally I would remove those two parameters, but that's just me.

Edit 2. I solved the Tidy Errors (code available) but there is one error that I just spotted.

$Label1 = GUICtrlCreateLabel("Password:", 4, 72, 62, 17)     GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") $Label1 = GUICtrlCreateLabel("Username:", 4, 44, 64, 17)

Both inputs have the same variable name. But no matter, because you don't need to name them anyway since they are not referenced again.

Edited by GEOSoft, 02 August 2008 - 05:33 PM.

GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#13 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,563 posts

Posted 02 August 2008 - 05:35 PM

great work man you should add in call authentication too.

What do you mean by "call authentication"? Example?
GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#14 zFrank

zFrank

    Polymath

  • Banned (NOT IN USE)
  • 225 posts

Posted 19 August 2008 - 08:57 PM

its good, i was trying to do something like this. Thanks for this.
GSM Expert but not AutoIt :DProud to be Admin Of : http://www.gsmhosting.net/visit my Forum... http://www.gsmhosting.net/vbb/index.php
$Life = "Happy" If @Error Then $Life = "Risk"

#15 TehWhale

TehWhale

    Whalee..

  • Banned (NOT IN USE)
  • 1,482 posts

Posted 19 August 2008 - 09:14 PM

You have this setup all whack...

#include <GUIConstants.au3> #include <EditConstants.au3> $ret = _LoginBox("Enter Credentials", "Please enter you username and password", "username", "password", -1, -1, -1, -1, -1, 0) If Not @error Then     MsgBox(0, "Credentails Returned", "Username: " & $ret[0] & @CRLF & "Password: " & $ret[1]) EndIf


That doesn't work. It doesn't give me the info when i press ok, but this does:

#include <GUIConstants.au3> #include <EditConstants.au3> $ret = _LoginBox("Enter Credentials", "Please enter you username and password", "username", "password", -1, -1, -1, -1, -1, 0) If @error Then     MsgBox(0, "Credentails Returned", "Username: " & $ret[0] & @CRLF & "Password: " & $ret[1]) EndIf



EDIT: And -1 doesn't work for the timeout, you have to have 0...

EDIT: You also need EditConstants included or else it wil error out with $ES_Password.

Edited by Alienware, 19 August 2008 - 09:17 PM.


#16 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 19 August 2008 - 10:32 PM

GeoSoft did some work, and I'll post it when I get more time to fix it all up... Soon I promise! ;)

#17 BrettF

BrettF

    My Drunk Monkey Guerilla is gonna getcha!

  • MVPs
  • 7,662 posts

Posted 20 August 2008 - 07:46 AM

Updated! Thanks GeoSoft!

#18 TehWhale

TehWhale

    Whalee..

  • Banned (NOT IN USE)
  • 1,482 posts

Posted 20 August 2008 - 02:46 PM

Very nice Brett. What happened to the default username/password spot? Also, maybe you should have at the very end a $hHwnd parameter, like the messagebox does.

#19 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,563 posts

Posted 20 August 2008 - 05:24 PM

Very nice Brett. What happened to the default username/password spot? Also, maybe you should have at the very end a $hHwnd parameter, like the messagebox does.

having a default password makes no sense at all. The idea is to force someone to enter the information. If you used default username and password then all that was required was to click the OK button, which anyone could do. That bypasses the security that you wanted to begin with.
GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#20 Anteaus

Anteaus

    Adventurer

  • Active Members
  • PipPip
  • 122 posts

Posted 20 August 2008 - 07:05 PM

You might be able to pull a few coding tips from this, it's open-source anyway and mostly written in (oh, you know what...)

http://sourceforge.net/projects/mylogon




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users