Jump to content

_CheckInput() UDF


MrCreatoR
 Share

Recommended Posts

Hi all,

This example script is demonstrate how you can see some tip-text in your Gui inputs (or other text-displaying controls) untill you type there somthing, if the control have no focus, and the input was "untouched", then the input is filled again with the default tip-text, untill you set the focus on it again (put the cursor to input field).

Sounds complicated?! check the example, its will show you all :rolleyes: (it's easy and usefull)...

#include <GuiConstants.au3>

Global $MARk_1              = 0
Global $DEFAULTINPUTDATA_1      = "Click and type something here..."

Global $MARK_2              = 0
Global $DEFAULTINPUTDATA_2      = "Click here and type something..."

Global $MARK_3              = 0
Global $DEFAULTINPUTDATA_3      = "And here to..."

Global $NONEAACTIVECOLOR    = 0x989898


$GUI = GUICreate("Check Inputs Demo", 280, 150)
WinSetOnTop($GUI, "", 1)

$Input_1 = GUICtrlCreateInput($DEFAULTINPUTDATA_1, 15, 20, 250, 20)
GUICtrlSetColor(-1, $NONEAACTIVECOLOR)

$Input_2 = GUICtrlCreateInput($DEFAULTINPUTDATA_2, 15, 60, 250, 20)
GUICtrlSetColor(-1, $NONEAACTIVECOLOR)

$Input_3 = GUICtrlCreateInput($DEFAULTINPUTDATA_3, 15, 100, 250, 20)
GUICtrlSetColor(-1, $NONEAACTIVECOLOR)

$ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

ControlFocus($Gui, "", $ExitButton)

While 1
    _CheckInput($GUI, $Input_1, "Click and type something here...", $DEFAULTINPUTDATA_1, $MARK_1)
    _CheckInput($GUI, $Input_2, "Click here and type something...", $DEFAULTINPUTDATA_2, $MARK_2)
    _CheckInput($GUI, $Input_3, "And here to...", $DEFAULTINPUTDATA_3, $MARK_3)
    Switch GUIGetMsg()
        Case $ExitButton, -3
            Exit
        Case Else
            ;.....
    EndSwitch
WEnd

Func _CheckInput($hWnd, $ID, $InputDefText, ByRef $DefaultInputData, ByRef $Mark)
    If $Mark = 0 And $DefaultInputData = $InputDefText And _IsFocused($hWnd, $ID) Then
        $Mark = 1
        GUICtrlSetData($ID, "")
        GUICtrlSetColor($ID, 0x000000)
        $DefaultInputData = ""
        Sleep(20)
    ElseIf $Mark = 1 And $DefaultInputData = "" And GUICtrlRead($ID) = "" And Not _IsFocused($hWnd, $ID) Then
        $Mark = 0
        $DefaultInputData = $InputDefText
        GUICtrlSetData($ID, $DefaultInputData)
        GUICtrlSetColor($ID, $NONEAACTIVECOLOR)
        Sleep(20)
    EndIf
EndFunc

Func _IsFocused($hWnd, $nCID)
    Return ControlGetHandle($hWnd, '', $nCID) = ControlGetHandle($hWnd, '', ControlGetFocus($hWnd))
EndFunc
Edited by MrCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 4 weeks later...

2 mounth and no comments? :whistle:

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

works great.

Thanks !

but what would u use that for?

Just as some nice effect (like some internet page forms do) :whistle: ..

all i ever needed was to make the text disapear once the input box is clicked

You can change it... just comment the line $Mark = 1 in the main function (_CheckInput()).

But the porpouse is that the input default text will be shown if the input is empty (the user was not write to it anything), if you type something to input, the text is remained, not changed to default :lmao:

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

  • 5 weeks later...

This is a nice effect, I'm gonna use this in one of my projects. Well done :)

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

I liked this a lot but didn't like all the global vars, I added an easy to use system with arrays and only one func call in while loop.

Include file:

#include-once
#include <GuiConstants.au3>

Global $avGlobalTipText[1][9] = [[ -1]]

;===============================================================================
;
; Function Name:   _TipTextAddCtrl
; Description::    Adds a control for "tip text" capability
; Parameter(s):    $hwnd - GUI handle
;                  $ID - control id
;                  $sTipText - Tip text to show in empty control
;                  $iNotActiveColor [optional] colour of tip text
;                  $iActiveColor [optional] colour of user-typed text
; Requirement(s):  None
; Return Value(s): Always 1
; Author(s):       MSCreatoR, RazerM
;
;===============================================================================
;
Func _TipTextAddCtrl($hwnd, $ID, $sTipText, $iNotActiveColor = -1, $iActiveColor = -1)
    If $iNotActiveColor = -1 Then $iNotActiveColor = 0x989898
    If $iActiveColor = -1 Then $iActiveColor = 0x000000
    If $avGlobalTipText[0][0] <> -1 Then ReDim $avGlobalTipText[UBound($avGlobalTipText, 1) + 1 ][UBound($avGlobalTipText, 2) ]
    Local $iUBound = UBound($avGlobalTipText, 1) - 1
    $avGlobalTipText[$iUBound][0] = $hwnd
    $avGlobalTipText[$iUBound][1] = $ID
    $avGlobalTipText[$iUBound][2] = $sTipText
    $avGlobalTipText[$iUBound][3] = $iNotActiveColor
    $avGlobalTipText[$iUBound][4] = $iActiveColor
    $avGlobalTipText[$iUBound][5] = $sTipText
    $avGlobalTipText[$iUBound][6] = False
    $avGlobalTipText[$iUBound][7] = 0
    $avGlobalTipText[$iUBound][8] = $sTipText
    GUICtrlSetData($ID, $sTipText)
    GUICtrlSetColor($ID, $iNotActiveColor)
    Return 1
EndFunc   ;==>_TipTextAddCtrl

Func _TipTextCheck()
    Local $i, $sText
    For $i = 0 To UBound($avGlobalTipText, 1) - 1
        $sText = GUICtrlRead($avGlobalTipText[$i][1])
        $bFocus = _IsFocused($avGlobalTipText[$i][0], $avGlobalTipText[$i][1])
        If $sText <> $avGlobalTipText[$i][5] Or $avGlobalTipText[$i][6] <> $bFocus Then
            If Not $avGlobalTipText[$i][7] And $bFocus And $avGlobalTipText[$i][2] = $avGlobalTipText[$i][8] Then
                $avGlobalTipText[$i][7] = 1
                GUICtrlSetData($avGlobalTipText[$i][1], "")
                GUICtrlSetColor($avGlobalTipText[$i][1], $avGlobalTipText[$i][4])
                $avGlobalTipText[$i][8] = ""
            ElseIf $avGlobalTipText[$i][7] And Not $bFocus And $avGlobalTipText[$i][8] = "" And $sText = "" Then
                $avGlobalTipText[$i][7] = 0
                GUICtrlSetData($avGlobalTipText[$i][1], $avGlobalTipText[$i][2])
                GUICtrlSetColor($avGlobalTipText[$i][1], $avGlobalTipText[$i][3])
                $avGlobalTipText[$i][8] = $avGlobalTipText[$i][2]
            EndIf
            $avGlobalTipText[$i][5] = $sText
            $avGlobalTipText[$i][6] = $bFocus
        EndIf
    Next
    Return 1
EndFunc   ;==>_TipTextCheck

Func _IsFocused($hwnd, $nCID)
    Return ControlGetHandle($hwnd, '', $nCID) = ControlGetHandle($hwnd, '', ControlGetFocus($hwnd))
EndFunc   ;==>_IsFocusedoÝ÷ ØLZ^jëh×6#include "TipText.au3"

$GUI = GUICreate("Check Inputs Demo", 280, 150)

$Input1 = GUICtrlCreateInput("", 15, 20, 250, 20)
_TipTextAddCtrl($GUI, $Input1, "Click and type something here...")

$Input2 = GUICtrlCreateInput("", 15, 60, 250, 20)
_TipTextAddCtrl($GUI, $Input2, "Click here and type something...", -1, 0x0000FF)

$Input3 = GUICtrlCreateInput("", 15, 100, 250, 20)
_TipTextAddCtrl($GUI, $Input3, "And here to...", 0xFF0000, 0x00FF00)

$ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

ControlFocus($GUI, "", $ExitButton)

While 1
    _TipTextCheck()
    Switch GUIGetMsg()
        Case $ExitButton, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Wow! realy greate improvements, and the CPU now is almoust 0! :)

Thanks!

We need also to think a way to make input lost the focus when gui is activated, i mean when the title is clicked... (without increesing the CPU).

Edited by MsCreatoR

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

The cpu usage is low because the code checks first to see if the control text has changed before doing anything else, if not, it doesn't bother.

Edit:

Is this what you mean about clicking window title? More checks could be added such as check if it is a Tip text control and has no data etc..

#include "TipText.au3"

$GUI = GUICreate("Check Inputs Demo", 280, 150)

Global Const $WM_NCLBUTTONDOWN = 0xA1
GUIRegisterMsg($WM_NCLBUTTONDOWN, "NCClick")

$Input1 = GUICtrlCreateInput("", 15, 20, 250, 20)
_TipTextAddCtrl($GUI, $Input1, "Click and type something here...")

$Input2 = GUICtrlCreateInput("", 15, 60, 250, 20)
_TipTextAddCtrl($GUI, $Input2, "Click here and type something...", -1, 0x0000FF)

$Input3 = GUICtrlCreateInput("", 15, 100, 250, 20)
_TipTextAddCtrl($GUI, $Input3, "And here to...", 0xFF0000, 0x00FF00)

$ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

ControlFocus($GUI, "", $ExitButton)

While 1
    _TipTextCheck()
    Switch GUIGetMsg()
        Case $ExitButton, $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func NCClick($hwnd, $msg, $wParam, $lParam)
    ControlFocus($GUI, "", $ExitButton)
EndFunc
Edited by RazerM
My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

The cpu usage is low because the code checks first to see if the control text has changed before doing anything else, if not, it doesn't bother.

Yes, but i have noticed now that it increesing at the begining...

Maby the main function should called by Adlib?

Is this what you mean about clicking window title?

Yes! thanks...

But also this:

...
AdlibEnable("_TipTextCheck", 50)

While 1
    Switch GUIGetMsg()
        Case $ExitButton, $GUI_EVENT_CLOSE
            Exit
        Case $GUI_EVENT_PRIMARYDOWN
            $CurInfo = GUIGetCursorInfo()
            If $CurInfo[4] = 0 Then ControlFocus($GUI, "", $ExitButton)
    EndSwitch
WEnd

...

 

Spoiler

Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

AutoIt_Rus_Community.png AutoIt Russian Community

My Work...

Spoiler

AutoIt_Icon_small.pngProjects: ATT - Application Translate Tool {new}| BlockIt - Block files & folders {new}| SIP - Selected Image Preview {new}| SISCABMAN - SciTE Abbreviations Manager {new}| AutoIt Path Switcher | AutoIt Menu for Opera! | YouTube Download Center! | Desktop Icons Restorator | Math Tasks | KeyBoard & Mouse Cleaner | CaptureIt - Capture Images Utility | CheckFileSize Program

AutoIt_Icon_small.pngUDFs: OnAutoItErrorRegister - Handle AutoIt critical errors {new}| AutoIt Syntax Highlight {new}| Opera Library! | Winamp Library | GetFolderToMenu | Custom_InputBox()! | _FileRun UDF | _CheckInput() UDF | _GUIInputSetOnlyNumbers() UDF | _FileGetValidName() UDF | _GUICtrlCreateRadioCBox UDF | _GuiCreateGrid() | _PathSplitByRegExp() | _GUICtrlListView_MoveItems - UDF | GUICtrlSetOnHover_UDF! | _ControlTab UDF! | _MouseSetOnEvent() UDF! | _ProcessListEx - UDF | GUICtrl_SetResizing - UDF! | Mod. for _IniString UDFs | _StringStripChars UDF | _ColorIsDarkShade UDF | _ColorConvertValue UDF | _GUICtrlTab_CoverBackground | CUI_App_UDF | _IncludeScripts UDF | _AutoIt3ExecuteCode | _DragList UDF | Mod. for _ListView_Progress | _ListView_SysLink | _GenerateRandomNumbers | _BlockInputEx | _IsPressedEx | OnAutoItExit Handler | _GUICtrlCreateTFLabel UDF | WinControlSetEvent UDF | Mod. for _DirGetSizeEx UDF
 
AutoIt_Icon_small.pngExamples: 
ScreenSaver Demo - Matrix included | Gui Drag Without pause the script | _WinAttach()! | Turn Off/On Monitor | ComboBox Handler Example | Mod. for "Thinking Box" | Cool "About" Box | TasksBar Imitation Demo

Like the Projects/UDFs/Examples? Please rate the topic (up-right corner of the post header: Rating AutoIt_Rating.gif)

* === My topics === *

==================================================
My_Userbar.gif
==================================================

 

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Link to comment
Share on other sites

The cpu usage is low because the code checks first to see if the control text has changed before doing anything else, if not, it doesn't bother.

Edit:

Is this what you mean about clicking window title? More checks could be added such as check if it is a Tip text control and has no data etc..

#include "TipText.au3"

$GUI = GUICreate("Check Inputs Demo", 280, 150)

Global Const $WM_NCLBUTTONDOWN = 0xA1
GUIRegisterMsg($WM_NCLBUTTONDOWN, "NCClick")

$Input1 = GUICtrlCreateInput("", 15, 20, 250, 20)
_TipTextAddCtrl($GUI, $Input1, "Click and type something here...")

$Input2 = GUICtrlCreateInput("", 15, 60, 250, 20)
_TipTextAddCtrl($GUI, $Input2, "Click here and type something...", -1, 0x0000FF)

$Input3 = GUICtrlCreateInput("", 15, 100, 250, 20)
_TipTextAddCtrl($GUI, $Input3, "And here to...", 0xFF0000, 0x00FF00)

$ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
GUICtrlSetState(-1, $GUI_DEFBUTTON)

GUISetState()

ControlFocus($GUI, "", $ExitButton)

While 1
    _TipTextCheck()
    Switch GUIGetMsg()
        Case $ExitButton, $GUI_EVENT_CLOSE
          Exit
    EndSwitch
WEnd

Func NCClick($hwnd, $msg, $wParam, $lParam)
    ControlFocus($GUI, "", $ExitButton)
EndFunc
Very nice code... Definately need a "check if it is a Tip text control and has no data" I am not sure how it works to check for data before alerting. All my test allow the "Click and type something here..." to be added as input.
Link to comment
Share on other sites

Adlib isn't as responsive but as long as _TipTextCheck is called thats fine.

@gesller

Sorry I don't understand what you mean...

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Different way of doing it....

#include <GuiConstants.au3>

Global Const $WM_COMMAND = 0x0111
Global Const $EN_CHANGE = 0x300
Global Const $EN_SETFOCUS = 0x100
Global Const $EN_KILLFOCUS = 0x200
Global Const $DebugIt = 1

Global $DEFAULTINPUTDATA = "Click and type something here..."
Global $NONEAACTIVECOLOR = 0x989898
Global $Input

_Main()

Func _Main()
    Local $GUI, $ExitButton, $y = 20
    $GUI = GUICreate("Check Inputs Demo", 280, 150)

    For $x = 0 To 2
        If IsArray($Input) Then
            ReDim $Input[UBound($Input) + 1]
        Else
            Dim $Input[1]
        EndIf
        $Input[UBound($Input) - 1] = GUICtrlCreateInput($DEFAULTINPUTDATA, 15, $y, 250, 20)
        GUICtrlSetColor(-1, $NONEAACTIVECOLOR)
        $y += 40
    Next

    $ExitButton = GUICtrlCreateButton("Exit", 110, 125, 60, 20)
    GUICtrlSetState(-1, $GUI_DEFBUTTON)

    ControlFocus($GUI, "", $ExitButton)

    GUISetState()
    GUIRegisterMsg($WM_COMMAND, "MY_WM_COMMAND")

    While 1
        Switch GUIGetMsg()
            Case $ExitButton, $GUI_EVENT_CLOSE
                ExitLoop
        EndSwitch
    WEnd
EndFunc   ;==>_Main

Func _Input_Changed($hControl)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Input Changed:" & GUICtrlRead($hControl))
    ;----------------------------------------------------------------------------------------------
EndFunc   ;==>_Input_Changed

Func _Input_SetFocus($hControl)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Input SetFocus")
    ;----------------------------------------------------------------------------------------------
    If GUICtrlRead($hControl) = $DEFAULTINPUTDATA Then GUICtrlSetData($hControl, "")
    GUICtrlSetColor($hControl, 0x000000)
EndFunc   ;==>_Input_SetFocus

Func _Input_KillFocus($hControl)
    ;----------------------------------------------------------------------------------------------
    If $DebugIt Then _DebugPrint("Input KillFocus")
    ;----------------------------------------------------------------------------------------------
    If Not StringLen(GUICtrlRead($hControl)) Then GUICtrlSetData($hControl, $DEFAULTINPUTDATA)
    GUICtrlSetColor($hControl, $NONEAACTIVECOLOR)
EndFunc   ;==>_Input_KillFocus

Func MY_WM_COMMAND($hWnd, $msg, $wParam, $lParam)
    Local $nNotifyCode = BitShift($wParam, 16) ; high word
    Local $nID = BitAND($wParam, 0xFFFF) ; low word
    Local $hCtrl = $lParam
    
    For $x = 0 To UBound($Input) - 1
        Switch $nID
            Case $Input[$x]
                Switch $nNotifyCode
                    Case $EN_CHANGE
                        _Input_Changed($nID)
                    Case $EN_SETFOCUS
                        _Input_SetFocus($nID)
                    Case $EN_KILLFOCUS
                        _Input_KillFocus($nID)
                EndSwitch
                ExitLoop
        EndSwitch
    Next
    ; Proceed the default Autoit3 internal message commands.
    ; You also can complete let the line out.
    ; !!! But only 'Return' (without any value) will not proceed
    ; the default Autoit3-message in the future !!!
    Return $GUI_RUNDEFMSG
EndFunc   ;==>MY_WM_COMMAND

Func _DebugPrint($s_Text, $line = @ScriptLineNumber, $file = @ScriptName)
    ConsoleWrite( _
            "!===========================================================" & @LF & _
            "+======================================================" & @LF & _
            "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_Text & @LF & _
            "+======================================================" & @LF)
EndFunc   ;==>_DebugPrint

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

Sorry, I meant if you are using this in a script how can you have _TipTextCheck() check to see if the input is from a user or just the default "Click here and type something.." This would be for opening an alert that you have not entered any text into the input before continuing. Sort of like validation in javascript.

Link to comment
Share on other sites

Yes i know what you mean..

Good idea gafrost.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

  • 1 month later...

I liked this a lot but didn't like all the global vars, I added an easy to use system with arrays and only one func call in while loop.

First of all, thank you.

A newbie question: is there a way to use the _TipTextAddCtrl() with Opt('GUIOnEventMode', 1) ?

EDIT: I know I probably have to use

GUIRegisterMsg($WM_NOTIFY, 'WM_Notify_Events')

Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
    #forceref $hWndGUI, $MsgID, $wParam
    Local $tagNMHDR, $event
    ...

    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_Notify_Events

but I do not understand what kind of message/value I am waiting for.

A small sample would be greatly appreciated.

Edited by MCP
Link to comment
Share on other sites

Yes, as long as _TipTextCheck is called with adlib or in main loop.

My Programs:AInstall - Create a standalone installer for your programUnit Converter - Converts Length, Area, Volume, Weight, Temperature and Pressure to different unitsBinary Clock - Hours, minutes and seconds have 10 columns each to display timeAutoIt Editor - Code Editor with Syntax Highlighting.Laserix Editor & Player - Create, Edit and Play Laserix LevelsLyric Syncer - Create and use Synchronised Lyrics.Connect 4 - 2 Player Connect 4 Game (Local or Online!, Formatted Chat!!)MD5, SHA-1, SHA-256, Tiger and Whirlpool Hash Finder - Dictionary and Brute Force FindCool Text Client - Create Rendered ImageMy UDF's:GUI Enhance - Enhance your GUIs visually.IDEA File Encryption - Encrypt and decrypt files easily! File Rename - Rename files easilyRC4 Text Encryption - Encrypt text using the RC4 AlgorithmPrime Number - Check if a number is primeString Remove - remove lots of strings at onceProgress Bar - made easySound UDF - Play, Pause, Resume, Seek and Stop.
Link to comment
Share on other sites

Yes, as long as _TipTextCheck is called with adlib or in main loop.

Thank you. I now understand it is not a matter of the messages I need to intercept, but of the frequency of the checks that can be done.

I like your style.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...