Jump to content

Simple and Stupid Control Hover UDF


binhnx
 Share

Recommended Posts

Here you are: SSCtrlHover.7z

And the example:

#AutoIt3Wrapper_UseX64=y

#include "SSCtrlHover_v3.au3"

GUICreate(@AutoItVersion)
$idLbl1 = GUICtrlCreateLabel("Label 1", 5, 5)
SSCtrlHover_Register($idLbl1, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 0)
$idLbl2 =GUICtrlCreateLabel("Label 2", 5, 35)
SSCtrlHover_Register($idLbl2, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 5)
GUISetState()

While GUIGetMsg() <> -3
  Sleep(10)
WEnd

Func FnNormal($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "Normal/Leave " & $idCtrl)
EndFunc

Func FnHover($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "Hover " & $idCtrl)
EndFunc

Func FnActive($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "Active " & $idCtrl)
EndFunc

Func FnClick($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "CLICK! " & $idCtrl & " - " & $hWnd & " - " & $vData)
EndFunc

 

Edited by LarsJ
Link to comment
Share on other sites

Interesting, What would be the best way to add effects to this UDF like tinting ,set-transparency, or even manipulating an image(controlid) without the need to add more image resources for these modes (Hover,Select,Normal) ..

Link to comment
Share on other sites

  • 2 weeks later...
On 2017-6-17 at 2:03 AM, LarsJ said:

在这里你是:SSCtrlHover.7z

和例子:

#AutoIt3Wrapper_UseX64 = Y

#include “SSCtrlHover_v3.au3

GUICreate@AutoItVersion$ idLbl1  =  GUICtrlCreateLabel(“标记1” , 55 ) 
SSCtrlHover _寄存器($ idLbl1 , “FnNormal” , 0 , “FnHover” , 0 , “FnActive” , 0 , “FnClick” , 0$ idLbl2  = GUICtrlCreateLabel(“Label 2” , 535 ) 
SSCtrlHover _ Register($ idLbl2 , “FnNormal” , 0 , “FnHover” , 0 , “FnActive” , 0 , “FnClick” , 5GUISetState()

而 GUIGetMsg() <>  - 3 
  睡眠(10WEnd

Func FnNormal($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “Normal / Leave”  & $ idCtrl )
EndFunc

Func FnHover($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “Hover”  & $ idCtrl )
EndFunc

Func FnActive($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “Active”  & $ idCtrl )
EndFunc

Func FnClick($ idCtrl , $ hWnd$ vData )
  ConsoleWrite@CRLF & “CLICK!”  & $ idCtrl  & “ - ”  & $ hWnd  & “ - ”  & $ vData )
EndFunc

 

Thank you so much

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...
  • 1 year later...
  • 2 years later...

hi, UDF cannot detect label over label ($idLbl0 on this case), what I can do to make it works? thanks

#include "SSCtrlHover_v3.au3"
#include <GUIConstants.au3>

GUICreate(@AutoItVersion)



$idBackgroundLabel = GUICtrlCreateLabel("", 5, 5, 200, 25)
GUICtrlSetBkColor($idBackgroundLabel, 0xFFFFFF)

$idLbl0 = GUICtrlCreateLabel("Label 0 over label not working", 5, 5, 200, 25)
GUICtrlSetBkColor($idLbl0, $GUI_BKCOLOR_TRANSPARENT)
SSCtrlHover_Register($idLbl0, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 0)



$idLbl1 = GUICtrlCreateLabel("Label 1", 5, 35, 200, 25)
SSCtrlHover_Register($idLbl1, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 0)

$idLbl2 = GUICtrlCreateLabel("Label 2", 5, 70, 200, 25)
SSCtrlHover_Register($idLbl2, "FnNormal", 0, "FnHover", 0, "FnActive", 0, "FnClick", 5)

GUISetState()

While GUIGetMsg() <> -3
  Sleep(10)
WEnd

Func FnNormal($idCtrl, $hWnd, $vData)
  GUICtrlSetColor($idCtrl, 0x000000)
  ConsoleWrite(@CRLF & "Normal/Leave " & $idCtrl)
EndFunc

Func FnHover($idCtrl, $hWnd, $vData)
  GUICtrlSetColor($idCtrl, 0xFF0000)
  ConsoleWrite(@CRLF & "Hover " & $idCtrl)
EndFunc

Func FnActive($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "Active " & $idCtrl)
EndFunc

Func FnClick($idCtrl, $hWnd, $vData)
  ConsoleWrite(@CRLF & "CLICK! " & $idCtrl & " - " & $hWnd & " - " & $vData)
EndFunc

 

Link to comment
Share on other sites

I have solution on my case but I found problem with this UDF, x64 bit run/compile freeze with loop in function, on UDF vesion Posted June 16, 2017 not freeze but still not work, can anyone help? I need to compile x64 bit exe, thanks

#include 'SSCtrlHover_v3.au3'
#include <GUIConstants.au3>
#include 'misc.au3'

Opt('GUIOnEventMode', 1)
Opt('GUICoordMode', 2)

$Menu = GUICreate('Menu', 398, 88, -1, 200, $WS_POPUP + $WS_BORDER, $WS_EX_TOPMOST + $WS_EX_TOOLWINDOW + $WS_EX_NOACTIVATE)

$idBackgroundLabel0 = GUICtrlCreateLabel('', 0, 0, 400, 30)
   GUICtrlSetBkColor($idBackgroundLabel0, $GUI_BKCOLOR_TRANSPARENT)
   SSCtrlHover_Register($idBackgroundLabel0, 'FnNormal', 0, 'FnHover', 0, 'Change_Value')
$idLbl0 = GUICtrlCreateLabel('   Label 0 - click to change value', -1, -1, 400, 30, $SS_CENTERIMAGE)
   GUICtrlSetBkColor($idLbl0, $GUI_BKCOLOR_TRANSPARENT)

$idBackgroundLabel1 = GUICtrlCreateLabel('', -1, 0, 400, 30)
   GUICtrlSetBkColor($idBackgroundLabel1, $GUI_BKCOLOR_TRANSPARENT)
   SSCtrlHover_Register($idBackgroundLabel1, 'FnNormal', 0, 'FnHover', 0, 'FnActive')
$idLbl1 = GUICtrlCreateLabel('   Label 1', -1, -1, 400, 30, $SS_CENTERIMAGE)
   GUICtrlSetBkColor($idLbl1, $GUI_BKCOLOR_TRANSPARENT)

$idBackgroundLabel2 = GUICtrlCreateLabel('', -1, 0, 400, 30)
   GUICtrlSetBkColor($idBackgroundLabel2, $GUI_BKCOLOR_TRANSPARENT)
   SSCtrlHover_Register($idBackgroundLabel2, 'FnNormal', 0, 'FnHover', 0, 'FnExit')
$idLbl2 = GUICtrlCreateLabel('   Exit', -1, -1, 400, 30, $SS_CENTERIMAGE)
   GUICtrlSetBkColor($idLbl2, $GUI_BKCOLOR_TRANSPARENT)

GUISetState(@SW_SHOWNOACTIVATE, $Menu)



for $i = 0 to 0 step 0
   if WinGetProcess(WinGetHandle('')) = @AutoItPID and _IsPressed('1B') then exit
   Sleep(10)
next



Func FnNormal($idCtrl, $hWnd, $vData)
   GUICtrlSetBkColor($idCtrl, $GUI_BKCOLOR_TRANSPARENT)
   GUICtrlSetColor($idCtrl+1, 0x000000)
   ConsoleWrite(@CRLF & 'Leave ' & $idCtrl)
EndFunc



Func FnHover($idCtrl, $hWnd, $vData)
   GUICtrlSetBkColor($idCtrl, 0x000000)
   GUICtrlSetColor($idCtrl+1, 0xFFFFFF)
   ConsoleWrite(@CRLF & 'Hover ' & $idCtrl)
EndFunc



Func FnActive($idCtrl, $hWnd, $vData)
   ConsoleWrite(@CRLF & 'Active ' & $idCtrl)
EndFunc



Func FnExit($idCtrl, $hWnd, $vData)
   exit
EndFunc



func Change_Value($Menu__Ctrl, $Menu__Hwnd, $vData)
   $Value = Input('Change value', '1000')
   ConsoleWrite(@CRLF & 'Change_value to ' & $Value)
endfunc



func Input($Title='', $InputFirstValue='')
   $Width = 172
   $Height = 78
   $Gui = GUICreate($Title, $Width, $Height, -1, 300, $WS_POPUP + $WS_BORDER)
   $GuiTitle = WinGetTitle($Gui)
   $GuiTitleBackground = GUICtrlCreateLabel('', 2, 2, 6, 24, -1, $GUI_WS_EX_PARENTDRAG)
   $GuiTitleLabel = GUICtrlCreateLabel($GuiTitle, 0, -1, $Width-6, -1, $SS_LEFT + $SS_CENTERIMAGE, $GUI_WS_EX_PARENTDRAG)
   $Input = GUICtrlCreateInput($InputFirstValue, 4-$Width, 0, $Width-(2*4), 20, $ES_CENTER + $ES_AUTOHSCROLL)
   $ButtonOk = GUICtrlCreateButton('OK', -1, 4, 80, 25, $BS_DEFPUSHBUTTON)
      GUICtrlSetOnEvent($ButtonOk, 'InputOk')
   $ButtonCancel = GUICtrlCreateButton('Cancel', 3, -1, 80, 25)
      GUICtrlSetOnEvent($ButtonCancel, 'InputDelete')
   GUICtrlSetState($Input, $GUI_FOCUS)
   GUISetState(@SW_SHOW, $Gui)
   Assign('Input__ButtonOkIsPressed__'    &number($Gui), False, 2)
   Assign('Input__ButtonCancelIsPressed__'&number($Gui), False, 2)
;#comments-start ;WHEN DELETE LOOP WORKS FINE
   for $i = 0 to 0 step 0
      if _IsPressed('1B') then
         GUIDelete($Gui)
         send('{esc up}')
         return False
      endif
      if Eval('Input__ButtonCancelIsPressed__'&number($Gui)) then
         Assign('Input__ButtonCancelIsPressed__'&number($Gui), False, 2)
         GUIDelete($Gui)
         return False
      endif
      if Eval('Input__ButtonOkIsPressed__'&number($Gui)) then
         Assign('Input__ButtonOkIsPressed__'&number($Gui), False, 2)
         $InputRead = GUICtrlRead($Input)
         GUIDelete($Gui)
         return $InputRead
      endif
      Sleep(10)
   next
;#comments-end ;WHEN DELETE LOOP WORKS FINE
endfunc



func InputDelete()
   Assign('Input__ButtonCancelIsPressed__'&number(@GUI_WinHandle), True, 2)
endfunc



func InputOk()
   Assign('Input__ButtonOkIsPressed__'&number(@GUI_WinHandle), True, 2)
endfunc

 

Edited by ibecko
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

×
×
  • Create New...