JustinReno Posted October 24, 2007 Share Posted October 24, 2007 Hello, I've been trying to design a program for you to enter a password in. My question is: Is there a way to detect if a character (Letter or Number) was put into an input? This is my code so far: #include <GUIConstants.au3> $Form1 = GUICreate("Password", 179, 66, 193, 115) $Label1 = GUICtrlCreateLabel("Please type your password to get in:", 0, 8, 174, 17) $Input1 = GUICtrlCreateInput("", 0, 24, 169, 21) $Button1 = GUICtrlCreateButton("Go", 0, 48, 171, 17, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE MsgBox(16, "Password", "You have to type your password to get in!") EndSwitch WEnd Any help is appreciated. Link to comment Share on other sites More sharing options...
GaryFrost Posted October 24, 2007 Share Posted October 24, 2007 http://www.autoitscript.com/forum/index.ph...e=%2BWM_COMMAND SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Achilles Posted October 24, 2007 Share Posted October 24, 2007 #416044 My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list] Link to comment Share on other sites More sharing options...
JustinReno Posted October 24, 2007 Author Share Posted October 24, 2007 Were can I find WinApi.au3? Link to comment Share on other sites More sharing options...
GaryFrost Posted October 24, 2007 Share Posted October 24, 2007 Were can I find WinApi.au3?Beta SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 24, 2007 Moderators Share Posted October 24, 2007 http://www.autoitscript.com/forum/index.ph...c=33677&hl=It's called A3LWinAPI.au3 in the zip file. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
JustinReno Posted October 24, 2007 Author Share Posted October 24, 2007 Thanks SmOke_N I try your script noe Gary. Link to comment Share on other sites More sharing options...
JustinReno Posted October 24, 2007 Author Share Posted October 24, 2007 Ok, I got the Winapi.au3 but your script doesn't work: I have beta, the latest version, and I have AU3Lib Installed Errors: expandcollapse popup>"C:\Program Files\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\Jar\Desktop\Test.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams +>20:45:01 Starting AutoIt3Wrapper v.1.9.2 >Running AU3Check (1.54.9.0) from:C:\Program Files\AutoIt3 C:\Documents and Settings\Jar\Desktop\Test.au3(8,131) : WARNING: $Debug_Ed possibly not declared/created yet $Debug_Ed = False ; Check ClassName being passed to Edit functions, set to True and use a handle to another control to see it work ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(61,116) : WARNING: $EN_ALIGN_LTR_EC: possibly used before declaration. Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(66,116) : WARNING: $EN_ALIGN_RTL_EC: possibly used before declaration. Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(71,120) : WARNING: $EN_CHANGE: possibly used before declaration. Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(77,120) : WARNING: $EN_ERRSPACE: possibly used before declaration. Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(82,102) : WARNING: $EN_HSCROLL: possibly used before declaration. Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(87,89) : WARNING: $EN_KILLFOCUS: possibly used before declaration. Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(92,142) : WARNING: $EN_MAXTEXT: possibly used before declaration. Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(102,91) : WARNING: $EN_SETFOCUS: possibly used before declaration. Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(108,87) : WARNING: $EN_UPDATE: possibly used before declaration. Case $EN_UPDATE ; Sent when an edit control is about to redraw itself ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(113,163) : WARNING: $EN_VSCROLL: possibly used before declaration. Case $EN_VSCROLL ; Sent when the user clicks an edit control's vertical scroll bar or when the user scrolls the mouse wheel over the edit control ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(61,116) : ERROR: $EN_ALIGN_LTR_EC: undeclared global variable. Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(23,66) : ERROR: _GUICtrlStatusBar_Create(): undefined function. $StatusBar = _GUICtrlStatusBar_Create ($hGUI, $aPartRightSide) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(24,64) : ERROR: _GUICtrlStatusBar_SetIcon(): undefined function. _GUICtrlStatusBar_SetIcon ($StatusBar, 3, 97, "shell32.dll") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(30,54) : ERROR: _GUICtrlEdit_AppendText(): undefined function. _GUICtrlEdit_AppendText ($hEdit, "This is a test") ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(33,89) : ERROR: _GUICtrlEdit_GetModify(): undefined function. _GUICtrlStatusBar_SetText ($StatusBar, "Modified: " & _GUICtrlEdit_GetModify ($hEdit) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(33,93) : ERROR: _GUICtrlStatusBar_SetText(): undefined function. _GUICtrlStatusBar_SetText ($StatusBar, "Modified: " & _GUICtrlEdit_GetModify ($hEdit), 2) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(44,68) : ERROR: _GUICtrlEdit_GetText(): undefined function. _DebugPrint("Input Changed: " & _GUICtrlEdit_GetText ($hControl) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(49,42) : ERROR: _GUICtrlEdit_SetSel(): undefined function. _GUICtrlEdit_SetSel ($hControl, 0, -1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(56,40) : ERROR: _WinAPI_LoWord(): undefined function. $iIDFrom = _WinAPI_LoWord ($iwParam) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3(57,38) : ERROR: _WinAPI_HiWord(): undefined function. $iCode = _WinAPI_HiWord ($iwParam) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^ C:\Documents and Settings\Jar\Desktop\Test.au3 - 10 error(s), 11 warning(s) !>20:45:01 AU3Check ended.rc:2 +>20:45:06 AutoIt3Wrapper Finished >Exit code: 0 Time: 5.455 Link to comment Share on other sites More sharing options...
JustinReno Posted October 24, 2007 Author Share Posted October 24, 2007 Ok, Well never mind that, What I'm trying to accomplish with my script is that if a user enters a key, and its not a specific letter I want, then It will change that part to the letter I want, I don't know if I'm explaining it right but here is my code so bar: #include <GUIConstants.au3> Global $B = 0 Global $B1 = 1 $Form1 = GUICreate("Password", 179, 66, 193, 115) $Label1 = GUICtrlCreateLabel("Please type your password to get in:", 0, 8, 174, 17) $Input1 = GUICtrlCreateInput("", 0, 24, 169, 21) $Button1 = GUICtrlCreateButton("Go", 0, 48, 171, 17, 0) GUISetState(@SW_SHOW) While 1 _Read() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE MsgBox(16, "Password", "You have to type your password to get in!") EndSwitch WEnd Func _Read() $Read = GUICtrlRead($Input1) If WinActive($Form1) AND $Read = NOT "" AND $B = 0 Then GUICtrlSetData($Input1, "A") $B += 1 EndIf If WinActive($Form1) AND $Read = NOT "" AND $B = 1 AND $B1 = 1 Then GuICtrlSetData($Input1, "u") $B +=1 Endif EndFunc I want it to spell AutoIt when I'm done. Thanks. Link to comment Share on other sites More sharing options...
GaryFrost Posted October 24, 2007 Share Posted October 24, 2007 From with-in SciTE Alt+F5 SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Thatsgreat2345 Posted October 24, 2007 Share Posted October 24, 2007 Ok, Well never mind that, What I'm trying to accomplish with my script is that if a user enters a key, and its not a specific letter I want, then It will change that part to the letter I want, I don't know if I'm explaining it right but here is my code so bar: #include <GUIConstants.au3> Global $B = 0 Global $B1 = 1 $Form1 = GUICreate("Password", 179, 66, 193, 115) $Label1 = GUICtrlCreateLabel("Please type your password to get in:", 0, 8, 174, 17) $Input1 = GUICtrlCreateInput("", 0, 24, 169, 21) $Button1 = GUICtrlCreateButton("Go", 0, 48, 171, 17, 0) GUISetState(@SW_SHOW) While 1 _Read() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE MsgBox(16, "Password", "You have to type your password to get in!") EndSwitch WEnd Func _Read() $Read = GUICtrlRead($Input1) If WinActive($Form1) AND $Read = NOT "" AND $B = 0 Then GUICtrlSetData($Input1, "A") $B += 1 EndIf If WinActive($Form1) AND $Read = NOT "" AND $B = 1 AND $B1 = 1 Then GuICtrlSetData($Input1, "u") $B +=1 Endif EndFunc I want it to spell AutoIt when I'm done. Thanks. B will only equal 0 or 1 once. You never reset it at all so it will continually be adding +1 every single time. I don't see why any WinApi has to be used. Plus if you just do Guictrlsetdata it will get rid of all previous data entered so you are going to have to do Guictrlsetdata($Input1, Guictrlread($input1) & "u" or whatever) My advice would be to add each letter to an array that should make it a lot easier on you. Link to comment Share on other sites More sharing options...
martin Posted October 24, 2007 Share Posted October 24, 2007 (edited) Ok, Well never mind that, What I'm trying to accomplish with my script is that if a user enters a key, and its not a specific letter I want, then It will change that part to the letter I want, I don't know if I'm explaining it right but here is my code so bar: #include <GUIConstants.au3> Global $B = 0 Global $B1 = 1 $Form1 = GUICreate("Password", 179, 66, 193, 115) $Label1 = GUICtrlCreateLabel("Please type your password to get in:", 0, 8, 174, 17) $Input1 = GUICtrlCreateInput("", 0, 24, 169, 21) $Button1 = GUICtrlCreateButton("Go", 0, 48, 171, 17, 0) GUISetState(@SW_SHOW) While 1 _Read() $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE MsgBox(16, "Password", "You have to type your password to get in!") EndSwitch WEnd Func _Read() $Read = GUICtrlRead($Input1) If WinActive($Form1) AND $Read = NOT "" AND $B = 0 Then GUICtrlSetData($Input1, "A") $B += 1 EndIf If WinActive($Form1) AND $Read = NOT "" AND $B = 1 AND $B1 = 1 Then GuICtrlSetData($Input1, "u") $B +=1 Endif EndFunc I want it to spell AutoIt when I'm done. Thanks. #include <GUIConstants.au3> $Form1 = GUICreate("Password", 179, 66, 193, 115) $Label1 = GUICtrlCreateLabel("Please type your password to get in:", 0, 8, 174, 17) $Input1 = GUICtrlCreateInput("", 0, 24, 169, 21) $Button1 = GUICtrlCreateButton("Go", 0, 48, 171, 17, 0) GUISetState(@SW_SHOW) While 1 _Read("AutoIt") $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE MsgBox(16, "Password", "You have to type your password to get in!") EndSwitch WEnd Func _Read($IPWanted) $Read = GUICtrlRead($Input1) Local $l1 = StringLen($Read) Local $l2 = StringLen($IPWanted) If $l1 < $L2 Then GUICtrlSetData($Input1,StringLeft($ipwanted,$l1)) Else GUICtrlSetData($input1,$IPWAnted) EndIf EndFunc EDIT: On second thoughts it would be better to do this maybe expandcollapse popup#include <GUIConstants.au3> GUIRegisterMsg($WM_COMMAND,"MY_WM_COMMAND") $Form1 = GUICreate("Password", 179, 66, 193, 115) $Label1 = GUICtrlCreateLabel("Please type your password to get in:", 0, 8, 174, 17) $Input1 = GUICtrlCreateInput("", 0, 24, 169, 21) $Button1 = GUICtrlCreateButton("Go", 0, 48, 171, 17, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE ;MsgBox(16, "Password", "You have to type your password to get in!") Exit EndSwitch WEnd Func _Read($IPWanted) $Read = GUICtrlRead($Input1) Local $l1 = StringLen($Read) Local $l2 = StringLen($IPWanted) If $l1 < $L2 Then GUICtrlSetData($Input1,StringLeft($ipwanted,$l1)) Else GUICtrlSetData($input1,$IPWAnted) EndIf EndFunc Func MY_WM_COMMAND($hWnd, $Msg, $wParam, $lParam) $nNotifyCode = BitShift($wParam, 16) $nID = BitAnd($wParam, 0x0000FFFF) If Not $hWnd = $Form1 Then Return $GUI_RUNDEFMSG If $nNotifyCode = $EN_CHANGE And $nID = $Input1 Then _Read("AutoIt") Return 0 EndIf Return $GUI_RUNDEFMSG EndFunc Edited October 24, 2007 by martin Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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