Jump to content

Recommended Posts

Posted

  Quote

with my example is much more simplier

Let me disagree with that, with your example you need to set additional function call inside the main loop and for each control you need to check manualy the event!

Many scripters doesn't like the idea of using the main loop by UDF, it (UDF) supose to "have life" of his own :).

  Quote

u don`t need 4 functions to create the three states

Why is that not good? :) 3, 4, is that really matter? :) the main thing here is that you set once the functions, and you do what you need inside them for every control.

  Quote

in the while loop with ur example it would grow to big....

It's only an example, you don't have to use the main loop at all, you can show the message box (or whatever is needed) in the function that called on PrimaryDown/Up event, it's just the handling of such internal needs better to see "on the surface".

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 1 month later...
Posted

This is old, but I have to give my kudos. This is excellent. I was using a different udf, and concocted one of my own, but both of them caused problems elsewhere in the script. This seems to work flawlessly with no cpu load. Great work.

  • 2 months later...
Posted

@Champak, @markedagain

Thanks for the feedbacks.

  Quote

any suggestions?

Check the obfuscater? :)

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  Wooltown said:

If you wish to use it on a TreeView see this topic

http://www.autoitscript.com/forum/index.php?showtopic=72441

Thanks, i will check this.

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

  • 2 months later...
Posted

Very useful UDF and working perfect on Vista, XP and Windows 2000 Server & Workstation. But the UDF is not working on Server 2003! Any idea how to get it working on server 2003?

I have created a GUI that looks like the Office2007 GUI, using your "Experimental version".

Code (very small version) with pics here

Compiled version here

  • 2 weeks later...
Posted

Since MrCreator didn't update his Experimental version to new DLLCallback -functions, i did it and included my HWnd-fix:

#include-once
Opt("MustDeclareVars", 1)
;_GUICtrlSetOnHover Initialize
Global $aHOVER_CONTROLS_ARRAY[1][1]
Global $aLAST_HOVERED_ELEMENT[2]                        = [-1, -1]
Global $LAST_HOVERED_ELEMENT_MARK                       = -1
Global $LAST_CLICKED_ELEMENT_MARK                       = -1
Global $pTimerProc                                      = DLLCallBackRegister("_MAIN_CALLBACK_ONHOVER_PROC","none", "hwnd;uint;uint;dword")
Global $uiTimer                                         = DllCall("user32.dll", "uint", "SetTimer", _
                                                                "hwnd", 0, "uint", TimerInit(), "int", 10, "ptr", DllCallBackGetPtr($pTimerProc))

$uiTimer = $uiTimer[0]

Opt("MustDeclareVars", 0)

;===============================================================================
;
; Function Name:    _GUICtrlSetOnHover()
; Description:      Set function(s) to call when hovering/leave hovering GUI elements.
; Parameter(s):     $iCtrlID - The Ctrl ID to set hovering for (can be a -1 as indication to the last item created).
;                   $sHoverFuncName - Function to call when the mouse is hovering the control.
;                   $sLeaveHoverFuncName - [Optional] Function to call when the mouse is leaving hovering the control
;                       (-1 - function is not called).
;                   $sPrimaryDownFuncName - [Optional] Function to call when Primary mouse button is clicked on the control.
;                       (-1 - function is not called).
;                   $sPrimaryUpFuncName - [Optional] Function to call when Primary mouse button is released on the control.
;                       (-1 - function is not called).
;
; Return Value(s):  Always returns 1 regardless of success.
; Requirement(s):   None.
; Note(s):          1) TreeView/ListView Items can not be set :(.
;                   2) When the window is not active, the hover/leave hover functions will still called,
;                      but not when the window is disabled.
;                   3) The hover/leave hover functions will be called even if the script is paused by such functions as MsgBox().
;
; Author(s):        G.Sandler (a.k.a CreatoR).
;
;===============================================================================
Func _GUICtrlSetOnHover($iCtrlID, $sHoverFuncName, $sLeaveHoverFuncName=-1, $sPrimaryDownFuncName=-1, $sPrimaryUpFuncName=-1)
    Local $iUbound = UBound($aHOVER_CONTROLS_ARRAY)
    ReDim $aHOVER_CONTROLS_ARRAY[$iUbound+1][5]
    
    $aHOVER_CONTROLS_ARRAY[$iUbound][0] = GUICtrlGetHandle($iCtrlID)
    $aHOVER_CONTROLS_ARRAY[$iUbound][1] = $sHoverFuncName
    $aHOVER_CONTROLS_ARRAY[$iUbound][2] = $sLeaveHoverFuncName
    $aHOVER_CONTROLS_ARRAY[$iUbound][3] = $sPrimaryDownFuncName
    $aHOVER_CONTROLS_ARRAY[$iUbound][4] = $sPrimaryUpFuncName
    
    $aHOVER_CONTROLS_ARRAY[0][0] = $iUbound
    
    Return 1
EndFunc

;CallBack function to handle the hovering process
Func _MAIN_CALLBACK_ONHOVER_PROC($hWnd, $uiMsg, $idEvent, $dwTime)
    If UBound($aHOVER_CONTROLS_ARRAY)-1 < 1 Then Return
    
    Local $hControlGetHovered = _ControlGetHoveredHWnd()
    Local $iControlGetHovered = _ControlGetID($hControlGetHovered)
    Local $iCheck_LHE = -1
    If $aLAST_HOVERED_ELEMENT[1] >= 0 Then $iCheck_LHE = GuiCtrlGetHandle($aLAST_HOVERED_ELEMENT[1])
    Local $iCheck_LCEM = $LAST_CLICKED_ELEMENT_MARK
    
    ;Leave Hovering Process and reset variables
    If $iControlGetHovered = 0 Or ($iCheck_LHE <> -1 And $hControlGetHovered <> $iCheck_LHE) Then
        If $LAST_HOVERED_ELEMENT_MARK = -1 Then Return
        If $aLAST_HOVERED_ELEMENT[0] <> -1 Then Call($aLAST_HOVERED_ELEMENT[0], $aLAST_HOVERED_ELEMENT[1])
        
        $aLAST_HOVERED_ELEMENT[0] = -1
        $aLAST_HOVERED_ELEMENT[1] = -1
        $LAST_HOVERED_ELEMENT_MARK = -1
        $LAST_CLICKED_ELEMENT_MARK = -1
    Else ;Hovering Process, Primary Down/Up handler, and set LAST_HOVERED_ELEMENT
        For $i = 1 To $aHOVER_CONTROLS_ARRAY[0][0]
            If $aHOVER_CONTROLS_ARRAY[$i][0] = $hControlGetHovered Then
                
                ;Primary Down/Up handler
                If $iCheck_LCEM = -1 Or $iCheck_LCEM = $hControlGetHovered Then
                    Local $aCursorInfo = GUIGetCursorInfo()
                    
                    If IsArray($aCursorInfo) Then
                        If $aCursorInfo[2] = 1 And $aHOVER_CONTROLS_ARRAY[$i][3] <> -1 Then
                            ;Primary Down
                            
                            Call($aHOVER_CONTROLS_ARRAY[$i][3], $iControlGetHovered)
                            $LAST_CLICKED_ELEMENT_MARK = $hControlGetHovered
                        ElseIf $aCursorInfo[2] = 0 And $aHOVER_CONTROLS_ARRAY[$i][4] <> -1 And _
                            $iCheck_LCEM = $hControlGetHovered Then
                            ;Primary Up
                            
                            Call($aHOVER_CONTROLS_ARRAY[$i][4], $iControlGetHovered)
                            $LAST_CLICKED_ELEMENT_MARK = -1
                        EndIf
                    EndIf
                EndIf
                
                If $LAST_HOVERED_ELEMENT_MARK = $aHOVER_CONTROLS_ARRAY[$i][0] Then ExitLoop
                $LAST_HOVERED_ELEMENT_MARK = $aHOVER_CONTROLS_ARRAY[$i][0]
                

                Call($aHOVER_CONTROLS_ARRAY[$i][1], $iControlGetHovered)
                
                If $aHOVER_CONTROLS_ARRAY[$i][2] <> -1 Then
                    $aLAST_HOVERED_ELEMENT[0] = $aHOVER_CONTROLS_ARRAY[$i][2]
                    $aLAST_HOVERED_ELEMENT[1] = $iControlGetHovered
                EndIf
                
                ExitLoop
            EndIf
        Next
    EndIf
EndFunc

;Thanks to amel27 for that one!!!
; modified by prog@ndy
Func _ControlGetID($ControlGetHovered)
    Local $ControlGetHoveredID = DllCall("user32.dll", "int", "GetDlgCtrlID", "hwnd", $ControlGetHovered)
    If @error Then Return
    Return $ControlGetHoveredID[0]
EndFunc

;Thanks to amel27 for that one!!!
; modified by prog@ndy
Func _ControlGetHoveredHwnd()
    Local $iOld_Opt_MCM = Opt("MouseCoordMode", 1)
    Local $mouse = MouseGetPos()
    Local $iRet = DllCall("user32.dll", "hwnd", "WindowFromPoint", _
        "long", $mouse[0], _
        "long", $mouse[1])
    Local $iError = @error
    Opt("MouseCoordMode", $iOld_Opt_MCM)
    If $iError Then Return Seterrot(1,0,0)
    Return $iRet[0]
EndFunc

;Release the CallBack resources
Func CallBack_Exit()
    DllCallbackFree($pTimerProc)
    DllCall("user32.dll", "int", "KillTimer", "hwnd", 0, "uint", $uiTimer)
EndFunc

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Posted

I was so close to the solution but I gave up yesterday.

Prog@ndy Thank you very much, you are fantastic :) . It's now working and is not blocked by DEP on the Windows 2003/2008 servers.

I identified only a spelling error in line 132 --> Seterror instead of Seterrot

  • 4 weeks later...
Posted

Stumbled across this today by accident but it's somethign I was looking for a week or so ago. Does what I need it to do. Thanks for posting it.

Other People's Stuff:Andy Flesner's AutoIt v3: Your Quick Guide[topic="34302"]Locodarwin's ExcelCom_UDF[/topic][topic="61090"]MrCreatorR's Opera Library[/topic]
  • 2 weeks later...
Posted (edited)

New version!

History:

  Quote

[v1.5]

+ Added AutoIt 3.2.10.0+ support, but 3.2.8.1 or less is dropped :) (due to lack of native CallBack functions).

+ Added Primary Down and Primary Up support. Helping to handle with the buttons pressing.

+ Added new arguments to calling function...

------The OnHover function now can recieve two more arguments:

------------------$iHoverMode - Defines the hover mode (1 - Hover, 2 - Leaves Hovering)

------------------$hWnd_Hovered - Control Handle where the mouse is moved to (after hovering).

* Almost all code of this UDF was rewritted.

* Now the main function name is _GUICtrl_SetOnHover(),

------but for backwards compatibility reasons, other (old) function names are still supported.

* Fixed bug with hovering controls in other apps.

* Improvements in generaly, the UDF working more stable now.

[v1.?]

* Beta changes, see this thread's previous posts for more details.

[v1.0]

* First release.

Now all examples and the latest UDF version can be found in one archive in first post! Edited by MrCreatoR

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted

  MrCreatoR said:

New version!

History:

Now all examples and the latest UDF version can be found in one archive in first post!

are you ever going to add support for secondary up and down?
Posted
  Tomb said:

are you ever going to add support for secondary up and down?

Can you show me when/how it will be usefull?

 

  Reveal hidden contents

 

 

AutoIt is simple, subtle, elegant. © AutoIt Team

Posted
  MrCreatoR said:

Can you show me when/how it will be usefull?

it would be great having different functons for right and left clicks on controls.
Posted
  Tomb said:

it would be great having different functons for right and left clicks on controls.

He was talking about Secondary Up/Down, NOT Right/Left click.

George

  Reveal hidden contents
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!"

  • 2 months later...

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
  • Recently Browsing   0 members

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