Jump to content

ASM Button Hover


wolf9228
 Share

Recommended Posts

ASM_ButtonHover.zip

0x000502_D2.png

ASM_ButtonHover.au3

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>
#include <SendMessage.au3>

Global $PointerSize = DllStructGetSize(DllStructCreate("PTR")) ,$ControlThread = DllStructCreate("INT TA;INT TB;INT TC")
Global $User32Dll = _WinAPI_LoadLibrary("User32.dll"),$AsmVar = DllStructCreate("INT LOOP;PTR PtrAtPos;HWND CurrentHwnd")
Global $StructButtonHover =0 ,$StructBHover =DllStructCreate("INT COUNT;PTR BHOVER") , $StructBHSize = DllStructGetSize _
( DllStructCreate(  "HWND  HWNDA; HWND  HWNDB; INT  TPRESS; INT  THOVER;PTR  NORMAL;PTR   OVER;PTR   PRESS;INT  MSGLOG" ))
Global $Kernel32dll  =  _WinAPI_LoadLibrary(  "Kernel32.dll"  )   ,  $StructBHoverPtr = DllStructGetPtr(  $StructBHover  )
Global $_GtPt=_WinAPI_GetProcAddress($User32Dll,"GetParent"),$_WnFPos=_WinAPI_GetProcAddress($User32Dll,"WindowFromPoint")
Global $SdMsg =_WinAPI_GetProcAddress($User32Dll,"SendMessageW"),$RiWin =_WinAPI_GetProcAddress($User32Dll,"RedrawWindow")
Global $G_CP =_WinAPI_GetProcAddress($User32Dll,"GetCursorPos"),$GKYState=_WinAPI_GetProcAddress($User32Dll,"GetKeyState")
Global $Sleep =_WinAPI_GetProcAddress($Kernel32dll,"Sleep") ,$PositionsSt = DllStructCreate("INT POS[2]") , $ThreadPtr = 0
Global $NewStructButtonHover= 0,$PositionsStPtr= DllStructGetPtr($PositionsSt),$IsPss = LIsPress(),$IsNPss = LIsNotPress()
Global $IsPssPtr = DllStructGetPtr($IsPss) , $IsNPssPtr = DllStructGetPtr($IsNPss),$MHover = LMHover(),$MNHover=LMNHover()
Global $MHoverPtr = DllStructGetPtr( $MHover ) ,  $MNHoverPtr = DllStructGetPtr( $MNHover )  ,  $ThreadAdd = LoadThread( )

Func CreateButtonHover($Text,$L,$T,$W,$H,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR = 0,$Font = True)

Local $tagButtonHover = "HWND HWNDA;HWND HWNDB;INT TPRESS;INT THOVER;PTR NORMAL;PTR OVER;PTR PRESS;INT MSGLOG"
Local $STM_SETIMAGE_HOVER = 0x0172 , $SS_BITMAP_HOVER = 0x0000000E _
 , $SS_REALSIZECONTROL_HOVER  =  0x00000040  ,  $STN_CLICKED  =  0

$controlID1 = GUICtrlCreateLabel("",$L,$T,$W,$H,BitOR($SS_REALSIZECONTROL_HOVER,$SS_BITMAP_HOVER))
if @error Then Return SetError(1,0,0)
GUICtrlSetBkColor(-1,$GUI_BKCOLOR_TRANSPARENT)
$hWndA = GUICtrlGetHandle($controlID1)

$controlID2 = GUICtrlCreateLabel($Text,$L,$T,$W,$H,BitOR($SS_CENTERIMAGE,$SS_CENTER))
if @error Then
GUICtrlDelete($controlID1)
Return SetError(2,0,0)
EndIf

$hWndB = GUICtrlGetHandle($controlID2)
$MSGLOG  = _WinAPI_MakeLong($controlID2,$STN_CLICKED)
GUICtrlSetBkColor (  -1 ,   $GUI_BKCOLOR_TRANSPARENT)
if ($TEXTCOLOOR) Then GUICtrlSetColor(-1,$TEXTCOLOOR)
if ($Font) Then GUICtrlSetFont(-1,(($H) / 2) - 1,600,0,"Arial")


if Not(DllStructGetData($StructBHover,"COUNT")) Then

$StructButtonHover = DllStructCreate($tagButtonHover)

DllStructSetData($StructButtonHover,"NORMAL",$NORMAL_hBMP)
DllStructSetData($StructButtonHover , "OVER" , $OVER_hBMP)
DllStructSetData($StructButtonHover ,"PRESS", $PRESS_hBMP)
DllStructSetData($StructButtonHover  , "HWNDA"  ,  $hWndA)
DllStructSetData($StructButtonHover  , "HWNDB"  ,  $hWndB)
DllStructSetData($StructButtonHover , "MSGLOG"  , $MSGLOG)

$ButtonHoverPtr  = DllStructGetPtr( $StructButtonHover )
DllStructSetData($StructBHover,"BHOVER",$ButtonHoverPtr)
DllStructSetData($StructBHover,"COUNT",1)

Else

ControlThread(1,True,True)

$COUNT = DllStructGetData($StructBHover,"COUNT")
$NewtagButtonHover = "BYTE [" & ($COUNT * $StructBHSize) & "];" & $tagButtonHover
$NewStructButtonHover = DllStructCreate($NewtagButtonHover)

$NewStructButtonHoverPtr    =    DllStructGetPtr(    $NewStructButtonHover   )
DllCall("kernel32.dll","none","RtlMoveMemory","ptr", $NewStructButtonHoverPtr, _
"ptr",DllStructGetPtr($StructButtonHover),"ulong_ptr",($COUNT * $StructBHSize))

DllStructSetData($NewStructButtonHover,"NORMAL",$NORMAL_hBMP)
DllStructSetData($NewStructButtonHover , "OVER" , $OVER_hBMP)
DllStructSetData($NewStructButtonHover ,"PRESS", $PRESS_hBMP)
DllStructSetData($NewStructButtonHover  , "HWNDA"  ,  $hWndA)
DllStructSetData($NewStructButtonHover  , "HWNDB"  ,  $hWndB)
DllStructSetData($NewStructButtonHover , "MSGLOG"  , $MSGLOG)

DllStructSetData($StructBHover,"BHOVER",$NewStructButtonHoverPtr)
DllStructSetData($StructBHover,"COUNT",$COUNT + 1)

$StructButtonHover = $NewStructButtonHover
$NewStructButtonHover = 0

ControlThread(1,False)

EndIf

_SendMessage($hWndA,$STM_SETIMAGE_HOVER,0,$NORMAL_hBMP)

if Not($ThreadPtr) Then
$ThreadPtr = DllStructGetPtr($ThreadAdd)
CreateThread($ThreadPtr,0)
EndIf

Return SetError (0,$controlID1,$controlID2)

EndFunc

Func LoadThread()

Local $IntSize = DllStructGetSize(DllStructCreate("INT")) ,$JZEnd , $JZTA ,$CThread
Local $OffSelpParameter = $PointerSize,$LOOPA,$End,$TA,$OffSetHwndA = 0,$TB,$JMPEND
Local $JZEnd , $JMPTB , $LOOPB , $AsmVarPtr = DllStructGetPtr($AsmVar) , $JZCThread

For $i = 1 To 2

$_ASMCode =  "0x"

$LOOPA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(3) ;mov eax,3 // 3 Milliseconds
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($Sleep) ;mov eax,$Sleep
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "BF" & HexBinary($AsmVarPtr) ;mov edi,$AsmVarPtr
$_ASMCode &= "BB" & HexBinary($StructBHoverPtr) ;mov ebx,$StructBHoverPtr
$_ASMCode &= "8B13" ;mov edx,[ebx]
$_ASMCode &= "8917" ;mov [edi],edx
$_ASMCode &= "8B5B" & Hex($IntSize,2) ;mov ebx,[ebx + $IntSize]
$_ASMCode &= "895F" & Hex($IntSize,2) ;mov [edi + $IntSize],ebx

$_ASMCode &= "B8" & HexBinary($PositionsStPtr) ;mov eax,$PositionsStPtr
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($G_CP) ;mov eax,GetCursorPos
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary($PositionsStPtr) ;mov eax,$PositionsStPtr
$_ASMCode &= "FF70" & Hex($IntSize,2) ;push [eax + $IntSize]
$_ASMCode &= "FF30" ;push [eax]
$_ASMCode &= "B8" & HexBinary($_WnFPos) ;mov eax,WindowFromPoint
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "8947" & Hex(($IntSize + $PointerSize),2) ;mov [edi + ($IntSize + $PointerSize)],eax

$LOOPB = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8038" & Hex(0,2) ;CMP [eax],0
$_ASMCode &= "74" & Hex(($End - $JZEnd),2) ;JZ $End;
$JZEnd = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "8B3B" ;mov edi,[ebx] ; // Get HWNDA
$_ASMCode &= "8B40" & Hex(($IntSize + $PointerSize),2) ;mov eax,[eax + ($IntSize + $PointerSize)] // Get CurrentHwnd

$_ASMCode &= "3BF8" ;CMP edi,eax
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "B8" & HexBinary($MNHoverPtr) ;mov eax,$MNHoverPtr
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "EB" & Hex(($TB - $JMPTB),2) ;JMP $TB
$JMPTB = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "53" ;push ebx
$_ASMCode &= "B8" & HexBinary($MHoverPtr) ;mov eax,$MHoverPtr
$_ASMCode &= "FFD0" ;call eax

$TB = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary($AsmVarPtr) ;mov eax,$AsmVarPtr
$_ASMCode &= "8028" & Hex(1,2) ;sub [eax],1
$_ASMCode &= "8B58" & Hex($IntSize,2) ;mov ebx,[eax + $IntSize]
$_ASMCode &= "83C3" & Hex($StructBHSize,2) ;add ebx,$StructBHSize
$_ASMCode &= "8958" & Hex($IntSize,2) ;mov [eax + $IntSize],ebx

$JMPLOOPB = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPLOOPB - $LOOPB) + 5)) ;JMP $LOOPB

$End = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(DllStructGetPtr($ControlThread)) ;mov eax,$ControlThread
$_ASMCode &= "8038" & Hex(1,2) ;CMP [eax],1
$_ASMCode &= "74" & Hex(($CThread - $JZCThread),2) ;JZ $CThread
$JZCThread = BinaryLen($_ASMCode)

$JMPLOOPA = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPLOOPA - $LOOPA) + 5)) ;JMP LOOPA

$CThread = BinaryLen($_ASMCode)

$_ASMCode &= "C640" & Hex($IntSize,2) & Hex(1,2) ;mov [eax + $IntSize],1

$_ASMCode &= "B8" & HexBinary(3) ;mov eax,3 // 3 Milliseconds
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($Sleep) ;mov eax,$Sleep
$_ASMCode &= "FFD0" ;call eax

$JMPEND = BinaryLen($_ASMCode)
$_ASMCode &= "E9" & HexBinary(-(($JMPEND - $End) + 5)) ;JMP End

$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LMHover() ;Mouse Hover

Local $OffSetTpress = DllStructGetSize( DllStructCreate( "HWND  HWNDA;HWND  HWNDB" ))
Local $TA    ,  $JZTA  ,  $TB  ,  $JMPTB  ,   $OffSetStructBHoverPtr  =  $PointerSize

For $i = 1 To 2

$_ASMCode =  "0x"
$_ASMCode &= "B8" & HexBinary(0x01) ;mov eax,$VK_LBUTTON
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($GKYState) ;mov eax,GetKeyState
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "25" & HexBinary(0x8000) ; and eax,0x8000 // bitwise AND // eax = BitAND(eax,0x8000)
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "FF7424" & Hex($OffSetStructBHoverPtr,2) ;push [esp + $OffSetStructBHoverPtr]
$_ASMCode &= "B8" & HexBinary($IsPssPtr) ;mov eax,$IsPssPtr
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "EB" & Hex(($TB - $JMPTB),2) ;JMP $JMPTD
$JMPTB = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)
$_ASMCode &= "FF7424" & Hex($OffSetStructBHoverPtr,2) ;push [esp + $OffSetStructBHoverPtr]
$_ASMCode &= "B8" & HexBinary($IsNPssPtr) ;mov eax,$IsNPssPtr
$_ASMCode &= "FFD0" ;call eax

$TB = BinaryLen($_ASMCode)
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //--------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LIsPress()

Local $OffSetPBmp = DllStructGetSize(DllStructCreate( "HWND  HWNDA;HWND  HWNDB;INT TPRESS;INT THOVER;PTR NORMAL;PTR OVER"))
Local $OffSetTpress = DllStructGetSize( DllStructCreate("HWND HWNDA;HWND HWNDB" ))  , $OffSetStructBHoverPtr = $PointerSize
Local $STM_SETIMAGE_HOVER = 0x0172 , $OffSetThover = DllStructGetSize( DllStructCreate( "HWND HWNDA;HWND HWNDB;INT TPRESS"))
Local $OffSetHwndA=0,$OffSetHBmp=DllStructGetSize(DllStructCreate("HWND HWNDA;HWND HWNDB;INT TPRESS;INT THOVER;PTR NORMAL"))
Local $TA , $JZTA , $TB , $JZTB , $JMPTC1 , $TC , $JMPTC2 ,$TC,$OffSetHwndB = DllStructGetSize(DllStructCreate("HWND HWNDA"))

For $i = 1 To 2

$_ASMCode =  "0x"

$_ASMCode &= "8B5C24" & Hex($OffSetStructBHoverPtr,2) ;mov ebx,[esp + $OffSetStructBHoverPtr]
$_ASMCode &= "8B43" & Hex($OffSetTpress,2) ;mov eax,[ebx + $OffSetTpress]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetThover,2) ;mov eax,[ebx + $OffSetThover]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TB - $JZTB),2) ;JZ $JZTB;
$JZTB = BinaryLen($_ASMCode)

$_ASMCode &= "EB" & Hex(($TC - $JMPTC1),2) ;JMP $JMPTC1
$JMPTC1 = BinaryLen($_ASMCode)

$TB = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffSetHBmp,2) ;mov eax,[ebx + $OffSetHBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(1,2) ;mov [ebx + $OffSetThover],1
$_ASMCode &= "EB" & Hex(($TC - $JMPTC2),2) ;JMP $JMPTC2
$JMPTC2 = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetPBmp,2) ;mov eax,[ebx + $OffSetPBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(1,2) ;mov [ebx + $OffSetTpress],1

$TC = BinaryLen($_ASMCode)
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LIsNotPress()

Local $OffSetPBmp = DllStructGetSize(DllStructCreate( "HWND  HWNDA;HWND  HWNDB;INT  TPRESS;INT THOVER;PTR  NORMAL;PTR OVER"))
Local $OffSetTpress = DllStructGetSize( DllStructCreate("HWND HWNDA;HWND HWNDB" ) )  ,  $OffSetStructBHoverPtr = $PointerSize
Local $STM_SETIMAGE_HOVER=0x0172,$OffSetThover=DllStructGetSize(DllStructCreate("HWND HWNDA;HWND HWNDB;INT TPRESS")),$SSenMsg
Local $OffSetHwndB=DllStructGetSize(DllStructCreate("HWND HWNDA")),$OffSetHBmp =DllStructGetSize(DllStructCreate("HWND HWNDA" & _
";HWND HWNDB;INT TPRESS;INT THOVER;PTR NORMAL")),$OffsetMsgLog = DllStructGetSize(DllStructCreate("HWND HWNDA;HWND HWNDB;INT" & _
" TPRESS;INT THOVER;PTR NORMAL;PTR OVER;PTR PRESS")),$OffSetHwndA = 0 ,$TA,$JZTA,$JMPTB,$TB,$JZTC,$TC,$TD,$JZTD,$JZStopSendMsg
Local $IntSize = DllStructGetSize(DllStructCreate("INT"))

For $i = 1 To 2

$_ASMCode =  "0x"
$_ASMCode &= "8B5C24" & Hex($OffSetStructBHoverPtr,2) ;mov ebx,[esp + $OffSetStructBHoverPtr]
$_ASMCode &= "8B43" & Hex($OffSetTpress,2) ;mov eax,[ebx + $OffSetTpress]
$_ASMCode &= "83F8" & Hex(1,2) ;CMP eax,1
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "EB" & Hex(($TB - $JMPTB),2) ;JMP $JMPTB
$JMPTB = BinaryLen($_ASMCode)

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(DllStructGetPtr($ControlThread)) ;mov eax,$ControlThread
$_ASMCode &= "8078" & Hex(($IntSize * 2),2) & Hex(1,2) ;CMP [eax + ($IntSize * 2)],1
$_ASMCode &= "74" & Hex(($SSenMsg - $JZStopSendMsg),2) ;JZ $StopSendMsg
$JZStopSendMsg = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($_GtPt) ;mov eax,GetParent
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "8BF8" ;mov edi,eax

$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffsetMsgLog,2) ;mov eax,[ebx + $OffsetMsgLog]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($WM_COMMAND) ;mov eax,$WM_COMMAND
$_ASMCode &= "50" ;push eax
$_ASMCode &= "57" ;push edi
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$SSenMsg = BinaryLen($_ASMCode) ; StopSendMsg
$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(0,2) ;mov [ebx + $OffSetThover],0
$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(0,2) ;mov [ebx + $OffSetTpress],0

$TB = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffSetThover,2) ;mov eax,[ebx + $OffSetThover]
$_ASMCode &= "83F8" & Hex(1,2) ;CMP eax,1
$_ASMCode &= "74" & Hex(($TC - $JZTC),2) ;JZ $JZTC;
$JZTC = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(1,2) ;mov [ebx + $OffSetThover],1
$_ASMCode &= "8B43" & Hex($OffSetHBmp,2) ;mov eax,[ebx + $OffSetHBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax

$TC = BinaryLen($_ASMCode)
$_ASMCode &= "8B43" & Hex($OffSetTpress,2) ;mov eax,[ebx + $OffSetTpress]
$_ASMCode &= "83F8" & Hex(3,2) ;CMP eax,3
$_ASMCode &= "74" & Hex(($TD - $JZTD),2) ;JZ $JZTD;
$JZTD = BinaryLen($_ASMCode)

;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

$TD = BinaryLen($_ASMCode)
$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(0,2) ;mov [ebx + $OffSetTpress],0
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func LMNHover() ;Mouse Not Hover

Local $OffSetNBmp  =  DllStructGetSize(  DllStructCreate(  "HWND  HWNDA;HWND  HWNDB;INT  TPRESS;INT  THOVER" ))
Local $OffSetThover = DllStructGetSize( DllStructCreate("HWND HWNDA;HWND HWNDB;INT TPRESS")) , $OffSetHwndA = 0
Local $OffSetTpress = DllStructGetSize(DllStructCreate("HWND HWNDA;HWND HWNDB")) , $STM_SETIMAGE_HOVER = 0x0172
Local $OffSetStructBHoverPtr   =   $PointerSize    ,   $TA    ,  $JZTA    ,   $TB    ,   $JZTB  , $TC  , $JMPTC
Local $OffSetHwndB = DllStructGetSize(DllStructCreate("HWND  HWNDA"))

For $i = 1 To 2

$_ASMCode =  "0x"

$_ASMCode &= "8B5C24" & Hex($OffSetStructBHoverPtr,2) ;mov ebx,[esp + $OffSetStructBHoverPtr]
$_ASMCode &= "8B43" & Hex($OffSetThover,2) ;mov eax,[ebx + $OffSetThover]
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TA - $JZTA),2) ;JZ $JZTA;
$JZTA = BinaryLen($_ASMCode)

$_ASMCode &= "8B43" & Hex($OffSetNBmp,2) ;mov eax,[ebx + $OffSetNBmp]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($STM_SETIMAGE_HOVER) ;mov eax,$STM_SETIMAGE_HOVER
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndA,2) ;mov eax,[ebx + $OffSetHwndA]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($SdMsg) ;mov eax,SendMessageW
$_ASMCode &= "FFD0" ;call eax

$_ASMCode &= "B8" & HexBinary(BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)) ;mov eax,BitOR($RDW_INVALIDATE,$RDW_UPDATENOW)
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "50" ;push eax
$_ASMCode &= "8B43" & Hex($OffSetHwndB,2) ;mov eax,[ebx + $OffSetHwndB]
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($RiWin) ;mov eax,RedrawWindow
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "C643" & Hex($OffSetThover,2) & Hex(0,2) ;mov [ebx + $OffSetThover],0

$TA = BinaryLen($_ASMCode)

$_ASMCode &= "B8" & HexBinary(0x01) ;mov eax,$VK_LBUTTON
$_ASMCode &= "50" ;push eax
$_ASMCode &= "B8" & HexBinary($GKYState) ;mov eax,GetKeyState
$_ASMCode &= "FFD0" ;call eax
$_ASMCode &= "25" & HexBinary(0x8000) ; and eax,0x8000 // bitwise AND // eax = BitAND(eax,0x8000)
$_ASMCode &= "83F8" & Hex(0,2) ;CMP eax,0
$_ASMCode &= "74" & Hex(($TB - $JZTB),2) ;JZ $JZTB;
$JZTB = BinaryLen($_ASMCode)

$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(3,2) ;mov [ebx + $OffSetTpress],3
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

$TB = BinaryLen($_ASMCode)
$_ASMCode &= "C643" & Hex($OffSetTpress,2) & Hex(0,2) ;mov [ebx + $OffSetTpress],0
;------------------------------// Return 0 //-----------------------------------------------------------
$_ASMCode &= "B8" & HexBinary(0) ;mov eax,0
$_ASMCode &= "C2" & Hex($PointerSize,2) & Hex(0,2) ;ret ($PointerSize) & "00" // Args Size
;------------------------------// Return 0 //-----------------------------------------------------------

Next

$Address = DllStructCreate("byte[" & BinaryLen($_ASMCode) & "]")
DllStructSetData($Address,1,$_ASMCode)
Return $Address

EndFunc

Func ControlThread($Flag = 1,$BOOL = True , $Wait = False)

; $Flag = 1 Continue Thread Loop // $BOOL = True Or $BOOL = False
; $Flag = 2 Stop Msg Send // // $BOOL = True Or $BOOL = False
; $Wait True Or False Wait Start Continue Of Thread Loop

Switch $Flag
Case 1
DllStructSetData($ControlThread, "TA" , 0 )
DllStructSetData($ControlThread, "TB" , 0 )
if ($BOOL) Then
DllStructSetData($ControlThread, "TA" , 1 )
if ($Wait) Then
While DllStructGetData($ControlThread,"TB") == 0
WEnd
Return True
Else
Return True
EndIf
Else
DllStructSetData($ControlThread, "TA" , 0 )
DllStructSetData($ControlThread, "TB" , 0 )
Return True
EndIf
Case 2
if ($BOOL) Then
DllStructSetData($ControlThread, "TC" , 1 )
Else
DllStructSetData($ControlThread, "TC" , 0 )
EndIf
Return True
Case Else
Return False
EndSwitch

EndFunc

Func HexBinary($Value)
Return Hex(Binary($Value))
EndFunc

Func CreateThread($lpStartAddress,$lpParameter)
Local $HANDLE = DllCall("Kernel32.dll","ptr","CreateThread","ptr",0,"int",0,"ptr", _
$lpStartAddress,"ptr",$lpParameter,"DWORD",0,"DWORD*",0)
if @error Or $HANDLE[0] = 0 Then Return SetError(1,0,0)
Return SetError(0,0,$HANDLE[0])
EndFunc

Func LoadBitmap_FromFile($sFileName)
Return _WinAPI_LoadImage(_WinAPI_GetModuleHandle(0),$sFileName,0 ,0,0,0x0010)
EndFunc

Func LoadBitmap_FromResources($resource_Name)
Return _WinAPI_LoadBitmap(_WinAPI_GetModuleHandle(0), $resource_Name)
EndFunc

 

ButtonHover_Example1.au3

#include <ASM_ButtonHover.au3>


$NORMAL_hBMP = LoadBitmap_FromFile("NORMAL1.bmp")
$PRESS_hBMP = LoadBitmap_FromFile("PRESS1.bmp")
$OVER_hBMP = LoadBitmap_FromFile("OVER1.bmp")
$TEXTCOLOOR = 0xFFFFFF

$GUI = GUICreate("ASM_ButtonHover")
$Button_SM = CreateButtonHover ("Small", 180, 80, 70, 15,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 8, 800, 0,  "Arial")
$Button_ME = CreateButtonHover ("Medium", 180, 120, 90, 30,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 12, 800, 0,  "Arial")
$Button_LO = CreateButtonHover ("Long", 180, 180, 190, 30,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 16, 800, 0,  "Arial")
$Button_LA = CreateButtonHover ("Large", 180, 240, 190, 60, $NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 20, 800, 0,  "Arial")
GUISetState(@SW_SHOW)

While 1
$MSG = GUIGetMsg()
StopSendMsg(True)
Switch $MSG
Case $GUI_EVENT_CLOSE
Exit
Case $Button_SM
MsgBox(0,"MSG","Small Button")
Case $Button_ME
MsgBox(0,"MSG","Medium Button")
Case $Button_LO
MsgBox(0,"MSG","Long Button")
Case $Button_LA
MsgBox(0,"MSG","Large Button")
EndSwitch
StopSendMsg(False)
WEnd

Func StopSendMsg($BOOL)
ControlThread(2,$BOOL)
EndFunc
 

 

ButtonHover_Example2.au3

#include <ASM_ButtonHover.au3>


$NORMAL_hBMP = LoadBitmap_FromFile("NORMAL1.bmp")
$PRESS_hBMP = LoadBitmap_FromFile("PRESS1.bmp")
$OVER_hBMP = LoadBitmap_FromFile("OVER1.bmp")
$TEXTCOLOOR = 0xFFFFFF

$GUI = GUICreate("ASM_ButtonHover")
$Button_SM = CreateButtonHover ("Small", 180, 80, 70, 15,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 8, 800, 0,  "Arial")
$Button_ME = CreateButtonHover ("Medium", 180, 120, 90, 30,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 12, 800, 0,  "Arial")
$Button_LO = CreateButtonHover ("Long", 180, 180, 190, 30,$NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 16, 800, 0,  "Arial")
$Button_LA = CreateButtonHover ("Large", 180, 240, 190, 60, $NORMAL_hBMP,$PRESS_hBMP,$OVER_hBMP,$TEXTCOLOOR)
GUICtrlSetFont(-1, 20, 800, 0,  "Arial")
GUISetState(@SW_SHOW)

While 1
$MSG = GUIGetMsg()
Switch $MSG
Case $GUI_EVENT_CLOSE
Exit
Case $Button_SM
MsgBox(0,"MSG","Small Button")
Case $Button_ME
MsgBox(0,"MSG","Medium Button")
Case $Button_LO
MsgBox(0,"MSG","Long Button")
Case $Button_LA
MsgBox(0,"MSG","Large Button")
EndSwitch
WEnd

صرح السماء كان هنا

 

Link to comment
Share on other sites

Pretty handy!

With example 2 Autoit3 would not close until I:

Case $GUI_EVENT_CLOSE
    StopSendMsg(True);========= copied this from above
    Exit

The GUI closed, just not Autoit3.

(not that I understand it)

AutoIt Version: V3.3.9.22 [X32]

Windows Version: WIN_XP [English]

Language: 0409

 

 

Click the Large button after the message box appears, do not close it and click the Large button again

, close the message box , do so on the Example 1 and Example 2 You will know the work of StopSendMsg

function.

When you make this process a normal button, will send two message.

Thank you :bye:

Edited by wolf9228

صرح السماء كان هنا

 

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