Jump to content



Photo

_CheckInput() UDF


  • Please log in to reply
21 replies to this topic

#1 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 22 June 2007 - 01:44 AM

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)...

AutoIt         
#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, 13 December 2009 - 02:59 PM.

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

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team








#2 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 20 July 2007 - 03:13 PM

2 mounth and no comments? :whistle:
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#3 Zephir

Zephir

    Prodigy

  • Active Members
  • PipPipPip
  • 184 posts

Posted 20 July 2007 - 03:31 PM

works great.
but what would u use that for? all i ever needed was to make the text disapear once the input box is clicked. but make text reappear when focus is lost...

#4 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 20 July 2007 - 03:54 PM

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:
Using OS: Win 7 Professional, Using AutoIt Ver(s): 3.3.6.1 / 3.3.8.1

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#5 1905russell

1905russell

    Prodigy

  • Active Members
  • PipPipPip
  • 161 posts

Posted 20 July 2007 - 06:12 PM

2 mounth and no comments? :whistle:

Only saw this today.

Excellent template. Just what I needed.

Thanks

#6 alc

alc

    Wayfarer

  • Active Members
  • Pip
  • 74 posts

Posted 20 July 2007 - 06:26 PM

@ MsCreatoR:

Hi.

Just discovered. I wrote a C# class with the same functionality. I think this is better than tooltips in many situations.

Thanks for sharing.

Have a good weekend

alc

#7 WeMartiansAreFriendly

WeMartiansAreFriendly

    Where's the kaboom?

  • Active Members
  • PipPipPipPipPipPip
  • 1,245 posts

Posted 20 July 2007 - 09:45 PM

I was going to write something like this, except I didn't know where to start. good job!
Posted ImageDon't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

#8 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 20 August 2007 - 06:16 AM

SWEET! :) I was looking for something like this... Thanks!!

#9 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 20 August 2007 - 04:40 PM

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.

#10 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 20 August 2007 - 05:19 PM

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:
AutoIt         
#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   ;==>_IsFocusedƒo݊÷ Ø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, 20 August 2007 - 05:24 PM.

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.

#11 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 20 August 2007 - 07:38 PM

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, 20 August 2007 - 07:42 PM.

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

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#12 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 20 August 2007 - 09:15 PM

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..
AutoIt         
#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, 20 August 2007 - 09:37 PM.

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.

#13 MrCreatoR

MrCreatoR

    Must AutoIt!

  • MVPs
  • 3,241 posts

Posted 21 August 2007 - 09:11 AM

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 ...

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

Posted Image AutoIt Russian CommunityPosted Image Projects: 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 ProgramPosted Image UDFs: 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 UDFPosted Image Examples: 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 DemoLike the examples/UDFs? Please rate the topic (up-right corner of the post header: Rating Posted Image)* === My topics === *

==========================================================Posted Image==========================================================

AutoIt is simple, subtle, elegant. © AutoIt Team


#14 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 21 August 2007 - 03:38 PM

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..

AutoIt         
#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.

#15 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 21 August 2007 - 04:31 PM

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.

#16 GaryFrost

GaryFrost

    I don't need your attitude. I have one of my own

  • Developers
  • 7,854 posts

Posted 21 August 2007 - 04:42 PM

Different way of doing it....

AutoIt         
#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.


#17 gseller

gseller

    Universalist

  • Active Members
  • PipPipPipPipPipPip
  • 1,057 posts

Posted 21 August 2007 - 06:00 PM

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.

#18 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 21 August 2007 - 08:24 PM

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.

#19 MCP

MCP

    Adventurer

  • Active Members
  • PipPip
  • 107 posts

Posted 14 October 2007 - 12:49 PM

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, 14 October 2007 - 01:52 PM.


#20 RazerM

RazerM

    cowinkeedenky - coincidence?

  • Active Members
  • PipPipPipPipPipPip
  • 1,246 posts

Posted 14 October 2007 - 01:22 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users