Jump to content

_ControlHover() UDF


Valuater
 Share

Recommended Posts

_ControlHover() 1.2.0 September 25, 2006

What ControlHover() does

1

_ControlHover() does NOT move the mouse over a control

2

_ControlHover() will tell you when the mouse....

A is over a control

B has left the control

C Has clicked on a control

D has released the click on a control

3

_ControlHover() will find any control, out of the added controls, that did the above #2

_ControlHover.au3

..... and a Demo to "demonstrate" different formats of use

_ControlHover_Demo.au3

Demo to Move Controls by dandymcgee

New... _ButtonHover() - Made Easy - Many people have used this just for buttons

( and has on-event-mode )

;===============================================================================
;
; Function Name:    _ControlHover()
; Description:      Enable Mouse/Hover Over Control Events
;                    Find if Mouse is over a known control
;                    Find if a Mouse has Clicked on a known control
;                    Add, Remove, or Verify the control within the known control list
; Parameter(s):     $cH_Mode    [default]       0 = Find if Mouse is over a known control
;                               [optional]        1 = Find if a Mouse has Clicked on a known control
;                                               2 = Add a control to the known control list
;                                               3 = Remove a control from the known control list
;                                               4 = Verify a control is in the known control list
;                   $cH_hWin    [optional]       - Window handle as returned by GUICreate()
;                                [preferred]        - Window handle to save CPU usage and speed of _ControlHover()
;                                                - and Avoid array errors for "non-active window"
;                   $cH_hCntrl    [required]       - Control ID to Add, Remove, or Verify the control within the known control list
;                                [not used]        - to find if a mouse is over or has clicked on a known control
; Requirement(s):   #include<Array.au3>
; Return Value(s):  
;                    $cH_Mode 0 or 1 
;                                On Success     Return = 1        @error = 0, @extended = Current known control 
;                               While Success Return = "" 
;                               On Failure: Return = 0        @error = 1, @extended = Last known control 
;                    $cH_Mode 2, 3, or 4
;                                On Success     Return = 1        @error = 0, @extended = Function's return line number 
;                    All $cH_Mode's
;                               On Error:     Return = Description of the error        
;                                                            @error = -1, @extended = Function's return line number 
; Author(s):        Valuater, Robert M
;
;===============================================================================

Support, Inhancements, comments or problems .... are all welcome

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

  • Replies 44
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Makes things alot easier! 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

UDF Name: _ControlHover.au3

;

; Version v1.2.0 Sept 25, 2006, built with Autoit 3.2.1.3

removed excessive @errror use ... example

If $Click = 1 And Not @Error And @extended = $Button_1 Then MsgBox(0, 'Testing', 'Button 1 was pressed', 2)

is now ....

If $Click = 1 And @extended = $Button_1 Then MsgBox(0, 'Testing', 'Button 1 was pressed', 2)

Added debug to assist in development

completely new demo with easier use and more examples of use

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

This is great creates a more "pro" type of look. It would be nice though if _HoverFound(), _HoverLost(), and _CheckHoverAndPressed, were in the UDF. The hard but not impossible part would be creating it so that the user could still have complete control over what the function did when found & lost.

This will be a part of every script though.

Thanks alot!

INI TreeViewA bus station is where a bus stops, a train station is where a train stops. Onmy desk I have a work station...
Link to comment
Share on other sites

  • 4 weeks later...

Thanks Strate...

Added: A Nice _ControlHover() Button Demo by Dhilip

see post #1

8)

Thanks Valuater for _ControlHover() UDF :whistle:

[u]My Projects[/u]:General:WinShell (Version 1.6)YouTube Video Downloader Core (Version 2.0)Periodic Table Of Chemical Elements (Version 1.0)Web-Based:Directory Listing Script Written In AutoIt3 (Version 1.9 RC1)UDFs:UnicodeURL UDFHTML Entity UDF[u]My Website:[/u]http://dhilip89.hopto.org/[u]Closed Sources:[/u]YouTube Video Downloader (Version 1.3)[quote]If 1 + 1 = 10, then 1 + 1 ≠ 2[/quote]

Link to comment
Share on other sites

  • 3 weeks later...

I can't manage to use it with GUi event mode.

you most certainly can use it with on event mode... you can mouse over controls and ... change color, make a tooltip show, change background picture.... and many other things

You can also use the $Click on a secondary GUI, as it seems that GUIOnEventMode has a problem with a second GUI... _ControlHover() does not have a problem with it!

dont limit yourself... 8)

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

I managed to use your (great) UDF in putting _CheckHoverAndPressed() in the main loop (event mode), and by reducing the sleep() from 1000ms to 100 ms.

But if I want to set a GUICtrlSetOnEvent I don't know if I have to set it to _ControlHover() or _CheckHoverAndPressed() (both don't work) or if I have to change all the system used in the ControlHover Demo.

Link to comment
Share on other sites

Yes but I want to make the _ControlHover within event mode, I've tryed this:

GUICtrlSetOnEvent(_ControlHover(0),'_CheckHoverAndPressed')

and the most combinations that are possible, but I didn't find a way for not having the _CheckHoverAndPressed() function in a loop . Can you help me?

Link to comment
Share on other sites

Yes but I want to make the _ControlHover within event mode, I've tryed this:

GUICtrlSetOnEvent(_ControlHover(0),'_CheckHoverAndPressed')

and the most combinations that are possible, but I didn't find a way for not having the _CheckHoverAndPressed() function in a loop . Can you help me?

Thats funny... don't get me wrong, I actually love the idea...

Just that, it won't work.... sorry

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Very nicely done @Val

This will come in handy.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Hey all, here is my example script:

2.) This one is my example of being able to move the controls around (only the label moves as of now):

UPDATED: The new example lets you move any of the three controls, and right clicking allows you to rename them.

#include<GuiConstants.au3>
#include<ControlHover.au3>
Opt("MouseCoordMode", 2)

$Main_GUI = GuiCreate("DanGui", 400, 250)

$MoveMe = GuiCtrlCreateLabel("Move Me (Test)", 150, 70, 80, 20)
$OK_BUT = GuiCtrlCreateButton("OK", 70, 160, 80, 20)
$CANCEL_BUT = GuiCtrlCreateButton("CANCEL", 220, 160, 90, 20)
$Move_But = GUICtrlCreateButton("Unlock Controls", 150, 220)
$Allow_Move = 0
_ControlHover(2, "", $MoveMe)
_ControlHover(2, "", $OK_BUT)
_ControlHover(2, "", $CANCEL_BUT)

GuiSetState()

While 1
    $msg = GuiGetMsg()
    Select
        Case $msg = $OK_BUT
            If $Allow_Move = 0 Then
                MsgBox(0, "Title", "This button still works!")
            EndIf
        Case $msg = $CANCEL_BUT
            If $Allow_Move = 0 Then
                MsgBox(0, "Title", "This button still works!")
            EndIf
        Case $msg = $Move_But
            If $Allow_Move = 0 Then
                GUICtrlSetData(6, "Lock Controls")
                $Allow_Move = 1
            ElseIf $Allow_Move = 1 Then
                GUICtrlSetData(6, "Unlock Controls")
                $Allow_Move = 0
            EndIf
        Case $msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
    
    ;If moving is enabled
    
    If $Allow_Move = 1 Then
        
        ;Check for a Hover
        
        $Over = _ControlHover(0, $Main_GUI)
        If $Over = 1 Then
            If @extended = $MoveMe Then
                GUICtrlSetBkColor(3, 0xFF0000)
            Else
                GUICtrlSetBkColor(3, 0xECE9D8)
            EndIf
            If @extended = $OK_BUT Then
                GUICtrlSetColor(4, 0xFF0000)
            Else
                GUICtrlSetColor(4, 0xECE9D8)
            EndIf
        EndIf
        
        ;Check for a Click
        
        $Click = _ControlHover(1, $Main_GUI)
        If $Click = 1 Then
            Select
                Case @extended = $MoveMe
                    MoveControl(3)
                Case @extended = $OK_BUT
                    MoveControl(4)
                Case @extended = $CANCEL_BUT
                    MoveControl(5)
            EndSelect
        EndIf
        $Check_Click = GUIGetCursorInfo()
        Select
            Case $Check_Click[4] = 3 And $Check_Click[3] = 1
                Text_Change(3)
            Case $Check_Click[4] = 4 And $Check_Click[3] = 1
                Text_Change(4)
            Case $Check_Click[4] = 5 And $Check_Click[3] = 1
                Text_Change(5)
        EndSelect
    EndIf
WEnd

;Text_Change ==> To rename a control in "Unlocked" mode when it is right-clicked on.

Func Text_Change($IDtoRename)
    $New_Name = InputBox("Label Change", "Input new text for this label:")
    If $New_Name = "" Then
        MsgBox(0, "ERROR!", "The entered text was invalid.  No changes have been made.")
    Else
        GUICtrlSetData($IDtoRename, $New_Name)
    EndIf
EndFunc

;MoveControl ==> When a control is clicked on in "Unlocked" mode.

Func MoveControl($IDtoMove)
    Do
        $Check_Click = GUIGetCursorInfo()
        $mousepos = MouseGetPos()
        GUICtrlSetPos($IDtoMove, $mousepos[0] - 40, $mousepos[1] - 10)
        Sleep(20)
    Until $Check_Click[2] = 0
EndFunc

Enjoy! I hope Val get's a sticky for this ;).

Edited by dandymcgee

- Dan [Website]

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