#NoEnv
; #Warn
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
OnMessage(0x404, "AHK_NOTIFYICON")
Gosub OpenSetting
Menu,Tray,Tip,单击或双击托盘图标打开设置窗口
Return
OpenSetting:
Gui,RGui:Destroy
Gui,RGui:Default
Gui,RGui:+Resize
SysGet, CXVSCROLL, 2
LVWidth:=LVWidth?LVWidth:350,LVHeight:=LVHeight?LVHeight:150 ;设定listview尺寸
,CGuiHeight:=0,CGuiWidth:=0 ;初始化
Gui,RGui:Add, ListView,w%LVWidth% h%LVHeight% AltSubmit Grid +E0x10 -LV0x10 -Multi NoSortHdr -WantF2 0x8 LV0x40 LV0x800 LV0x80 gControl_Gui vSetHLV HWNDHLV, 编号|内容
LV_ModifyCol(1,LVWidth*0.25),LV_ModifyCol(2,LVWidth*0.75-CXVSCROLL*(A_ScreenDPI/96) " Center"),Count:=1
Loop,15
LV_Add("",A_Index,Count++ "-1")
Gui,RGui:Show,AutoSize,可拉伸ListView示例
return
RGuiGuiSize:
if A_Cursor In SizeNESW,SizeNS,SizeNWSE,SizeWE
{
GuiControlGet,CGSize,RGui:Pos,SetHLV
if (!CGuiHeight&&!CGuiWidth&&CGSizeW=LVWidth) {
Gui, RGui:+MinSize%A_GuiWidth%x%A_GuiHeight%
}else{
GuiControlGet,CGSize,RGui:Pos,SetHLV
GuiControl,RGui:Move,SetHLV,% "w" CGSizeW+A_GuiWidth-CGuiWidth " h" CGSizeH+A_GuiHeight-CGuiHeight
LV_ModifyCol(1,(CGSizeW+A_GuiWidth-CGuiWidth)*0.25),LV_ModifyCol(2,(CGSizeW+A_GuiWidth-CGuiWidth)*0.75-CXVSCROLL*(A_ScreenDPI/96))
}
CGuiHeight:=A_GuiHeight,CGuiWidth:=A_GuiWidth,LVWidth:=CGSizeW,LVHeight:=CGSizeH
}
return
Control_Gui:
Gui,RGui:Submit,NoHide
Switch A_GuiControl
{
Case "SetHLV":
columNum:=LV_GetClickColumNum(HLV) ;获取点击列号
LV_GetText(value,A_EventInfo,columNum)
ToolTip,% value
SetTimer,KillToolTip,-800
}
Return
KillToolTip:
ToolTip
Return
RGuiGuiClose:
Gui,RGui:Destroy
Return
AHK_NOTIFYICON(wParam, lParam, uMsg, hWnd){
if (lParam = 0x201||lParam = 0x203) {
Gosub OpenSetting
}
}
LV_GetClickColumNum(HLV) {
Static LVM_SUBITEMHITTEST := 0x1039
VarSetCapacity(POINT, 8, 0)
DllCall("User32.dll\GetCursorPos", "Ptr", &POINT)
DllCall("User32.dll\ScreenToClient", "Ptr", HLV, "Ptr", &POINT)
VarSetCapacity(LVHITTESTINFO, 24, 0)
NumPut(NumGet(POINT, 0, "Int"), LVHITTESTINFO, 0, "Int")
NumPut(NumGet(POINT, 4, "Int"), LVHITTESTINFO, 4, "Int")
SendMessage, LVM_SUBITEMHITTEST, 0, &LVHITTESTINFO, , ahk_id %HLV%
If (ErrorLevel = -1)
Return False
Return NumGet(LVHITTESTINFO, 16, "Int") + 1
}
不错
谢谢大神分享,学习