|
Компьютерный форум OSzone.net » Программирование, базы данных и автоматизация действий » AutoIt » [решено] Как сделать текст сам стирался при щелчке в GUICtrlCreateInput, а не выделялсяЦветом? |
|
[решено] Как сделать текст сам стирался при щелчке в GUICtrlCreateInput, а не выделялсяЦветом?
|
![]() Старожил Сообщения: 379 |
|
|
Отправлено: 17:48, 05-04-2009 |
Старожил Сообщения: 460
|
Профиль | Отправить PM | Цитировать #region: - Include #include <GUIConstantsEx.au3> #Include <GuiEdit.au3> #include <WindowsConstants.au3> #endregion #region: - Option Opt('GUIOnEventMode', 1) Opt('MustDeclareVars', 1) Opt('TrayIconDebug', 1) Opt('TrayIconHide', 0) #endregion #region: - Global Global $hWinMain, $Input_1, $Input_2 #endregion #region: GUI $hWinMain = GUICreate('Test', 400, 400, -1, -1) GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit_pro') $Input_2 = GUICtrlCreateInput('Введите любой текст', 20, 70+40, 185, 21) $Input_1 = GUICtrlCreateInput('Введите любой текст', 20, 40, 185, 21) #endregion #region: - После создания всех GUI GUIRegisterMsg($WM_COMMAND, 'WM_COMMAND') GUISetState(@SW_SHOW, $hWinMain) #endregion #region: - Sleep, Exit While 1 Sleep(10) WEnd Func _Exit_pro() Exit EndFunc #endregion Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg Local $hWndFrom, $iIDFrom, $iCode, $hWndEdit If Not IsHWnd($Input_1) Then $hWndEdit = GUICtrlGetHandle($Input_1) $hWndFrom = $ilParam $iIDFrom = _WinAPI_LoWord($iwParam) $iCode = _WinAPI_HiWord($iwParam) Switch $hWndFrom Case $Input_1, $hWndEdit Switch $iCode Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right _DebugPrint("$EN_ALIGN_LTR_EC" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left _DebugPrint("$EN_ALIGN_RTL_EC" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control _DebugPrint("$EN_CHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request _DebugPrint("$EN_ERRSPACE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar _DebugPrint("$EN_HSCROLL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus _DebugPrint("$EN_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control _DebugPrint("$EN_MAXTEXT" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; This message is also sent when an edit control does not have the $ES_AUTOHSCROLL style and the number of characters to be ; inserted would exceed the width of the edit control. ; This message is also sent when an edit control does not have the $ES_AUTOVSCROLL style and the total number of lines resulting ; from a text insertion would exceed the height of the edit control ; no return value Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus _DebugPrint("$EN_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) GUICtrlSetData($Input_1, '') ; no return value Case $EN_UPDATE ; Sent when an edit control is about to redraw itself _DebugPrint("$EN_UPDATE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value 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 _DebugPrint("$EN_VSCROLL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ; no return value Case Else _DebugPrint("Else" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_COMMAND Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint |
------- Отправлено: 19:01, 05-04-2009 | #2 |
Для отключения данного рекламного блока вам необходимо зарегистрироваться или войти с учетной записью социальной сети. Если же вы забыли свой пароль на форуме, то воспользуйтесь данной ссылкой для восстановления пароля. |
Старожил Сообщения: 307
|
Профиль | Отправить PM | Цитировать Цитата sashadeg:
#include <GUIConstantsEx.au3> ;ниже в переменных хранится текст, который будет в инпутах при запуске $Tekst_v_inpute1="Введите текст в инпут1" $Tekst_v_inpute2="Введите текст в инпут2" $Tekst_v_inpute3="Введите текст в инпут3" $GUI = GUICreate("AutoIt Example", 300, 160) $Label=GUICtrlCreateLabel("Введите нужный текст во все поля:", 20, 10, 260, 20) Controlfocus("AutoIt Example","",$Label) ;нужно только чтобы увести фокусировку от инпута 1, где фокус по умолчанию будет. Очень важно, если поменяеш название окна "AutoIt Example" на другое, то впиши то другое название и сюда. $Input_1 = GUICtrlCreateInput($Tekst_v_inpute1, 20, 40, 260, 20) $Input_2 = GUICtrlCreateInput($Tekst_v_inpute2, 20, 70, 260, 20) $Input_3 = GUICtrlCreateInput($Tekst_v_inpute3, 20, 100, 260, 20) $Ok_Button = GUICtrlCreateButton("OK", 40, 130, 60, 20) $Cancel_Button = GUICtrlCreateButton("Отмена", 200, 130, 60, 20) GUISetState(@SW_SHOW, $GUI) $IsFocused_input1=0 $IsFocused_input2=0 $IsFocused_input3=0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit ;тут выход вобще из скрыпта при закрытии Gui окна Case $Cancel_Button GUIDelete($GUI) ;удаляем gui, так как уже не надобно MsgBox(0,"Внимание","Была нажата кнопка Отмена поэтому будет выход из цикла") ExitLoop Case $Ok_Button $sText1 = GUICtrlRead($Input_1) $sText2 = GUICtrlRead($Input_2) $sText3 = GUICtrlRead($Input_3) ; Дальше идет проверка, не пустые ли инпуты, и изменен ли текст в инпутах из Начального положения, которое было в них при запуске. If $sText1=="" Or $sText1==$Tekst_v_inpute1 Or $sText2=="" Or $sText2==$Tekst_v_inpute2 Or $sText3=="" Or $sText3==$Tekst_v_inpute3 then MsgBox(0,'Внимание','Вы не ввели текст во всех полях') else GUIDelete($GUI) ;удаляем gui, так как уже не надобно MsgBox(0,"Результат",$sText1 & @CRLF &$sText2 & @CRLF & $sText3) ;можно обойтись без этого сообщения, оно нужно лишь чтобы показать что в переменных $sText1, $sText2, $sText3 уже хранится текст введенный ранее в инпуты Exitloop endif EndSwitch _OrInput_IsFocused() Wend ;дальше может быть любой набор команд... Func _OrInput_IsFocused() If _ControlIsFocused($GUI, $Input_1) And $IsFocused_input1=0 Then $IsFocused_input1=1 GUICtrlSetData($Input_1,"") ;проверка, есть ли фокусировка на $Input_1, и если есть то очищаем инпут ElseIf _ControlIsFocused($GUI, $Input_2) And $IsFocused_input2=0 Then $IsFocused_input2=1 GUICtrlSetData($Input_2,"") ;проверка, есть ли фокусировка на $Input_2, и если есть то очищаем инпут ElseIf _ControlIsFocused($GUI, $Input_3) And $IsFocused_input3=0 Then $IsFocused_input3=1 GUICtrlSetData($Input_3,"") ;проверка, есть ли фокусировка на $Input_3, и если есть то очищаем инпут EndIf EndFunc ;_OrInput_IsFocused() Func _ControlIsFocused($hWnd, $nCID) Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd)) EndFunc |
|
------- Отправлено: 19:49, 05-04-2009 | #3 |
![]() |
Участник сейчас на форуме |
![]() |
Участник вне форума |
![]() |
Автор темы |
![]() |
Сообщение прикреплено |
| |||||
Название темы | Автор | Информация о форуме | Ответов | Последнее сообщение | |
[решено] Как сделать, чтобы текст вводимый в InputBox пропечатался самостоятельно позже? | sashadeg | AutoIt | 3 | 23-02-2009 10:58 | |
[решено] Как сделать так, чтобы текст формы появлялся по мере выполнения операций? | D_Master | AutoIt | 7 | 17-01-2009 13:21 | |
[решено] Ошибка при двойном щелчке на диске C: | Sparkster | Microsoft Windows 2000/XP | 5 | 12-05-2007 21:49 | |
CMD/BAT - [решено] Как сделать чтобы *.bat-ник удалял сам себя? | Maximlian | Скриптовые языки администрирования Windows | 2 | 06-04-2005 21:22 |
|