Sign in to follow this  
Followers 0
dontask

Help with Drivemapadd using GUICtrlCreateInput

4 posts in this topic

I need some help here. Yes I am a newbie with Autoit. I have no trouble mapping using InputBox but Im having all sorts of trouble using

GUICtrlCreateInput. Im sure Im missing something simple. Any help would be appreciated. Thanks

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=D:\Downloads\koda_1.7.2.0\Forms\Form2.kxf
$Form1 = GUICreate("Form1", 645, 239, 192, 124)
$Button1 = GUICtrlCreateButton("Backup", 96, 56, 89, 33, $WS_GROUP)
$Button2 = GUICtrlCreateButton("Restore", 266, 57, 89, 33, $WS_GROUP)
$Button3 = GUICtrlCreateButton("Exit", 434, 58, 89, 33, $WS_GROUP)
$Label1 = GUICtrlCreateLabel("RTS Backup and restore script. This window will close when the process is complete.", 28, 16, 588, 20)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Checkbox1 = GUICtrlCreateCheckbox("Map network drive", 96, 150, 193, 25)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
$Computername = GUICtrlCreateInput("", 310, 130, 121, 21)
$UserID = GUICtrlCreateInput("", 454, 132, 121, 21)
$Driveletter = GUICtrlCreateInput("e:\", 309, 185, 57, 21)
$Password = GUICtrlCreateInput("", 455, 184, 121, 21,$ES_PASSWORD)
$Label2 = GUICtrlCreateLabel("Server", 311, 109, 35, 17)
$Label3 = GUICtrlCreateLabel("Drive Letter", 309, 164, 59, 17)
$Label4 = GUICtrlCreateLabel("User Name", 455, 111, 57, 17)
$Label5 = GUICtrlCreateLabel("Password", 455, 163, 50, 17)
$Group1 = GUICtrlCreateGroup("Mapping", 63, 99, 540, 119)
GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif")
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
    ;Start Back------------------------------------------------------------ 
Case $Button1
    $str = InputBox("Backup Name","Enter your Windows user name:", @UserName )
        $drv = InputBox("Drive letter","What drive do you want to back up to:", "e:\" )
    ;map drive ------------------------------------------------------------
    if GUICtrlRead ($Checkbox1) = $GUI_CHECKED Then
       DriveMapAdd ($Driveletter,"\\" & $Computername & "\backup", 0, $UserID, $Password)
       MsgBox("","",$Computername);only for testing
    EndIf
    ;end map drive -------------------------------------------------------
    sleep (1000)
    ;Check if backup is on the drive already

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi,

you mixed ControlId's with variables.

See helpfile GUICtrlCreateInput:

Success: Returns the identifier (controlID) of the new control into your variables, e.g. $Driveletter.

Try:

DriveMapAdd (GUICtrlRead ($Driveletter),"\\" & GUICtrlRead ($Computername) & "\backup", 0, GUICtrlRead ($UserID), GUICtrlRead ($Password))

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

Thanks Ill give that a try!

Share this post


Link to post
Share on other sites

Worked like a champ. Thanks again for your help.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0