llolslim Posted June 17, 2008 Share Posted June 17, 2008 Hi all, As i am struggling to include an entire GUI in my project, I am having to stick with two seperate input boxes, first for username, second for pasword. My question is .. is it possible to customise them a little bit? For example, I dont want a cancel button or the ability to close the box. If you see my script it will make more sense Oh, of course if someone can suggest a way of using the gui instead, I would be MOST grateful. thanks in advancedrivemapWORKING.au3 Link to comment Share on other sites More sharing options...
newbiescripter Posted June 17, 2008 Share Posted June 17, 2008 I don't think that you can modify the inputbox, but you could create a function and within that you could create your own inputbox by designing a GUI for it. regards Link to comment Share on other sites More sharing options...
llolslim Posted June 17, 2008 Author Share Posted June 17, 2008 (edited) I don't think that you can modify the inputbox, but you could create a function and within that you could create your own inputbox by designing a GUI for it.regardshi thanks for the reply.Please excuse my lack of understanding, but I think what you're saying I have already tried .. here so the username and password check are inside a function. Unfortuantely it didnt work.I've already had some amazing support and help in this thread to get it all started.i am working with adults with learning disabilities which is why it would be handy to be able to re-design the gui thank you Edited June 17, 2008 by llolslim Link to comment Share on other sites More sharing options...
enaiman Posted June 18, 2008 Share Posted June 18, 2008 Have a look at this: expandcollapse popup#include <ExcelCOM_UDF.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Process.au3> ;replaced your whole block for running 2 commands with these 3 lines _RunDos("net use x: /delete") Sleep(1000) _RunDos("taskkill /f /im explorer.exe") $sFilePath = @WorkingDir & "\book1.xls" ;Location of Excel spreadsheet $oExcel = _ExcelBookOpen($sFilePath, 0, False, "", "") ;Open the Excel document $sRangeOrRowStart = "A2:A5";This is the field I want the search to start at. Opt("GUIOnEventMode", 1) #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Authentication Form", 244, 159, 193, 125, BitOR($WS_SYSMENU,$WS_CAPTION,$WS_POPUP,$WS_POPUPWINDOW,$WS_BORDER,$WS_CLIPSIBLINGS)) GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close") GUICtrlCreateLabel("Please enter your Username and Password ", 8, 8, 228, 17, $SS_CENTER) GUICtrlCreateLabel("Username", 8, 45, 52, 17) $UsernameInput = GUICtrlCreateInput("", 80, 43, 153, 21) GUICtrlCreateLabel("Password", 8, 80, 50, 17) $PasswordInput = GUICtrlCreateInput("", 80, 78, 153, 21) $OKButton = GUICtrlCreateButton("OK", 80, 120, 97, 25, 0) GUICtrlSetOnEvent(-1, "OKButtonclick") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Sleep(100) WEnd Func Form1Close() _ExcelBookClose($oExcel) Exit EndFunc Func OKButtonclick() ;what happens when you click OK $username = GUICtrlRead($UsernameInput) $password = GUICtrlRead($PasswordInput) $whatever = _ExcelFindInRange($oExcel, $username, $sRangeOrRowStart, 1, 800, 800, 0, 2, False, "") ;Searches to see if the username is on the list If $whatever[0][0] = 1 then ;If the username is found on the list execute the following For $x = 1 to $whatever[0][0] $excelPassword = "B" & $whatever[$x][3] ;Setting this equal to the password cell that corresponds with the username entered. $field =_ExcelReadCell($oExcel, $excelPassword, 1) ;reads that password cell. $driveMapPath = "C" & $whatever[$x][3] ;Setting this equal to the path-to-be-mapped cell that corresponds with the username entered. If $field = $password Then ;checking to make sure the password entered matches the password in the cell ;use this if they need the same username and password to map the drive ;comment out or delete if not used DriveMapAdd("X:", "\\PC3\" & $username) ;maps the drive based on the info attained above. ;Send("#r") ;WinWaitActive("Run") ;Send("cmd") ;Send("{enter}") ;WinWaitActive("C:\WINDOWS\system32\cmd.exe") WinActivate("C:\WINDOWS\system32\cmd.exe") Send("explorer.exe") Send("{Enter}") WinClose("C:\WINDOWS\system32\cmd.exe") ;If the drive mapping doesn't require a username and password just use this one ;comment out or delete if not used ;DriveMapAdd("X:", $driveMapPath) Sleep(3000) ;Uncomment below if you want the mapped drive to automatically open ;Run('c:\windows\explorer.exe X:\') Form1Close() Else ;If the password entered does NOT matches the password in the cell execute the following TryAgain("Password") Return EndIf Next else ;If the username is NOT found on the list execute the following TryAgain("Username") Return EndIf EndFunc Func TryAgain($varb) ;just a message box to offer the user a chance to reenter credentials $iMsgBoxAnswer = MsgBox(52,"Error:","Incorrect "&$varb&". Would you like to try again?") Select Case $iMsgBoxAnswer = 6 ;Yes Case $iMsgBoxAnswer = 7 ;No Form1Close() EndSelect EndFunc Hope it is what you were looking for. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
llolslim Posted June 18, 2008 Author Share Posted June 18, 2008 thank you SO much!! With a little bit of playing around, I now have it EXACTLY how I need it THANK YOU SO MUCH!! Credit to enaiman and muncherw Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now