鼠标获取鼠标点击 帮帮忙
本帖最后由 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
resources.au3 什么意思??
能说清楚点吗? 希望牛人能帮忙.!!!! 继续等高人出现.. 继续等高人出现.. 继续等高人出现.. 坚持住!!!!!! resources.au3
bing614 发表于 2009-5-17 18:15 http://www.autoitx.com/images/common/back.gif
看看人家回帖再顶嘛 是这个出问题了??? 能不能说明白点啊.. 问题是你没提供 这个文件 叫别人怎么测试...
不好意思..麻烦给看看... {:3_89:}{:3_88:}
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