Jump to content

_ControlHover


 Share

Recommended Posts

Hello,

sorry for boring you again but have a question about _ControlHover and its use.

Can't undestand $cH_hCntrl use, need manage event when mouse hover on a button.

(eg. tooltip saying 'i'm on button x')

reading _ControlHover instruction, find this :

$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

post little example as test code :

#include <_ControlHover.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <EditConstants.au3>
;/////////////////////////////////////////////////////////////////////////////
;               declare 
;/////////////////////////////////////////////////////////////////////////////
dim $user_insert, $num
dim $i

$Btn_Color = 0x7A9DD8
$Hover_Color = 0xFF0000;0x7AC5D8

Global $hGui, $xmouseData = 0
Local $input 
Local $iRotNum = 0, $sRet
Opt("MouseCoordMode", 2);1=absolute, 0=relative, 2=client

GUICreate("", 0, 0, 0, 0)
GUISetState()

;/////////////////////////////////////////////////////////////////////////////
;               GUI
;/////////////////////////////////////////////////////////////////////////////
;~ $mygui = GUICreate("T9", 300, 350, 400, 400)
$mygui = GUICreate("GUI", 454, 328, 551, 252)

$Button_2 = GUICtrlCreateButton("abc", 0, 0, 100, 100, 0)
$Button_3 = GUICtrlCreateButton("def", 100, 0, 100, 100, 0)
$Button_4 = GUICtrlCreateButton("ghi", 200, 0, 100, 100, 0)
$Button_5 = GUICtrlCreateButton("jkl", 0, 100, 100, 100, 0)

$Button_1 = GUICtrlCreateButton("FUNC", 100, 100, 100, 100, 0)

$Button_6 = GUICtrlCreateButton("mno", 200, 100, 100, 100, 0)
$Button_7 = GUICtrlCreateButton("pqrs", 0, 200, 100, 100, 0)
$Button_8 = GUICtrlCreateButton("tuv", 100, 200, 100, 100, 0)
$Button_9 = GUICtrlCreateButton("wxyz", 200, 200, 100, 100, 0)

        
GUICtrlSetBkColor($Button_1, $Btn_Color )
GUICtrlSetBkColor($Button_2, $Btn_Color )
GUICtrlSetBkColor($Button_3, $Btn_Color )
GUICtrlSetBkColor($Button_4, $Btn_Color )
GUICtrlSetBkColor($Button_5, $Btn_Color )
GUICtrlSetBkColor($Button_6, $Btn_Color )
GUICtrlSetBkColor($Button_7, $Btn_Color )
GUICtrlSetBkColor($Button_8, $Btn_Color )
GUICtrlSetBkColor($Button_9, $Btn_Color )

GUISetState ()    


;/////////////////////////////////////////////////////////////////////////////
;               ENABLE CONTROL ON BUTTONS
;/////////////////////////////////////////////////////////////////////////////
_ControlHover(2, "", $Button_1) 
_ControlHover(2, "", $Button_2)
_ControlHover(2, "", $Button_3) 
_ControlHover(2, "", $Button_4)
_ControlHover(2, "", $Button_5) 
_ControlHover(2, "", $Button_6)
_ControlHover(2, "", $Button_7) 
_ControlHover(2, "", $Button_8)
_ControlHover(2, "", $Button_9) 


;/////////////////////////////////////////////////////////////////////////////
;               MAIN
;/////////////////////////////////////////////////////////////////////////////
While 1
   $msg1 = GUIGetMsg()
    If $msg1 = $GUI_EVENT_CLOSE Then 
        ExitLoop
    EndIf
   
    $Over = _ControlHover(0, $mygui); or _ControlHover() - or _ControlHover(0)
    If $Over = 1 Then
        $tempID = @extended
        GUICtrlSetBkColor( $tempID, $Hover_Color); color does not work on buttons - an Autoit Limit

    Else
        $tempID = @extended 
        GUICtrlSetBkColor( $tempID, $Btn_Color )
        
    EndIf
   
   
    $Click = _ControlHover(1, $mygui); or _ControlHover(1)
    If $Click = 1 And @extended = $Button_2 Then msgbox(0,"","clicked")
    If $Click = 1 And @extended = $Button_3 Then msgbox(0,"","clicked")
    If $Click = 1 And @extended = $Button_4 Then msgbox(0,"","clicked")
    If $Click = 1 And @extended = $Button_5 Then msgbox(0,"","clicked")
        
    If $Click = 1 And @extended = $Button_1 Then msgbox(0,"","FUNC")
        
    If $Click = 1 And @extended = $Button_6 Then msgbox(0,"","clicked")
    If $Click = 1 And @extended = $Button_7 Then msgbox(0,"","clicked")
    If $Click = 1 And @extended = $Button_8 Then msgbox(0,"","clicked")
    If $Click = 1 And @extended = $Button_9 Then msgbox(0,"","clicked")


Wend
    



;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;          functions   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Func button_input($num)
    
    GUICtrlSetData($in, '')
    
    $user_insert = $user_insert & $num
    
        If $num = 'nul' Then
            GUICtrlSetData($in, GUICtrlRead($in) & 0)
        Else
            GUICtrlSetData($in, GUICtrlRead($in) & $user_insert)
        EndIf

;~   search_word()
EndFunc

thank you for help,

m.

Link to comment
Share on other sites

Can't undestand $cH_hCntrl use, need manage event when mouse hover on a button.

Your example working fine for me, what is the problem?

P.S

You also can try the GUICtrlSetOnHover UDF...

#include <GUICtrlSetOnHover_UDF.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <Misc.au3>
#include <EditConstants.au3>
;

;/////////////////////////////////////////////////////////////////////////////
;                declare 
;/////////////////////////////////////////////////////////////////////////////
Global $user_insert, $num, $i

$Btn_Color = 0x7A9DD8
$Hover_Color = 0xFF0000 ;0x7AC5D8

Global $hGui, $xmouseData = 0
Global $input, $iRotNum = 0, $sRet

Opt("MouseCoordMode", 2) ;1=absolute, 0=relative, 2=client

GUICreate("", 0, 0, 0, 0)
GUISetState()

;/////////////////////////////////////////////////////////////////////////////
;                GUI
;/////////////////////////////////////////////////////////////////////////////
;~ $mygui = GUICreate("T9", 300, 350, 400, 400)
$hMyGUI = GUICreate("GUI", 454, 328, 551, 252)

$Button_1 = GUICtrlCreateButton("FUNC", 100, 100, 100, 100, 0)
$Button_2 = GUICtrlCreateButton("abc", 0, 0, 100, 100, 0)
$Button_3 = GUICtrlCreateButton("def", 100, 0, 100, 100, 0)
$Button_4 = GUICtrlCreateButton("ghi", 200, 0, 100, 100, 0)
$Button_5 = GUICtrlCreateButton("jkl", 0, 100, 100, 100, 0)
$Button_6 = GUICtrlCreateButton("mno", 200, 100, 100, 100, 0)
$Button_7 = GUICtrlCreateButton("pqrs", 0, 200, 100, 100, 0)
$Button_8 = GUICtrlCreateButton("tuv", 100, 200, 100, 100, 0)
$Button_9 = GUICtrlCreateButton("wxyz", 200, 200, 100, 100, 0)

For $i = $Button_1 To $Button_9
    GUICtrlSetBkColor($i, $Btn_Color)
    _GUICtrlSetOnHover($i, "Hover_Func", "Leave_Hover_Func") 
Next

GUISetState()

;/////////////////////////////////////////////////////////////////////////////
;                MAIN
;/////////////////////////////////////////////////////////////////////////////
While 1
    $nMsg = GUIGetMsg()
    
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button_1
            MsgBox(64, "", "FUNC", 0, $hMyGUI)
        Case $Button_2 To $Button_9
            MsgBox(64, "", "Clicked (" & $nMsg & ")", 0, $hMyGUI)
    EndSwitch
Wend

Func Hover_Func($iCtrlID)
    Switch $iCtrlID
        Case $Button_1 To $Button_9
            GUICtrlSetBkColor($iCtrlID, $Hover_Color)
    EndSwitch
EndFunc

Func Leave_Hover_Func($iCtrlID)
    Switch $iCtrlID
        Case $Button_1 To $Button_9
            GUICtrlSetBkColor($iCtrlID, $Btn_Color)
    EndSwitch
EndFunc

 

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

when move mouse over a button, tooltip say "you are here !", without click.

(now only change color)

m.

Use GUICtrlSetTip($i, "You are here !"), or in the Hover_Func() add ToolTip("You are here !"), and to the Leave_Hover_Func() add ToolTip("").

 

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

is possible to pass value to a variable when i hover on a button ?

What value to what variable? Can you be more specific?

 

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

in my test code there is a function on bottom :

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;          functions   
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Func button_input($num)
    
    GUICtrlSetData($in, '')
    
    $user_insert = $user_insert & $num
    
        If $num = 'nul' Then
            GUICtrlSetData($in, GUICtrlRead($in) & 0)
        Else
            GUICtrlSetData($in, GUICtrlRead($in) & $user_insert)
        EndIf

EndFunc

in original script this function receives a number when a button is pressed :

$Click = _ControlHover(1, $mygui); or _ControlHover(1)
;----------------------------------------------------------- manage mouse pressed buttons
    If $Click = 1 And @extended = $Button_2 Then button_input(2)
    If $Click = 1 And @extended = $Button_3 Then button_input(3)
    If $Click = 1 And @extended = $Button_4 Then button_input(4)
    If $Click = 1 And @extended = $Button_5 Then button_input(5)

Button click is needed in my script, want to substitute with mouse hover.

m.

Edited by myspacee
Link to comment
Share on other sites

Button click is needed in my script, want to substitute with mouse hover.

Then use it instead of (or together with) changing the button color.

$Over = _ControlHover(0, $mygui); or _ControlHover() - or _ControlHover(0)
    If $Over = 1 Then
        $tempID = @extended
        GUICtrlSetBkColor( $tempID, $Hover_Color); color does not work on buttons - an Autoit Limit
        button_input($tempID)
    Else
        $tempID = @extended    
        GUICtrlSetBkColor( $tempID, $Btn_Color )
    EndIfoÝ÷ ØêðØfÉìZ^ë-¦ëb¶)íáè½êźwºw-ÚºÚ"µÍ[ÈÝÑ[Ê   ÌÍÚPÝQ
BÝÚ]Ú    ÌÍÚPÝQØÙH ÌÍÐ]ÛÌHÈ  ÌÍÐ]ÛÎBÕRPÝÙ]ÐÛÛÜ   ÌÍÚPÝQ  ÌÍÒÝÐÛÛÜB]ÛÚ[]
    ÌÍÚPÝQ
B[ÝÚ]Ú[[

 

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

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