Sign in to follow this  
Followers 0
kor

GuiCtrlSendToDummy problem

13 posts in this topic

#1 ·  Posted (edited)

If _IsPressed("0D") Then ; enter button
For $i = 1 To 10
If GUICtrlGetHandle($aControls[$i]) = _WinAPI_GetFocus() Then GUICtrlSendToDummy($cDummy)
Next
While _IsPressed("0D")
Sleep(10)
WEnd
EndIf

This code works, but I have a message box pop up if any of the $aControls are null. The problem is if I hit enter to acknowledge the message box this code pops up the message box again and again.

Is there any way to be able to hit enter on the message box without this code interrupting that as a fire to the dummy control?

Edited by kor

Share this post


Link to post
Share on other sites



Your guess is as good as mine, because that code doesn't run by itself there's no way to tell what you're doing in the script.

Think about this, if you read this thread with absolutely no idea what was being discussed, would what you posted be of any help whatsoever to anyone?

Post your script, describe in detail what isn't working correctly, and see what happens.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Why not use accelerators for detecting the Enter key being pressed?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Your guess is as good as mine, because that code doesn't run by itself there's no way to tell what you're doing in the script.

Think about this, if you read this thread with absolutely no idea what was being discussed, would what you posted be of any help whatsoever to anyone?

Post your script, describe in detail what isn't working correctly, and see what happens.

 

Full code

#NoTrayIcon
#include <AD.au3>
#include <Misc.au3>
#include <File.au3>
#include <String.au3>
#include <WinAPI.au3>
#include <GuiEdit.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <GuiRichEdit.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <ComboConstants.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>
 
Global $sVersion = "2.1.0", $sTemp = @TempDir & "\SAM", $sName = "Student Account Manager"
 
Global $sUsername, $sDisplayName, $sGrade, $sEnrolled, $bLocked, $bExpires
 
_GUI()
 
Func _GUI()
; create gui
Global $iWidth = 260, $iHeight = 371
Global $oGUI = GUICreate($sName, $iWidth, $iHeight, -1, -1) ; create main gui window
GUISetBkColor(0xFFFFFF, $oGUI) ; set background color
GUICtrlCreateGraphic(0, 1, 1, $iHeight - 1) ; left border
GUICtrlSetColor(-1, 0x8C8C8C)
GUICtrlCreateGraphic(0, 0, $iWidth, 1) ; top border
GUICtrlSetColor(-1, 0x8C8C8C)
GUICtrlCreateGraphic($iWidth - 1, 1, 1, $iHeight - 1) ; right border
GUICtrlSetColor(-1, 0x8C8C8C)
GUICtrlCreateGraphic(0, $iHeight - 1, $iWidth, 1) ; bottom border
GUICtrlSetColor(-1, 0x8C8C8C)
; populate gui
Global $aControls[40], $aWarnings[40], $iStep, $bBulk = False
Global $iLabelHeight = 35 ; bottom labels start height
_CreateHeader($sName & "  (Build " & $sVersion & ")", $iWidth)
; create inputs
;$aControls[7] = _CreateLine(10, 108, $iWidth) ; line
_CreateLabel("Please input the student account number", 25, $iLabelHeight, 200)
$aControls[0] = _CreateLabel("Username :", 30, $iLabelHeight + 29)
$aControls[1] = _CreateInput("", 105, $iLabelHeight + 30, 100)
$aWarnings[0] = _CreateIcon("warning", 218, $iLabelHeight + 29)
_CreateLine(10, 100, $iWidth) ; line
_CreateLabel("Name :", 30, $iLabelHeight + 80)
_CreateLabel("Grade :", 30, $iLabelHeight + 110)
_CreateLabel("Enrolled at :", 30, $iLabelHeight + 140)
_CreateLabel("Is Locked :", 30, $iLabelHeight + 170)
_CreateLabel("Expires :", 30, $iLabelHeight + 200)
_CreateLabel("Internet :", 30, $iLabelHeight + 230)
 
 
 
 
 
_CreateLabel("Test User", 105, $iLabelHeight + 80, -1, -1, "Left")
_CreateLabel("5", 105, $iLabelHeight + 110, -1, -1, "Left")
_CreateLabel("School 1", 105, $iLabelHeight + 140, -1, -1, "Left")
_CreateLabel("Yes", 105, $iLabelHeight + 170, -1, -1, "Left")
_CreateLabel("No", 105, $iLabelHeight + 200, -1, -1, "Left")
_CreateLabel("Normal", 105, $iLabelHeight + 230, -1, -1, "Left")
 
 
_CreateButton("go", $iWidth - 50, $iLabelHeight + 170, 24, 24)
_CreateButton("go", $iWidth - 50, $iLabelHeight + 200, 24, 24)
_CreateButton("go", $iWidth - 50, $iLabelHeight + 230, 24, 24)
 
 
_CreateLine(10, 298, $iWidth) ; line
; set default options
For $i = 0 To UBound($aWarnings) - 1
GUICtrlSetState($aWarnings[$i], $GUI_HIDE) ; hide all warning icons
Next
; create buttons
$aControls[2] = _CreateButton("go", $iWidth - 60, $iHeight - 60, 48, 48)
$aControls[3] = _CreateButtonLabel("Go", $iWidth - 60, $iHeight - 60)
Local $cDummy = GUICtrlCreateDummy() ; create dummy control
$aControls[4] = _CreateButton("close", 10, $iHeight - 60, 48, 48)
$aControls[5] = _CreateButtonLabel("Close", 10, $iHeight - 60, "Right")
GUISetState(@SW_SHOW, $oGUI) ; show gui only after all controls have been created
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $aControls[4] ; close button
_AD_Close() ; close connection to active directory
GUIDelete() ; destory gui before exit
_TempCleanup() ; delete temporary icon files
Exit
Case $aControls[2], $cDummy ; go button
$sUsername = GUICtrlRead($aControls[1]) ; read username
If $sUsername = "" Then
MsgBox(16, "Error", " Username must not be blank")
GuiCtrlSetState($aControls[1], $GUI_FOCUS)
Else
;_SAMv2()
If _SAMv2() = 1 Then
MsgBox(16, "Error", " User does not exist")
GUICtrlSetState($aControls[1], $GUI_FOCUS)
Else
_Lookup()
EndIf
EndIf
EndSwitch
If _IsPressed("0D") Then ; enter button
For $i = 1 To 10
If GUICtrlGetHandle($aControls[$i]) = _WinAPI_GetFocus() Then GUICtrlSendToDummy($cDummy)
Next
While _IsPressed("0D")
Sleep(10)
WEnd
EndIf
#ce
WEnd
EndFunc   ;==>_GUI
 
Func _CreateHeader($sText = "", $iWidth = 0)
Local $iHeight = 5
Dim $aHeaderControl[2]
$aHeaderControl[0] = GUICtrlCreateLabel($sText, 12, $iHeight, $iWidth - 13, 20, $SS_CENTERIMAGE) ; left, top, width, height
GUICtrlSetColor($aHeaderControl[0], 0x000000)
$aHeaderControl[1] = GUICtrlCreateGraphic(10, $iHeight + 20, $iWidth - 20, 1)
GUICtrlSetColor($aHeaderControl[1], 0x8C8C8C)
Return $aHeaderControl
EndFunc   ;==>_CreateHeader
 
Func _CreateLine($iLeft, $iTop, $iWidth, $iHeight = 1)
Local $oControl = GUICtrlCreateGraphic($iLeft, $iTop, $iWidth - 20, $iHeight)
GUICtrlSetColor($oControl, 0x8C8C8C)
Return $oControl
EndFunc   ;==>_CreateLine
 
Func _CreateLabel($sText = "", $iLeft = 0, $iTop = 0, $iWidth = 60, $iHeight = 20, $sAlign = "Right")
Local $iAlign
If $sAlign = "Right" Then $iAlign = $SS_RIGHT
If $sAlign = "Left" Then $iAlign = $SS_LEFT
Local $oControl = GUICtrlCreateLabel($sText, $iLeft, $iTop, $iWidth, $iHeight, BitOR($iAlign, $SS_CENTERIMAGE))
Return $oControl
EndFunc   ;==>_CreateLabel
 
Func _CreateInput($sText = "", $iLeft = 0, $iTop = 0, $iWidth = 120, $iHeight = 20)
Local $oControl = GUICtrlCreateInput($sText, $iLeft, $iTop, $iWidth, $iHeight, BitOR($SS_CENTERIMAGE, $ES_AUTOHSCROLL))
GUICtrlSetBkColor($oControl, 0xE5F5E5)
Return $oControl
EndFunc   ;==>_CreateInput
 
Func _CreateIcon($sIcon, $iLeft, $iTop, $iWidth = 24, $iHeight = 24)
Local $oControl = GUICtrlCreateIcon($sTemp & "\" & $sIcon & ".ico", "", $iLeft, $iTop - 2, $iWidth, $iHeight)
Return $oControl
EndFunc   ;==>_CreateIcon
 
Func _CreateButton($sIcon, $iLeft, $iTop, $iWidth, $iHeight)
Local $oControl = GUICtrlCreateIcon($sTemp & "\" & $sIcon & ".ico", "", $iLeft, $iTop, $iWidth, $iHeight)
GUICtrlSetState($oControl, $GUI_ENABLE)
GUICtrlSetCursor($oControl, 0)
Return $oControl
EndFunc   ;==>_CreateButton
 
Func _CreateButtonLabel($sText, $iLeft, $iTop, $sAlign = "Left")
Local $sAlignment, $iLeftRight
If $sAlign = "Left" Then
$iAlign = $SS_RIGHT
$iLeftRight = $iLeft - 61 ; will put text to the left of the icon
Else
$iAlign = $SS_LEFT
$iLeftRight = $iLeft + 54 ; will put text to the right of the icon
EndIf
Local $oControl = GUICtrlCreateLabel($sText, $iLeftRight, $iTop, 55, 48, BitOR($iAlign, $SS_CENTERIMAGE))
GUICtrlSetFont($oControl, 12, 500, 0, "Tahoma", 5)
Switch $sText
Case "go"
GUICtrlSetColor($oControl, 0x3465A0)
Case "close"
GUICtrlSetColor($oControl, 0xDE4018)
Case "csv"
GUICtrlSetColor($oControl, 0xD6D3CE)
EndSwitch
Return $oControl
EndFunc   ;==>_CreateButtonLabel
Edited by kor

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Hi,

A control ID min value is 3, however your $aControls[4] returns 0, so is the GUIGetMsg function when nothing happens.

Conclusion : both values matches on your Exit's Case statement.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I thought it was 3 and upwards?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

I thought it was 3 and upwards?

Correct. I got confused by some debugging I made.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

Sorry, I don't understand.

I'm not having a problem closing the script.

I'm having a problem when I hit "enter" inside the username field. An msgbox will pop up saying username cannot be blank. If I hit enter to press "ok" on the msgbox, the script then hits "enter" again on the dummy control bringing up the username cannot be blank error message again.

If I press spacebar to select the "ok", or click "ok" on the message box the msgbox goes away and the script functions normally.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

I'm not having a problem closing the script.

I said that I could not test your script because of what I explained; that issue is triggered by the GUICtrlCreateIcon when the icon is not found, hence it returns 0.

If your MsgBox keeps showing when you press enter, then you have to handle correctly the enter key and wait for it to be released before or after this MsgBox.

;opt1:
While _IsPressed("0D")
WEnd
MsgBox( ...

;opt2:
MsgBox( ...
While _IsPressed("0D")
WEnd

Edit: Typo.

Br, FireFox.

Edited by FireFox

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

I said that I could not test your script because of what I explained

Alright then. Here is working code that demonstrates the problem. If you run and leave the username field blank and hit enter you get the msgbox. if you hit enter on the msgbox the msgbox appears again.

#NoTrayIcon
#include <AD.au3>
#include <Misc.au3>
#include <File.au3>
#include <String.au3>
#include <WinAPI.au3>
#include <Constants.au3>
#include <GuiListBox.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <ButtonConstants.au3>
#include <WindowsConstants.au3>

Global $sUsername, $sDisplayName, $sGrade, $sEnrolled, $aStudentCheck, $iSet, $sLocked = "No", $sExpires = "No", _
$sRestricted = "Normal", $sVersion = "2.0.2", $sPath = "", $sName = "Student Account Manager"

If WinExists($sName) Then Exit MsgBox(48, " Error", $sName & " is already running")
;_AD_Open()
_GUI()

Func _GUI()
Global $iWidth = 260, $iHeight = 341, $aControls[30], $iStep
Global $oGUI = GUICreate($sName, $iWidth, $iHeight, -1, -1) ; create main gui window
GUISetBkColor(0xFFFFFF, $oGUI) ; set background color
GUICtrlCreateGraphic(0, 1, 1, $iHeight - 1) ; left border
GUICtrlSetColor(-1, 0x8C8C8C)
GUICtrlCreateGraphic(0, 0, $iWidth, 1) ; top border
GUICtrlSetColor(-1, 0x8C8C8C)
GUICtrlCreateGraphic($iWidth - 1, 1, 1, $iHeight - 1) ; right border
GUICtrlSetColor(-1, 0x8C8C8C)
GUICtrlCreateGraphic(0, $iHeight - 1, $iWidth, 1) ; bottom border
GUICtrlSetColor(-1, 0x8C8C8C)
Global $iLabelHeight = 35 ; bottom labels start height
_CreateHeader($sName & " (Build " & $sVersion & ")", $iWidth)
_CreateLabel("Please input the student account number", 25, $iLabelHeight, 200)
$aControls[0] = _CreateLabel("Username :", 30, $iLabelHeight + 29)
$aControls[1] = _CreateInput("", 105, $iLabelHeight + 30, 100)
_CreateLine(10, 100, $iWidth) ; line
_CreateLabel("Name :", 30, $iLabelHeight + 80)
_CreateLabel("Grade :", 30, $iLabelHeight + 110)
_CreateLabel("Locked :", 30, $iLabelHeight + 140)
_CreateLabel("Enrolled at :", 30, $iLabelHeight + 170)
_CreateLabel("Internet :", 30, $iLabelHeight + 200)
_CreateLine(10, 268, $iWidth) ; line
; create buttons
$aControls[2] = GUICtrlCreateButton("this", 100, 100, 25, 25);_CreateButton("go", $iWidth - 60, $iHeight - 60, 48, 48)
$aControls[3] = GUICtrlCreateButton(".", 130, 100, 25, 25);_CreateButtonLabel("Go", $iWidth - 60, $iHeight - 60)
Local $cDummy = GUICtrlCreateDummy() ; create dummy control
$aControls[4] = GUICtrlCreateButton(".", 140, 100, 25, 25);_CreateButton("close", 10, $iHeight - 60, 48, 48)
$aControls[5] = GUICtrlCreateButton(".", 150, 100, 25, 25);_CreateButtonLabel("Close", 10, $iHeight - 60, "Right")
$aControls[20] = GUICtrlCreateButton(".", 160, 100, 25, 25);_CreateButton("key", $iWidth - 55, $iLabelHeight + 79, 32, 32) ; password
$aControls[21] = GUICtrlCreateButton(".", 170, 100, 25, 25);_CreateButton("unlock", $iWidth - 53, $iLabelHeight + 135, 32, 32) ; locked
$aControls[22] = GUICtrlCreateButton(".", 180, 100, 25, 25);_CreateButton("shield", $iWidth - 55, $iLabelHeight + 195, 32, 32) ; internet
For $i = 20 To 25
GUICtrlSetState($aControls[$i], $GUI_HIDE) ; hide auxiliary buttons
Next
GUISetState(@SW_SHOW, $oGUI) ; show gui only after all controls have been created
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE, $aControls[4] ; close button
;_AD_Close() ; close connection to active directory
GUIDelete() ; destory gui before exit
;_TempCleanup() ; delete temporary icon files
Exit
Case $aControls[2], $cDummy ; go button
$sUsername = GUICtrlRead($aControls[1]) ; read username
If $sUsername = "" Then
MsgBox(16, "Error", " Username must not be blank")
GuiCtrlSetState($aControls[1], $GUI_FOCUS)
Else
_ClearControls()
;_SAMv2()
EndIf
Case $aControls[20] ; password
;_ChangePassword()
Case $aControls[21] ; locked
;_Unlock()
Case $aControls[22] ; internet
;_ChangeInternet()
EndSwitch
If _IsPressed("0D") Then ; enter button
For $i = 1 To 10
If GUICtrlGetHandle($aControls[$i]) = _WinAPI_GetFocus() Then GUICtrlSendToDummy($cDummy)
Next
While _IsPressed("0D")
Sleep(10)
WEnd
EndIf
WEnd
EndFunc ;==>_GUI

Func _ClearControls()
For $i = 10 To 19
If $aControls[$i] Then GUICtrlDelete($aControls[$i]) ; delete all lookup information
Next
For $i = 20 To 29
GUICtrlSetState($aControls[$i], $GUI_HIDE) ; hide auxiliary buttons
Next
EndFunc ;==>_ClearControls

Func _CreateHeader($sText = "", $iWidth = 0)
Local $iHeight = 5
Dim $aHeaderControl[2]
$aHeaderControl[0] = GUICtrlCreateLabel($sText, 12, $iHeight, $iWidth - 13, 20, $SS_CENTERIMAGE) ; left, top, width, height
GUICtrlSetColor($aHeaderControl[0], 0x000000)
$aHeaderControl[1] = GUICtrlCreateGraphic(10, $iHeight + 20, $iWidth - 20, 1)
GUICtrlSetColor($aHeaderControl[1], 0x8C8C8C)
Return $aHeaderControl ; required
EndFunc ;==>_CreateHeader

Func _CreateIcon($sIcon, $iLeft, $iTop, $iWidth = 24, $iHeight = 24)
Local $oControl = "";GUICtrlCreateIcon($sPath & "\" & $sIcon & ".ico", "", $iLeft, $iTop - 2, $iWidth, $iHeight)
Return $oControl ; required
EndFunc ;==>_CreateIcon


Func _CreateLine($iLeft, $iTop, $iWidth, $iHeight = 1)
Local $oControl = GUICtrlCreateGraphic($iLeft, $iTop, $iWidth - 20, $iHeight)
GUICtrlSetColor($oControl, 0x8C8C8C)
Return $oControl ; required
EndFunc ;==>_CreateLine

Func _CreateLabel($sText = "", $iLeft = 0, $iTop = 0, $iWidth = 60, $iHeight = 20, $sAlign = "Right")
Local $iAlign
If $sAlign = "Right" Then $iAlign = $SS_RIGHT
If $sAlign = "Left" Then $iAlign = $SS_LEFT
Local $oControl = GUICtrlCreateLabel($sText, $iLeft, $iTop, $iWidth, $iHeight, BitOR($iAlign, $SS_CENTERIMAGE))
Return $oControl ; required
EndFunc ;==>_CreateLabel

Func _CreateInput($sText = "", $iLeft = 0, $iTop = 0, $iWidth = 120, $iHeight = 20)
Local $oControl = GUICtrlCreateInput($sText, $iLeft, $iTop, $iWidth, $iHeight, BitOR($SS_CENTERIMAGE, $ES_AUTOHSCROLL))
GUICtrlSetBkColor($oControl, 0xE5F5E5)
Return $oControl ; required
EndFunc ;==>_CreateInput

Func _CreateButton($sIcon, $iLeft, $iTop, $iWidth, $iHeight)
Local $oControl = "";GUICtrlCreateIcon($sPath & "\" & $sIcon & ".ico", "", $iLeft, $iTop, $iWidth, $iHeight)
GUICtrlSetState($oControl, $GUI_ENABLE)
GUICtrlSetCursor($oControl, 0)
Return $oControl ; required
EndFunc ;==>_CreateButton

Func _CreateButtonLabel($sText, $iLeft, $iTop, $sAlign = "Left")
Local $sAlignment, $iLeftRight
If $sAlign = "Left" Then
$iAlign = $SS_RIGHT
$iLeftRight = $iLeft - 61 ; will put text to the left of the icon
Else
$iAlign = $SS_LEFT
$iLeftRight = $iLeft + 54 ; will put text to the right of the icon
EndIf
Local $oControl = GUICtrlCreateLabel($sText, $iLeftRight, $iTop, 55, 48, BitOR($iAlign, $SS_CENTERIMAGE))
GUICtrlSetFont($oControl, 12, 500, 0, "Tahoma", 5)
Switch $sText
Case "go"
GUICtrlSetColor($oControl, 0x3465A0)
Case "close"
GUICtrlSetColor($oControl, 0xDE4018)
Case "csv"
GUICtrlSetColor($oControl, 0xD6D3CE)
EndSwitch
Return $oControl ; required
EndFunc ;==>_CreateButtonLabel

Share this post


Link to post
Share on other sites

kor,

What is wrong with using GUISetAccelerators instead of _IsPressed?


_AdapterConnections()_AlwaysRun()_AppMon()_AppMonEx()_BinaryBin()_CheckMsgBox()_CmdLineRaw()_ContextMenu()_ConvertLHWebColor()/_ConvertSHWebColor()_DesktopDimensions()_DisplayPassword()_DotNet_Load()/_DotNet_Unload()_Fibonacci()_FileCompare()_FileCompareContents()_FileNameByHandle()_FilePrefix/SRE()_FindInFile()_GetBackgroundColor()/_SetBackgroundColor()_GetConrolID()_GetCtrlClass()_GetDirectoryFormat()_GetDriveMediaType()_GetFilename()/_GetFilenameExt()_GetHardwareID()_GetIP()_GetIP_Country()_GetOSLanguage()_GetSavedSource()_GetStringSize()_GetSystemPaths()_GetURLImage()_GIFImage()_GoogleWeather()_GUICtrlCreateGroup()_GUICtrlListBox_CreateArray()_GUICtrlListView_CreateArray()_GUICtrlListView_SaveCSV()_GUICtrlListView_SaveHTML()_GUICtrlListView_SaveTxt()_GUICtrlListView_SaveXML()_GUICtrlMenu_Recent()_GUICtrlMenu_SetItemImage()_GUICtrlTreeView_CreateArray()_GUIDisable()_GUIImageList_SetIconFromHandle()_GUIRegisterMsg()_GUISetIcon()_Icon_Clear()/_Icon_Set()_IdleTime()_InetGet()_InetGetGUI()_InetGetProgress()_IPDetails()_IsFileOlder()_IsGUID()_IsHex()_IsPalindrome()_IsRegKey()_IsStringRegExp()_IsSystemDrive()_IsUPX()_IsValidType()_IsWebColor()_Language()_Log()_MicrosoftInternetConnectivity()_MSDNDataType()_PathFull/GetRelative/Split()_PathSplitEx()_PrintFromArray()_ProgressSetMarquee()_ReDim()_RockPaperScissors()/_RockPaperScissorsLizardSpock()_ScrollingCredits_SelfDelete()_SelfRename()_SelfUpdate()_SendTo()_ShellAll()_ShellFile()_ShellFolder()_SingletonHWID()_SingletonPID()_Startup()_StringCompact()_StringIsValid()_StringRegExpMetaCharacters()_StringReplaceWholeWord()_StringStripChars()_Temperature()_TrialPeriod()_UKToUSDate()/_USToUKDate()_WinAPI_Create_CTL_CODE()_WinAPI_CreateGUID()_WMIDateStringToDate()/_DateToWMIDateString()Au3 script parsingAutoIt SearchAutoIt3 PortableAutoIt3WrapperToPragmaAutoItWinGetTitle()/AutoItWinSetTitle()CodingDirToHTML5FileInstallrFileReadLastChars()GeoIP databaseGUI - Only Close ButtonGUI ExamplesGUICtrlDeleteImage()GUICtrlGetBkColor()GUICtrlGetStyle()GUIEventsGUIGetBkColor()Int_Parse() & Int_TryParse()IsISBN()LockFile()Mapping CtrlIDsOOP in AutoItParseHeadersToSciTE()PasswordValidPasteBinPosts Per DayPreExpandProtect GlobalsQueue()Resource UpdateResourcesExSciTE JumpSettings INISHELLHOOKShunting-YardSignature CreatorStack()Stopwatch()StringAddLF()/StringStripLF()StringEOLToCRLF()VSCROLLWM_COPYDATAMore Examples...

Updated: 04/09/2015

Share this post


Link to post
Share on other sites

And... I gave you the code to fix your problem.


 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

And... I gave you the code to fix your problem.

I see that now. You wanted your code to go where the msgbox was. I thought it needed to go where I already had a While loop for _IsPressed. Solved.

@guinness, I will look at accelerators for the future. thanks!

Edited by kor

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