zhuang513 发表于 2009-5-17 18:02:24

鼠标获取鼠标点击 帮帮忙

本帖最后由 zhuang513 于 2009-5-21 13:58 编辑


想了很久没看出毛病 谢谢我想单击即运行..#include <resources.au3>
#include <GUIConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Opt("TrayMenuMode", 1) ;没有默认的(暂停脚本和退出)菜单.

HotKeySet("{ESC}", "_exit") ;ESC键退出

_GDIPlus_Startup ()

Global $Image_BK = _GDIPlus_BitmapCreateFromFile("bj.png")
Global $Image_Exit_Out = _GDIPlus_BitmapCreateFromFile("ExitOut.png")
Global $Image_Exit_Over = _GDIPlus_BitmapCreateFromFile("ExitOver.png")
Global $Image_Exit_Down = _GDIPlus_BitmapCreateFromFile("ExitDown.png")
Global $Win_Width = _GDIPlus_ImageGetWidth($Image_BK)
Global $Win_Height = _GDIPlus_ImageGetHeight($Image_BK)
Global $MainGUI
Global $ImageState
$ImageState = 1

_CreateTransparentGUI()
_SetTotalBitmap()

Dim $LastCtrlID,$ThisCtrlID
While 1
        $MousePos = GUIGetCursorInfo($MainGUI)
        $WinPos = WinGetPos($MainGUI)

        If BitAND($MousePos<=117,$MousePos>=17,$MousePos<=118,$MousePos>=18) Then
                $ThisCtrlID = 1
        Else
                $ThisCtrlID = 0
        EndIf
       
        If $LastCtrlID <> $ThisCtrlID Then
                Switch $ThisCtrlID
                        Case 1
                                $ImageState = 2
                        Case 0
                                $ImageState = 1
                EndSwitch
                _SetTotalBitmap()
                $LastCtrlID = $ThisCtrlID
        EndIf
       
        If $MousePos And $ThisCtrlID = 1 Then
                $ImageState = 3
                _SetTotalBitmap()
                While $MousePos
                        $MousePos = GUIGetCursorInfo($MainGUI)
                WEnd
                If BitAND($MousePos<=117,$MousePos>=17,$MousePos<=118,$MousePos>=18) Then
                        $ThisCtrlID = 1
                        _exit()
                Else
                        $ThisCtrlID = 0
                        $ImageState = 1
                        _SetTotalBitmap()
                EndIf
        EndIf

        Sleep(50)
WEnd


Func _SetTotalBitmap()
        Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend, $hBitmap
        $hScrDC= _WinAPI_GetDC(0)
        $hMemDC= _WinAPI_CreateCompatibleDC($hScrDC)
       
        Local $Image_Temp,$hGraphic
        $Image_Temp = _GDIPlus_BitmapCloneArea($Image_BK,0,0,$Win_Width,$Win_Height,$GDIP_PXF32ARGB)
        $hGraphic = _GDIPlus_ImageGetGraphicsContext ($Image_Temp)

        Switch $ImageState
                Case 1
                        _GDIPLus_GraphicsDrawImageRect($hGraphic, $Image_Exit_Out, 17, 18, 100, 100)
                Case 2
                        _GDIPLus_GraphicsDrawImageRect($hGraphic, $Image_Exit_Over, 17, 18, 100, 100)
                Case 3
                        _GDIPLus_GraphicsDrawImageRect($hGraphic, $Image_Exit_Down, 17, 18, 100, 100)
        EndSwitch

        _GDIPlus_GraphicsDispose ($hGraphic)
        $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($Image_Temp)
        $hOld= _WinAPI_SelectObject($hMemDC, $hBitmap)
        $tSize = DllStructCreate($tagSIZE)
        $pSize = DllStructGetPtr($tSize)
        DllStructSetData($tSize, "X", $Win_Width)
        DllStructSetData($tSize, "Y", $Win_Height)
        $tSource = DllStructCreate($tagPOINT)
        $pSource = DllStructGetPtr($tSource)
        $tBlend= DllStructCreate($tagBLENDFUNCTION)
        $pBlend= DllStructGetPtr($tBlend)
        DllStructSetData($tBlend, "Alpha" , 255)
        DllStructSetData($tBlend, "Format", 1)
        _WinAPI_UpdateLayeredWindow($MainGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
        _WinAPI_ReleaseDC (0, $hScrDC)
        _WinAPI_SelectObject($hMemDC, $hOld)
        _WinAPI_DeleteObject($hBitmap)
        _WinAPI_DeleteDC($hMemDC)
        _GDIPlus_ImageDispose ($Image_Temp)
        _WinAPI_DeleteObject ($Image_Temp)
       
EndFunc


Func _CreateTransparentGUI()
        $MainGUI = GUICreate("", $Win_Width, $Win_Height,-1,-1, $WS_POPUP, $WS_EX_LAYERED)
        GUISetState()
    GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
EndFunc

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $MainGUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc

func _exit()
        _GDIPlus_ShutDown ()
    Exit
EndFunc

bing614 发表于 2009-5-17 18:15:54

resources.au3

zhuang513 发表于 2009-5-17 18:25:15

什么意思??
能说清楚点吗?

zhuang513 发表于 2009-5-17 21:26:26

希望牛人能帮忙.!!!!

zhuang513 发表于 2009-5-17 23:32:45

继续等高人出现..

zhuang513 发表于 2009-5-18 15:38:23

继续等高人出现..

zhuang513 发表于 2009-5-18 19:13:30

继续等高人出现..

zhuang513 发表于 2009-5-18 23:39:14

坚持住!!!!!!

sxd 发表于 2009-5-19 01:40:31

resources.au3
bing614 发表于 2009-5-17 18:15 http://www.autoitx.com/images/common/back.gif
看看人家回帖再顶嘛

zhuang513 发表于 2009-5-19 01:44:01

是这个出问题了???

zhuang513 发表于 2009-5-19 01:50:16

能不能说明白点啊..

sxd 发表于 2009-5-19 01:54:22

问题是你没提供 这个文件 叫别人怎么测试...

zhuang513 发表于 2009-5-19 02:03:46



不好意思..麻烦给看看...

zhuang513 发表于 2009-5-19 16:47:23

{:3_89:}{:3_88:}

sxd 发表于 2009-5-20 02:39:39


Func _CreateTransparentGUI()
        $MainGUI = GUICreate("", $Win_Width, $Win_Height,-1,-1, $WS_POPUP, $WS_EX_LAYERED)
        GUISetState()
    GUIRegisterMsg($WM_NCLBUTTONDOWN, "WM_NCLBUTTONDOWN")
EndFunc

Func WM_NCLBUTTONDOWN($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $MainGUI) And ($iMsg = $WM_NCLBUTTONDOWN) Then Return $HTCAPTION
EndFunc
页: [1] 2
查看完整版本: 鼠标获取鼠标点击 帮帮忙