本帖最后由 wsfda 于 2011-6-11 17:14 编辑
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
Opt("GUIOnEventMode", 1) ; 开启 Event 模式
Global $H_info = 5,$Tab,$T[20] ;$H_Iinfo = 说明的高度 ,...,...$Tab = 分页标签的数量
Global $b_DB = TimerInit();双击事件
$Tab = IniReadSectionNames("menu.ini")
$F = GUICreate("",550,90,200,210)
GUISetOnEvent($GUI_EVENT_CLOSE, "main")
$TB = GUICtrlCreateTab(0, 0, 565, 90)
GUICtrlSetState(-1, 8)
For $I = 1 To $Tab[0]
$T[$I] = GUICtrlCreateTabItem($Tab[$I]);根据配置文件内的字段数量创建相应数量的分页标签
$Command = IniReadSection("menu.ini", $Tab[$I])
For $L = 1 To $Command[0][0]
$Command[$L][0] = GUICtrlCreateButton($Command[$L][0], $H_info + ($L - 1) * 70, 25, 65, 60)
_GUICtrlButton_SetImageList(-1, _GetImageListHandle($Command[$L][1], 0, True), 2, -1, 5)
GUICtrlSetCursor(-1, 0) ;鼠标样式
GUICtrlSetOnEvent($Command[$L][0], "Command")
Next
Next
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
While 1
If GUIGetMsg() <> -3 Then _WinHide($F);自动隐藏
$hw = _WinAPI_GetForegroundWindow();置顶 Start
If $hw <> $F Then
_WinAPI_SetWindowPos($hw, -2, 0, 0, 0, 0, 3)
EndIf
_WinAPI_SetWindowPos($F, -1, 0, 0, 0, 0, 3);置顶 End
GetPos()
Sleep(15)
WEnd
Func Command()
For $L = 1 To UBound($Command, 1) - 1
If @GUI_CtrlId = $Command[$L][0] Then ShellExecute($Command[$L][1])
Next
EndFunc
Func _WinHide($Hwnd)
$Wp = WinGetPos($F)
$Mp = MouseGetPos()
Select
Case $Wp[1] <= 3
If ($Mp[0] < $Wp[0] Or $Mp[0] > $Wp[0] + $Wp[2] Or $Mp[1] > $Wp[1] + $Wp[3]) Then
WinMove($Hwnd, "", $Wp[0], 3 - $Wp[3], $Wp[2], $Wp[3], 1)
Else
WinMove($Hwnd, "", $Wp[0], 3, $Wp[2], $Wp[3], 1)
EndIf
Case $Wp[0] >= (@DesktopWidth - $Wp[2] + 3)
If ($Mp[0] < $Wp[0] Or $Mp[1] < $Wp[1] Or $Mp[1] > $Wp[1] + $Wp[3]) Then
WinMove($Hwnd, "", @DesktopWidth - 3, $Wp[1], $Wp[2], $Wp[3], 1)
Else
WinMove($Hwnd, "", @DesktopWidth - $Wp[2] + 3, $Wp[1], $Wp[2], $Wp[3], 1)
EndIf
EndSelect
EndFunc
Func main()
Switch @GUI_CtrlId ; 根据宏 @GUI_CtrlId 来判断消息
Case $GUI_EVENT_CLOSE
;For $I = 1 To $Tab[0]
;If GUICtrlRead ($Tb) = 0 Then
;MsgBox(0,"",$Tab[1])
;ExitLoop
;ElseIf GUICtrlRead ($Tb) = $I Then
;MsgBox(0,"",$Tab[$I+1])
;EndIf
;Next
Exit
EndSwitch
EndFunc ;==>main
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False);添加图标
Local $iSize = 16
If $fLarge Then $iSize = 32
Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
_GUIImageList_AddBitmap($hImage, $sFile)
Else
_GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
EndIf
Return $hImage
EndFunc ;==>_GetImageListHandle
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <GuiButton.au3>
#include <GuiImageList.au3>
Opt("GUIOnEventMode", 1) ; 开启 Event 模式
Global $H_info = 5,$Tab,$T[20] ;$H_Iinfo = 说明的高度 ,...,...$Tab = 分页标签的数量
Global $b_DB = TimerInit();双击事件
$Tab = IniReadSectionNames("menu.ini")
$F = GUICreate("",550,90,200,210)
GUISetOnEvent($GUI_EVENT_CLOSE, "main")
$TB = GUICtrlCreateTab(0, 0, 565, 90)
GUICtrlSetState(-1, 8)
For $I = 1 To $Tab[0]
$T[$I] = GUICtrlCreateTabItem($Tab[$I]);根据配置文件内的字段数量创建相应数量的分页标签
$Command = IniReadSection("menu.ini", $Tab[$I])
For $L = 1 To $Command[0][0]
$Command[$L][0] = GUICtrlCreateButton($Command[$L][0], $H_info + ($L - 1) * 70, 25, 65, 60)
_GUICtrlButton_SetImageList(-1, _GetImageListHandle($Command[$L][1], 0, True), 2, -1, 5)
GUICtrlSetCursor(-1, 0) ;鼠标样式
GUICtrlSetOnEvent($Command[$L][0], "Command")
Next
Next
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
While 1
If GUIGetMsg() <> -3 Then _WinHide($F);自动隐藏
$hw = _WinAPI_GetForegroundWindow();置顶 Start
If $hw <> $F Then
_WinAPI_SetWindowPos($hw, -2, 0, 0, 0, 0, 3)
EndIf
_WinAPI_SetWindowPos($F, -1, 0, 0, 0, 0, 3);置顶 End
GetPos()
Sleep(15)
WEnd
Func Command()
For $L = 1 To UBound($Command, 1) - 1
If @GUI_CtrlId = $Command[$L][0] Then ShellExecute($Command[$L][1])
Next
EndFunc
Func _WinHide($Hwnd)
$Wp = WinGetPos($F)
$Mp = MouseGetPos()
Select
Case $Wp[1] <= 3
If ($Mp[0] < $Wp[0] Or $Mp[0] > $Wp[0] + $Wp[2] Or $Mp[1] > $Wp[1] + $Wp[3]) Then
WinMove($Hwnd, "", $Wp[0], 3 - $Wp[3], $Wp[2], $Wp[3], 1)
Else
WinMove($Hwnd, "", $Wp[0], 3, $Wp[2], $Wp[3], 1)
EndIf
Case $Wp[0] >= (@DesktopWidth - $Wp[2] + 3)
If ($Mp[0] < $Wp[0] Or $Mp[1] < $Wp[1] Or $Mp[1] > $Wp[1] + $Wp[3]) Then
WinMove($Hwnd, "", @DesktopWidth - 3, $Wp[1], $Wp[2], $Wp[3], 1)
Else
WinMove($Hwnd, "", @DesktopWidth - $Wp[2] + 3, $Wp[1], $Wp[2], $Wp[3], 1)
EndIf
EndSelect
EndFunc
Func main()
Switch @GUI_CtrlId ; 根据宏 @GUI_CtrlId 来判断消息
Case $GUI_EVENT_CLOSE
;For $I = 1 To $Tab[0]
;If GUICtrlRead ($Tb) = 0 Then
;MsgBox(0,"",$Tab[1])
;ExitLoop
;ElseIf GUICtrlRead ($Tb) = $I Then
;MsgBox(0,"",$Tab[$I+1])
;EndIf
;Next
Exit
EndSwitch
EndFunc ;==>main
Func _GetImageListHandle($sFile, $nIconID = 0, $fLarge = False);添加图标
Local $iSize = 16
If $fLarge Then $iSize = 32
Local $hImage = _GUIImageList_Create($iSize, $iSize, 5, 3)
If StringUpper(StringMid($sFile, StringLen($sFile) - 2)) = "BMP" Then
_GUIImageList_AddBitmap($hImage, $sFile)
Else
_GUIImageList_AddIcon($hImage, $sFile, $nIconID, $fLarge)
EndIf
Return $hImage
EndFunc ;==>_GetImageListHandle
代码如上:
如何做到点击按钮,执行指定程序
谢谢各位大哥帮忙
配置文件如下:
[默认分类]
随机音乐=D:\深蓝随机音乐台.exe
[编程应用]
key=C:\Users\make\Desktop\key.exe
[办公应用]
QQ=C:\Program Files\Tencent\QQ\Bin\QQ.exe
[command]
Mozilla Firefox=C:\Program Files\mozilla firefox\firefox.exe |