GDI+ 图形库 创建一个带有悬浮图标的可交互 GUI,它允许用户通过拖拽文件到悬浮图标上来触发不同的操作,并展示动态的按钮交互。
所需依赖库下载:
文件管理器中拖放文件的拖放Gui.ahk
; 测试方法:拖拽文件到悬浮图标上。具体详见以下链接的需求说明
; https://www.autohotkey.com/boards/viewtopic.php?f=76&t=72575
;*************************************************************
#Include <Gdip> ;<------ Replace with your copy of GDIP
;*************************************************************
#SingleInstance,Force
SetBatchLines,-1
gdip_Startup()
lst := ["a","b","c","d"]
pos := [50,80,110,140]
Gui,1:+AlwaysOnTop +LastFound hwndGuiHwnd -DPIScale -Caption
Gui,1:Color,123456
WinSet,TransColor,123456
Gui,1:Margin,0,0
Gui,1:Add,Pic,x0 y0 w50 h50 0xE hwndMain gMoveChange
SetImage(Main,HB_BITMAP_MAKER("C"))
GuiControl,1:Move,% Main,w50 h50
Loop, 4 {
Gui,1:Add,Pic,x0 y+0 w30 h30 0xE hwndButt%A_Index%
SetImage(Butt%A_Index%,HB_BITMAP_MAKER(A_Index))
GuiControl,1:Move,% Butt%A_Index%,w30 h30
GuiControl,1:Hide,% Butt%A_Index%
Gui,1:Add,Pic,x+0 yp w30 h30 0xE hwndTButt%A_Index%
SetImage(TButt%A_Index%,HB_BITMAP_MAKER(lst[A_Index]))
GuiControl,1:Move,% TButt%A_Index%,w30 h30
GuiControl,1:Hide,% TButt%A_Index%
}
Handles := []
loop 4
Handles.Push(butt%A_Index%)
loop 4
Handles.Push(Tbutt%A_Index%)
Gui,1:Show,w100 h400, blah blah
SetTimer,Phase1,500
return
GuiClose:
GuiContextMenu:
*ESC::
ExitApp
MoveChange:
if(GetKeyState("Shift")){
MsgBox, This would be where you edit w/e you want
return
}
PostMessage,0xA1,2
return
Phase1:
MouseGetPos,,,,ctrl,2
if(GetKeyState("LButton")&&A_Cursor="Unknown"&&ctrl=Main){
loop 4
GuiControl,1:Show,% Handles[A_Index]
Lctrl := ""
SetTimer,Phase1,Off
SetTimer,Phase2,30
}
return
Phase2:
MouseGetPos,,,,ctrl,2
loop 4 {
if(ctrl=Butt%A_Index%&&ctrl!=Lctrl){
Lctrl := ctrl
npos := pos[A_Index]
SI := A_Index
Loop, 4 {
GuiControl,1:Show,% Handles[A_Index+4]
GuiControl,1:Move,% Handles[A_Index+4], % " y" npos
npos+=30
}
GuiControl,1:+Redraw,% Handles[8]
}
}
if(!GetKeyState("LButton")){
loop 8
GuiControl,1:Hide,% Handles[A_Index]
SetTimer,Phase1,On
SetTimer,Phase2,Off
}
return
GuiDropFiles:
MouseGetPos,,,,ctrl,2
Loop, 4
if(ctrl=Handles[A_Index+4]){
ToolTip,% "File / Folder :`n" A_GuiEvent "`n`nButton: " SI " - " lst[A_Index]
SetTimer,TTOff,-5000
return
}
ToolTip, Not a valid button
SetTimer,TTOff,-5000
return
TTOff:
ToolTip,
return
HB_BITMAP_MAKER(char){
;Bitmap Created Using: HB Bitmap Maker
pBitmap:=Gdip_CreateBitmap( 100 , 100 )
G := Gdip_GraphicsFromImage( pBitmap )
Gdip_SetSmoothingMode( G , 2 )
Brush := Gdip_BrushCreateSolid( "0xFF004D8D" )
Gdip_FillRectangle( G , Brush , 2 , 2 , 96 , 96 )
Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , 100 , 100 , "0xFFD4FAFC" , "0xFF004D8D" , 1 , 1 )
Gdip_FillRectangle( G , Brush , 4 , 4 , 92 , 92 )
Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 0 , 0 , 100 , 100 , "0xFFD4FAFC" , "0xFF004D8D" , 1 , 1 )
Gdip_FillRectangle( G , Brush , 5 , 5 , 90 , 90 )
Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 4 , 2 , 90 , 47 , "0xFFC6F2F8" , "0xFF8ACFE7" , 1 , 1 )
Gdip_FillRectangle( G , Brush , 6 , 6 , 88 , 88 )
Gdip_DeleteBrush( Brush )
Brush := Gdip_CreateLineBrushFromRect( 7 , 47 , 88 , 46 , "0xFF198EC7" , "0xaa6FC0E0" , 1 , 1 )
Gdip_FillRectangle( G , Brush , 6 , 50 , 88 , 45 )
Gdip_DeleteBrush( Brush )
Brush := Gdip_BrushCreateSolid( "0xFFF0F0F0" )
Gdip_TextToGraphics( G , char , "s56 Center vCenter Bold c" Brush " x0 y0" , "Arial" , 100 , 100 )
Gdip_DeleteBrush( Brush )
Gdip_DeleteGraphics( G )
hBitmap:=Gdip_CreateHBITMAPFromBitmap(pBitmap)
Gdip_DisposeImage(pBitmap)
return hBitmap
}
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。

评论(0)