Jump to content

[Solved itself]Tabbing to a Case/button activates it.


Recommended Posts

When trying to tab my way to the Login-button in my program it instantly activates it even without me pressing anything else than tab.

Tried to make a:

Case Send('{ENTER}')
ExitLoop

But no results.

Is there any other way to make the button activate when I press enter and not activate when tabbed onto?

Thanks for all help :D

#region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_Outfile_x64=..\Compilation\DeloitteADController.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=y
#endregion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <AD.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <EditConstants.au3>


#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 262, 145, 193, 124)
$Username = GUICtrlCreateInput("", 112, 24, 121, 21)
$Password = GUICtrlCreateInput("", 112, 64, 121, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
GUICtrlCreateLabel("Username", 24, 24, 52, 17)
GUICtrlCreateLabel("Password", 24, 64, 50, 17)
$Login = GUICtrlCreateButton("Login", 24, 104, 75, 25)
$Cancel = GUICtrlCreateButton("Cancel", 160, 104, 75, 25)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###



While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $Cancel
Exit
Case Send('{ENTER}')
ExitLoop
Case $Login
ExitLoop
EndSwitch
WEnd


_AD_Open(GUICtrlRead($Username), GUICtrlRead($Password))
If @error Then Exit MsgBox(16, "Active Directory Example Script", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)

Global $iReply = MsgBox(308, "Active Directory Functions - Example 1", "This script adds a user to a group." & @CRLF & @CRLF & _
"Are you sure you want to change the Active Directory?")
If $iReply <> 6 Then Exit

#region ### START Koda GUI section ### Form=
Global $Form1 = GUICreate("Active Directory Functions - Example 1", 514, 124)
GUICtrlCreateLabel("User account (FQDN or samAccountName):", 8, 10, 231, 17)
GUICtrlCreateLabel("Group name (without leading CN=):", 8, 42, 231, 17)
Global $lUser = GUICtrlCreateInput(@UserName, 241, 8, 259, 21)
Global $IGroup = GUICtrlCreateInput("", 241, 40, 259, 21)
Global $BOK = GUICtrlCreateButton("Assign user to group", 8, 72, 121, 33)
Global $BCancel = GUICtrlCreateButton("Cancel", 428, 72, 73, 33, BitOR($GUI_SS_DEFAULT_BUTTON, $BS_DEFPUSHBUTTON))
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###


While 1
Global $nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $BCancel
Exit
Case $BOK
Global $sUser = GUICtrlRead($lUser)
Global $sGroup = GUICtrlRead($IGroup)
ExitLoop
EndSwitch
WEnd



Global $iValue = _AD_AddUserToGroup($sGroup, $sUser)
If $iValue = 1 Then
MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' successfully assigned to group '" & $sGroup & "'")
ElseIf @error = 1 Then
$sStrippedGroup = StringStripWS($sGroup, 8)
Global $iStrippedValue = _AD_AddUserToGroup($sStrippedGroup, $sUser)
If @error = 1 Then
MsgBox(64, "Active Directory Functions - Example 1", "Group '" & $sGroup & "' does not exist")
EndIf
ElseIf @error = 2 Then
MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' does not exist")
ElseIf @error = 3 Then
MsgBox(64, "Active Directory Functions - Example 1", "User '" & $sUser & "' is already a member of group '" & $sGroup & "'")
Else
MsgBox(64, "Active Directory Functions - Example 1", "Return code '" & @error & "' from Active Directory")
EndIf


_AD_Close()
Edited by Akarillon

Challenge accepted!

Link to comment
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
 Share

×
×
  • Create New...