In the following script a menu-like window with the clipboards appears. I'd like it to be semi-transparent, but I haven't got anything. In some tests it becomes invisible (100% tranasparent), in other tests it only becomes semi-transparent when closed and remains as a watermark on the screen.
It is a menu generated through the PUM.ahk library.
(In the image is the menu on the left)
Code: Select all
; https://www.autohotkey.com/board/topic/73599-ahk-l-pum-owner-drawn-object-based-popup-menu/ - capitalH
#NoEnv
;#Include %A_ScriptDir%
#Include PUM.ahk
#Include PUM_API.ahk
#singleinstance force
SetWorkingDir %A_ScriptDir%
CoordMode, Mouse, Screen
;MaxCount:=0
StartTicks:=A_TickCount
ClipBoardHistory:=Object()
ClipBoardEnabled=1
previousClip=%clipboard%
if FileExist("TempClip\Clip1.clip")
{
Loop, TempClip\Clip*.clip
NumberClip := A_Index
;MsgBox, %NumberClip%
Loop, %NumberClip%
{
ReadClip:= "TempClip\Clip" A_Index ".clip"
FileRead, ClipHsy, %ReadClip%
FileDelete, %ReadClip%
ClipSave(ClipBoardHistory, ClipHsy, A_Index)
}
}
; parameters of the PUM object, the manager of the menus
pumParams := { "SelMethod" : "fill" ;item selection method, may be frame,fill
,"selTColor" : 0xFFFFFF ;selection text color
,"selBGColor" : 0x036FC5 ;selection background color, -1 means invert current color
,"oninit" : "PUM_out" ;function which will be called when any of this events happen, se it below
,"onuninit" : "PUM_out"
,"onselect" : "PUM_out"
,"onrbutton" : "PUM_out"
,"onmbutton" : "PUM_out"
,"onrun" : "PUM_out" }
;PUM_Menu parameters
menuParams1 := { "bgcolor" : 0xFFFFF4 ;background color of the menu R
, "iconssize" : 0 ;size of icons in the menu
, "tcolor" : 0x036FC5 ; text color of the menu items
, "hFont" : Segoe UI 50}
;create an instance of PUM object, it is best to have only one of such in the program
pm := new PUM( pumParams )
PUM_out( msg, obj )
{
; if ( msg = "onselect" )
; tooltip % obj.tooltip
; if ( msg = "oninit" )
; tooltip % "menu init: " obj.handle
; if ( msg = "onuninit" )
; tooltip % "menu uninit: " obj.handle
; if ( msg = "onrbutton" )
; tooltip % "Right clicked: " obj.name
; if ( msg = "onmbutton" )
; tooltip % "Middle clicked: " obj.name
; if ( msg = "onrun" )
; tooltip % "Item runned: " obj.name
}
^!v::
;^ñ::
menu := pm.CreateMenu( menuParams1 )
index:=ClipBoardHistory.maxIndex()
if index=
return
while Index>=ClipBoardHistory.minIndex()
{
Description:=ClipBoardHistory[Index]["plain"]
FullDescription:=Description
;if(StrLen(Description)>35)
if(StrLen(Description)>80)
{
;toCut:=StrLen(Description)-18
toCut:=StrLen(Description)-50
StringMid, itemTemp1, Description, 1, 12
StringTrimLeft, itemTemp2, Description, %toCut%
Description=%itemTemp1%...%itemTemp2%
}
if index<10
MenuString:="&" . (ClipBoardHistory.maxindex()-Index+1) . ". " . Description
else
MenuString:= (ClipBoardHistory.maxindex()-Index+1) . ". " . Description
menu.Add( { "name" : MenuString
, "bold" : 1
, "index" : Index
, "tooltip" : ClipBoardHistory[Index]["plain"]})
index--
}
WinGet, ActiveWindow , ID, A
MouseGetPos, xpos2, ypos2
; item := menu.Show( A_ScreenWidth/3, A_ScreenHeight/3 )
item := menu.Show( xpos2, ypos2 )
WinGet, MenuClip, ID, A
;MsgBox, %MenuClip%
WinSet, Transparent, 150, ahk_Class AutohotkeyGui
WinSet, Redraw,, ahk_Class AutohotkeyGui
tooltip
WinActivate , ahk_id %ActiveWindow%
WinWaitActive, ahk_id %ActiveWindow%
hwnd := WinExist()
if item
{
ClipBoardEnabled=0
test:=item.index
tempClip:=clipboard
clipboard:=ClipBoardHistory[test]["plain"]
send, ^v
clipboard:=tempClip
ClipBoardEnabled=1
}
return
Menu.destroy()
WinSet, Transparent, 255, ahk_Class AutohotkeyGui
WinSet, Transparent, off, ahk_Class AutohotkeyGui
return
HideTrayTip:
TrayTip
Return
OnClipboardChange:
if (ClipBoardEnabled=1) and ((A_TickCount-StartTicks)>1)
{
currentClip=%clipboard%
;currentClipAll=%clipboardall%
If (A_EventInfo=1) and (currentClip <> previousClip)
{
previousClip=%clipboard%
;TrayTip,, %currentClip%
;SoundPlay, Close Window.mp3
;SetTimer, HideTrayTip, -1500
ClipSave(ClipBoardHistory,currentclip, 5)
}
}
Return
ClipSave(ClipBoardHistory,clip,maxclips=5)
{
ClipBoardHistory.insert(Object())
index:=ClipBoardHistory.MaxIndex()
ClipBoardHistory[index]["plain"]:=clip
;ClipBoardHistory[index]["All"]:=clipall
ClipTemp:= "TempClip\Clip" index ".clip"
If Index<=5
{
FileAppend, %Clip%, %ClipTemp%
}
if (index>maxclips)
{
ClipBoardHistory.Remove(ClipBoardHistory.MinIndex())
FileDelete, TempClip\Clip1.clip
Loop 5
if !FileExist("TempClip\Clip" A_Index ".clip")
{
NumberFile := A_Index
FileSup := NumberFile+1
Sup := "TempClip\Clip" Filesup ".clip"
NumF:= "TempClip\Clip" NumberFile ".clip"
Filemove, %Sup%, %NumF%
}
FileAppend, %Clip%, TempClip\Clip5.clip
}
}