DesktopIcons() : Hide / Show Desktop Icons

Post your working scripts, libraries and tools for AHK v1.1 and older
ninjspks
Posts: 8
Joined: 01 Nov 2020, 22:30
Contact:

Re: DesktopIcons() : Hide / Show Desktop Icons

15 Feb 2023, 13:32

Skrell wrote:
17 Oct 2022, 14:45
Any way to get them to "fade in" and out?

Code: Select all

Setcontroldelay -1
SetBatchLines -1
SetWinDelay -1
#SingleInstance force
ListLines,Off
SendMode,Input
CoordMode,Mouse,Screen
global mdc,main_hwnd,hpic
onexit("clean")
tt("Begin")
sleep,900
gui,Back:New,-DPIScale +toolwindow +owner -SysMenu +E0x80020 ;+AlwaysOnTop
gui,Back:+LastFound +HwndMainhWnd -Caption
gui,Back:color,99ccff
winSet,Transcolor,99ccff
pToken:= Gdip_Startup()	;	winset,transcolor, 0
gui,pic: New,-DPIScale +hwndhpic  +parentBack +ToolWindow E0x80020 ;+AlwaysOnTop +e0x20
gui,pic: +LastFound -Caption -SysMenu +OwnDialogs
gui,pic: color,0f3f5c	;	winset,transcolor,0f00f0
gui,Back:Show,na x0 y0 w%a_screenwidth% h%a_screenheight%
main_DC:= DllCall("GetDC","UInt",MainhWnd)
	mdc:= DllCall("GetDC","UInt",hpic)
 DllCall("gdi32.dll\SetStretchBltMode","Uptr",main_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",SysLv_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",mdc,"UInt",3)
hProgman:= WinExist("ahk_class WorkerW", "FolderView")? WinExist()
:  WinExist("ahk_class Progman", "FolderView")
ShDef_DC:= 	DllCall("GetDC","UInt",hShellDefView:= DllCall("user32.dll\GetWindow","ptr",hProgman,"int",5,"ptr"))
SysLv_DC:= 	DllCall("GetDC","UInt",	hSysListView:= DllCall("user32.dll\GetWindow","ptr",hShellDefView,"int",5,"ptr"))
DllCall("SetParent","ptr",hpic,"ptr",dd:= desktop()) ; DllCall("SetParent","ptr",hpic,"ptr",MainhWnd)
gui,pic: show,na x0 y0 w%a_screenwidth% h%a_screenheight% 	;	winset,transcolor,0f00f0
DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,		"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
,trans(hSysListView,1)
mdc:= DllCall("GetDC","UInt",hpic) 
,tt("Replaced",1)
sleep,900
;;Show:= -1
;DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
;,	"Uint",mdc,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
;;if !(abc:=(DllCall("user32.dll\IsWindowVisible","ptr",hSysListView)=Show)){
;;	winhide,ahk_id %hSysListView%
;;	sleep,1000
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView,"uint",0x111,"uint",0x7402,"uint",0)
;;}
mdc:= DllCall("GetDC","UInt",hpic)
sleep,1000

tt("Fade-out",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
}
sleep,1000

tt("Fade-in",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
}
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView, "uint",0x111, "uint",0x7402, "uint",0)
winset,style,-0x10000000,ahk_id %hSysListView%
trans(hSysListView,"off")
winset,style,+0x10000000,ahk_id %hSysListView%
winset,style,+0x46003A40,ahk_id %hSysListView%
trans(hpic,1)
gui,pic: hide
gui,pic: destroy
return,

clean(){
	Gdip_Shutdown(ptoken)
}

trans(hwnd,val) {
	winset,transparent,% val,ahk_id %hwnd%
}

style(hwnd,style) {
	winset,style,% style,ahk_id %hwnd%
}

TT(TxT="",X:="",Y="",Dur="") {
	(TxT=""? TxT:= A_now)
	if(x && !isint(X)) {
		((isint(Y))? (Y? Dur:= Y))	;Transpose potential Dur arg.
		somethingElseThatMightBeDeclarableLater:= (Dur? Dur:())
		switch,(tt_loc:=X)	{
			case "center"	: X:=	(A_screenwidth *.5) -80,Y:= (A_screenheight*.5) -35
			case "!tray"	: X:=	(A_screenwidth -10),	Y:= (A_screenheight -10)
			case "tray"		: X:=	(A_screenwidth -10),	Y:=	45
		}
	} else,(!Y&&!Dur? Dur:= ((X)? X:-880))				;(Def timeout 880ms)
	((Dur&&!Dur=0)? ((Dur<100)&&(-100<Dur))? Dur*=1000)	;(Timeout as param.2 (int||str))
	ToolTip,% TxT,% (X&&Y? X:""),% (X&&Y? Y:""),1		;(y="center"? y:= (A_screenheight*.5)-35)
	SetTimer,Time0ut,% ((instr(Dur,"-")||(Dur<0))? Dur:("-" . Dur))
	return,~errOrlevel
} ; (x="center"?Dur:=y, x:=(A_screenwidth*0.5)-80, y:=(A_screenheight*.5)-35,)

sl33p() {
	loop,500 {
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
	}
}

Time0ut() {
	tooltip,
	return,
}
:happybday:
ninjspks
Posts: 8
Joined: 01 Nov 2020, 22:30
Contact:

Re: DesktopIcons() : Hide / Show Desktop Icons

15 Feb 2023, 13:47

Would be helpful if someone knows how to change the desktop font/font-color/glow/shadow. I have spent too many hours on that.
King regards
Skrell
Posts: 307
Joined: 23 Jan 2014, 12:05

Re: DesktopIcons() : Hide / Show Desktop Icons

08 Jul 2023, 14:51

ninjspks wrote:
15 Feb 2023, 13:32
Skrell wrote:
17 Oct 2022, 14:45
Any way to get them to "fade in" and out?

Code: Select all

Setcontroldelay -1
SetBatchLines -1
SetWinDelay -1
#SingleInstance force
ListLines,Off
SendMode,Input
CoordMode,Mouse,Screen
global mdc,main_hwnd,hpic
onexit("clean")
tt("Begin")
sleep,900
gui,Back:New,-DPIScale +toolwindow +owner -SysMenu +E0x80020 ;+AlwaysOnTop
gui,Back:+LastFound +HwndMainhWnd -Caption
gui,Back:color,99ccff
winSet,Transcolor,99ccff
pToken:= Gdip_Startup()	;	winset,transcolor, 0
gui,pic: New,-DPIScale +hwndhpic  +parentBack +ToolWindow E0x80020 ;+AlwaysOnTop +e0x20
gui,pic: +LastFound -Caption -SysMenu +OwnDialogs
gui,pic: color,0f3f5c	;	winset,transcolor,0f00f0
gui,Back:Show,na x0 y0 w%a_screenwidth% h%a_screenheight%
main_DC:= DllCall("GetDC","UInt",MainhWnd)
	mdc:= DllCall("GetDC","UInt",hpic)
 DllCall("gdi32.dll\SetStretchBltMode","Uptr",main_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",SysLv_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",mdc,"UInt",3)
hProgman:= WinExist("ahk_class WorkerW", "FolderView")? WinExist()
:  WinExist("ahk_class Progman", "FolderView")
ShDef_DC:= 	DllCall("GetDC","UInt",hShellDefView:= DllCall("user32.dll\GetWindow","ptr",hProgman,"int",5,"ptr"))
SysLv_DC:= 	DllCall("GetDC","UInt",	hSysListView:= DllCall("user32.dll\GetWindow","ptr",hShellDefView,"int",5,"ptr"))
DllCall("SetParent","ptr",hpic,"ptr",dd:= desktop()) ; DllCall("SetParent","ptr",hpic,"ptr",MainhWnd)
gui,pic: show,na x0 y0 w%a_screenwidth% h%a_screenheight% 	;	winset,transcolor,0f00f0
DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,		"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
,trans(hSysListView,1)
mdc:= DllCall("GetDC","UInt",hpic) 
,tt("Replaced",1)
sleep,900
;;Show:= -1
;DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
;,	"Uint",mdc,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
;;if !(abc:=(DllCall("user32.dll\IsWindowVisible","ptr",hSysListView)=Show)){
;;	winhide,ahk_id %hSysListView%
;;	sleep,1000
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView,"uint",0x111,"uint",0x7402,"uint",0)
;;}
mdc:= DllCall("GetDC","UInt",hpic)
sleep,1000

tt("Fade-out",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
}
sleep,1000

tt("Fade-in",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
}
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView, "uint",0x111, "uint",0x7402, "uint",0)
winset,style,-0x10000000,ahk_id %hSysListView%
trans(hSysListView,"off")
winset,style,+0x10000000,ahk_id %hSysListView%
winset,style,+0x46003A40,ahk_id %hSysListView%
trans(hpic,1)
gui,pic: hide
gui,pic: destroy
return,

clean(){
	Gdip_Shutdown(ptoken)
}

trans(hwnd,val) {
	winset,transparent,% val,ahk_id %hwnd%
}

style(hwnd,style) {
	winset,style,% style,ahk_id %hwnd%
}

TT(TxT="",X:="",Y="",Dur="") {
	(TxT=""? TxT:= A_now)
	if(x && !isint(X)) {
		((isint(Y))? (Y? Dur:= Y))	;Transpose potential Dur arg.
		somethingElseThatMightBeDeclarableLater:= (Dur? Dur:())
		switch,(tt_loc:=X)	{
			case "center"	: X:=	(A_screenwidth *.5) -80,Y:= (A_screenheight*.5) -35
			case "!tray"	: X:=	(A_screenwidth -10),	Y:= (A_screenheight -10)
			case "tray"		: X:=	(A_screenwidth -10),	Y:=	45
		}
	} else,(!Y&&!Dur? Dur:= ((X)? X:-880))				;(Def timeout 880ms)
	((Dur&&!Dur=0)? ((Dur<100)&&(-100<Dur))? Dur*=1000)	;(Timeout as param.2 (int||str))
	ToolTip,% TxT,% (X&&Y? X:""),% (X&&Y? Y:""),1		;(y="center"? y:= (A_screenheight*.5)-35)
	SetTimer,Time0ut,% ((instr(Dur,"-")||(Dur<0))? Dur:("-" . Dur))
	return,~errOrlevel
} ; (x="center"?Dur:=y, x:=(A_screenwidth*0.5)-80, y:=(A_screenheight*.5)-35,)

sl33p() {
	loop,500 {
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
	}
}

Time0ut() {
	tooltip,
	return,
}
:happybday:
image.png
image.png (31.92 KiB) Viewed 1366 times
ninjspks
Posts: 8
Joined: 01 Nov 2020, 22:30
Contact:

Re: DesktopIcons() : Hide / Show Desktop Icons

23 Sep 2023, 11:27

Skrell wrote:
08 Jul 2023, 14:51
ninjspks wrote:
15 Feb 2023, 13:32
Skrell wrote:
17 Oct 2022, 14:45
Any way to get them to "fade in" and out?

Code: Select all

Setcontroldelay -1
SetBatchLines -1
SetWinDelay -1
#SingleInstance force
ListLines,Off
SendMode,Input
CoordMode,Mouse,Screen
global mdc,main_hwnd,hpic
onexit("clean")
tt("Begin")
sleep,900
gui,Back:New,-DPIScale +toolwindow +owner -SysMenu +E0x80020 ;+AlwaysOnTop
gui,Back:+LastFound +HwndMainhWnd -Caption
gui,Back:color,99ccff
winSet,Transcolor,99ccff
pToken:= Gdip_Startup()	;	winset,transcolor, 0
gui,pic: New,-DPIScale +hwndhpic  +parentBack +ToolWindow E0x80020 ;+AlwaysOnTop +e0x20
gui,pic: +LastFound -Caption -SysMenu +OwnDialogs
gui,pic: color,0f3f5c	;	winset,transcolor,0f00f0
gui,Back:Show,na x0 y0 w%a_screenwidth% h%a_screenheight%
main_DC:= DllCall("GetDC","UInt",MainhWnd)
	mdc:= DllCall("GetDC","UInt",hpic)
 DllCall("gdi32.dll\SetStretchBltMode","Uptr",main_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",SysLv_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",mdc,"UInt",3)
hProgman:= WinExist("ahk_class WorkerW", "FolderView")? WinExist()
:  WinExist("ahk_class Progman", "FolderView")
ShDef_DC:= 	DllCall("GetDC","UInt",hShellDefView:= DllCall("user32.dll\GetWindow","ptr",hProgman,"int",5,"ptr"))
SysLv_DC:= 	DllCall("GetDC","UInt",	hSysListView:= DllCall("user32.dll\GetWindow","ptr",hShellDefView,"int",5,"ptr"))
DllCall("SetParent","ptr",hpic,"ptr",dd:= desktop()) ; DllCall("SetParent","ptr",hpic,"ptr",MainhWnd)
gui,pic: show,na x0 y0 w%a_screenwidth% h%a_screenheight% 	;	winset,transcolor,0f00f0
DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,		"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
,trans(hSysListView,1)
mdc:= DllCall("GetDC","UInt",hpic) 
,tt("Replaced",1)
sleep,900
;;Show:= -1
;DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
;,	"Uint",mdc,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
;;if !(abc:=(DllCall("user32.dll\IsWindowVisible","ptr",hSysListView)=Show)){
;;	winhide,ahk_id %hSysListView%
;;	sleep,1000
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView,"uint",0x111,"uint",0x7402,"uint",0)
;;}
mdc:= DllCall("GetDC","UInt",hpic)
sleep,1000

tt("Fade-out",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
}
sleep,1000

tt("Fade-in",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
}
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView, "uint",0x111, "uint",0x7402, "uint",0)
winset,style,-0x10000000,ahk_id %hSysListView%
trans(hSysListView,"off")
winset,style,+0x10000000,ahk_id %hSysListView%
winset,style,+0x46003A40,ahk_id %hSysListView%
trans(hpic,1)
gui,pic: hide
gui,pic: destroy
return,

clean(){
	Gdip_Shutdown(ptoken)
}

trans(hwnd,val) {
	winset,transparent,% val,ahk_id %hwnd%
}

style(hwnd,style) {
	winset,style,% style,ahk_id %hwnd%
}

TT(TxT="",X:="",Y="",Dur="") {
	(TxT=""? TxT:= A_now)
	if(x && !isint(X)) {
		((isint(Y))? (Y? Dur:= Y))	;Transpose potential Dur arg.
		somethingElseThatMightBeDeclarableLater:= (Dur? Dur:())
		switch,(tt_loc:=X)	{
			case "center"	: X:=	(A_screenwidth *.5) -80,Y:= (A_screenheight*.5) -35
			case "!tray"	: X:=	(A_screenwidth -10),	Y:= (A_screenheight -10)
			case "tray"		: X:=	(A_screenwidth -10),	Y:=	45
		}
	} else,(!Y&&!Dur? Dur:= ((X)? X:-880))				;(Def timeout 880ms)
	((Dur&&!Dur=0)? ((Dur<100)&&(-100<Dur))? Dur*=1000)	;(Timeout as param.2 (int||str))
	ToolTip,% TxT,% (X&&Y? X:""),% (X&&Y? Y:""),1		;(y="center"? y:= (A_screenheight*.5)-35)
	SetTimer,Time0ut,% ((instr(Dur,"-")||(Dur<0))? Dur:("-" . Dur))
	return,~errOrlevel
} ; (x="center"?Dur:=y, x:=(A_screenwidth*0.5)-80, y:=(A_screenheight*.5)-35,)

sl33p() {
	loop,500 {
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
	}
}

Time0ut() {
	tooltip,
	return,
}
:happybday:
image.png
sorry for taking so long to respond, desktop mereley derives the desktop handle.

here is the missing function

Code: Select all

DESKTOP(def="") { ;mw wip
DetectHiddenWindows, On
DetectHiddenText,    On
SetTitleMatchMode,   2
SetTitleMatchMode,   Slow 
	WinGet,LL,List,ahk_class WorkerW
	loop,%LL%
	{
		va:= LL%A_Index%
		winget, deskhandle, id, ahk_id %va%
		; if (def="Main") {
			; return,va
		; }
		; else,
		controlget,desklistviewhnd,hwnd,,SysListView321 , ahk_id %va%
		SendMessage, 0x1004, 0, 0,, Ahk_ID %desklistviewhnd%
		if !(errorlevel = "FAIL") {
			itemcount:=errorlevel
			return,va
			; return,desklistviewhnd
		}
	}
	return,va
	;msgbox no %def%
}
also i found a better sleep method on autohotkey documentation

Code: Select all

Sleep(DurMSecs=4) { ; 4ms *MW 2023 ;
	DllCall("Winmm\timeBeginPeriod","UInt",3)
	DllCall("Sleep","UInt",DurMSecs)
	DllCall("Winmm\timeEndPeriod","UInt",3)
}
Skrell
Posts: 307
Joined: 23 Jan 2014, 12:05

Re: DesktopIcons() : Hide / Show Desktop Icons

24 Sep 2023, 12:45

so replace sl33p() with sleep() correct?
Skrell
Posts: 307
Joined: 23 Jan 2014, 12:05

Re: DesktopIcons() : Hide / Show Desktop Icons

24 Sep 2023, 12:49

ninjspks wrote:
23 Sep 2023, 11:27
Skrell wrote:
08 Jul 2023, 14:51
ninjspks wrote:
15 Feb 2023, 13:32
Skrell wrote:
17 Oct 2022, 14:45
Any way to get them to "fade in" and out?

Code: Select all

Setcontroldelay -1
SetBatchLines -1
SetWinDelay -1
#SingleInstance force
ListLines,Off
SendMode,Input
CoordMode,Mouse,Screen
global mdc,main_hwnd,hpic
onexit("clean")
tt("Begin")
sleep,900
gui,Back:New,-DPIScale +toolwindow +owner -SysMenu +E0x80020 ;+AlwaysOnTop
gui,Back:+LastFound +HwndMainhWnd -Caption
gui,Back:color,99ccff
winSet,Transcolor,99ccff
pToken:= Gdip_Startup()	;	winset,transcolor, 0
gui,pic: New,-DPIScale +hwndhpic  +parentBack +ToolWindow E0x80020 ;+AlwaysOnTop +e0x20
gui,pic: +LastFound -Caption -SysMenu +OwnDialogs
gui,pic: color,0f3f5c	;	winset,transcolor,0f00f0
gui,Back:Show,na x0 y0 w%a_screenwidth% h%a_screenheight%
main_DC:= DllCall("GetDC","UInt",MainhWnd)
	mdc:= DllCall("GetDC","UInt",hpic)
 DllCall("gdi32.dll\SetStretchBltMode","Uptr",main_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",SysLv_DC,"UInt",3)
,DllCall("gdi32.dll\SetStretchBltMode","Uptr",mdc,"UInt",3)
hProgman:= WinExist("ahk_class WorkerW", "FolderView")? WinExist()
:  WinExist("ahk_class Progman", "FolderView")
ShDef_DC:= 	DllCall("GetDC","UInt",hShellDefView:= DllCall("user32.dll\GetWindow","ptr",hProgman,"int",5,"ptr"))
SysLv_DC:= 	DllCall("GetDC","UInt",	hSysListView:= DllCall("user32.dll\GetWindow","ptr",hShellDefView,"int",5,"ptr"))
DllCall("SetParent","ptr",hpic,"ptr",dd:= desktop()) ; DllCall("SetParent","ptr",hpic,"ptr",MainhWnd)
gui,pic: show,na x0 y0 w%a_screenwidth% h%a_screenheight% 	;	winset,transcolor,0f00f0
DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,		"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
,trans(hSysListView,1)
mdc:= DllCall("GetDC","UInt",hpic) 
,tt("Replaced",1)
sleep,900
;;Show:= -1
;DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
;,	"Uint",mdc,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
;;if !(abc:=(DllCall("user32.dll\IsWindowVisible","ptr",hSysListView)=Show)){
;;	winhide,ahk_id %hSysListView%
;;	sleep,1000
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView,"uint",0x111,"uint",0x7402,"uint",0)
;;}
mdc:= DllCall("GetDC","UInt",hpic)
sleep,1000

tt("Fade-out",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0xff-a_index)<<16|1<<24,"Uint",2)
}
sleep,1000

tt("Fade-in",1)
loop,255 {
	sl33p()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0x00+a_index)<<16|1<<24, "Uint", 2)
}
;;	DllCall("user32.dll\SendMessage", "ptr",hShellDefView, "uint",0x111, "uint",0x7402, "uint",0)
winset,style,-0x10000000,ahk_id %hSysListView%
trans(hSysListView,"off")
winset,style,+0x10000000,ahk_id %hSysListView%
winset,style,+0x46003A40,ahk_id %hSysListView%
trans(hpic,1)
gui,pic: hide
gui,pic: destroy
return,

clean(){
	Gdip_Shutdown(ptoken)
}

trans(hwnd,val) {
	winset,transparent,% val,ahk_id %hwnd%
}

style(hwnd,style) {
	winset,style,% style,ahk_id %hwnd%
}

TT(TxT="",X:="",Y="",Dur="") {
	(TxT=""? TxT:= A_now)
	if(x && !isint(X)) {
		((isint(Y))? (Y? Dur:= Y))	;Transpose potential Dur arg.
		somethingElseThatMightBeDeclarableLater:= (Dur? Dur:())
		switch,(tt_loc:=X)	{
			case "center"	: X:=	(A_screenwidth *.5) -80,Y:= (A_screenheight*.5) -35
			case "!tray"	: X:=	(A_screenwidth -10),	Y:= (A_screenheight -10)
			case "tray"		: X:=	(A_screenwidth -10),	Y:=	45
		}
	} else,(!Y&&!Dur? Dur:= ((X)? X:-880))				;(Def timeout 880ms)
	((Dur&&!Dur=0)? ((Dur<100)&&(-100<Dur))? Dur*=1000)	;(Timeout as param.2 (int||str))
	ToolTip,% TxT,% (X&&Y? X:""),% (X&&Y? Y:""),1		;(y="center"? y:= (A_screenheight*.5)-35)
	SetTimer,Time0ut,% ((instr(Dur,"-")||(Dur<0))? Dur:("-" . Dur))
	return,~errOrlevel
} ; (x="center"?Dur:=y, x:=(A_screenwidth*0.5)-80, y:=(A_screenheight*.5)-35,)

sl33p() {
	loop,500 {
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
	}
}

Time0ut() {
	tooltip,
	return,
}
:happybday:
image.png
sorry for taking so long to respond, desktop mereley derives the desktop handle.

here is the missing function

Code: Select all

DESKTOP(def="") { ;mw wip
DetectHiddenWindows, On
DetectHiddenText,    On
SetTitleMatchMode,   2
SetTitleMatchMode,   Slow 
	WinGet,LL,List,ahk_class WorkerW
	loop,%LL%
	{
		va:= LL%A_Index%
		winget, deskhandle, id, ahk_id %va%
		; if (def="Main") {
			; return,va
		; }
		; else,
		controlget,desklistviewhnd,hwnd,,SysListView321 , ahk_id %va%
		SendMessage, 0x1004, 0, 0,, Ahk_ID %desklistviewhnd%
		if !(errorlevel = "FAIL") {
			itemcount:=errorlevel
			return,va
			; return,desklistviewhnd
		}
	}
	return,va
	;msgbox no %def%
}
also i found a better sleep method on autohotkey documentation

Code: Select all

Sleep(DurMSecs=4) { ; 4ms *MW 2023 ;
	DllCall("Winmm\timeBeginPeriod","UInt",3)
	DllCall("Sleep","UInt",DurMSecs)
	DllCall("Winmm\timeEndPeriod","UInt",3)
}
image.png
image.png (17.72 KiB) Viewed 1208 times
Attachments
image.png
image.png (4.69 KiB) Viewed 1211 times
ninjspks
Posts: 8
Joined: 01 Nov 2020, 22:30
Contact:

Re: DesktopIcons() : Hide / Show Desktop Icons

25 Sep 2023, 01:51

It definitely works at my end still .Ive reduced the FPS of this GIF to save filesize.
Image
It is running over 100 fps for me, you may have to use your own value for sleep time in msecs.

You may also find that there is more than one custom function missing, they should all be publicly available on my github.

Here is the missing function:

Code: Select all

isint(var) {
	if var is integer
		 return,1
	else,return,0
}
Skrell
Posts: 307
Joined: 23 Jan 2014, 12:05

Re: DesktopIcons() : Hide / Show Desktop Icons

22 Nov 2023, 21:23

@ninjspks Sorry to bother you again about this but I'm trying to take your script and break it up into discrete callable functions but found that upon doing that the icons on the desktop no longer highlight when I move the mouse over them; any idea what I broke?

Code: Select all

#Include, Gdip_All.ahk
; https://www.autohotkey.com/boards/viewtopic.php?p=507506#p507506

Setcontroldelay -1
SetBatchLines -1
SetWinDelay -1
#SingleInstance force
ListLines,Off
SendMode,Input
CoordMode,Mouse,Screen
onexit("clean")

global mdc,main_hwnd,hpic,SysLv_DC,MainhWnd, hSysListView

StartupIconFade()

Return


StartupIconFade() {
    global mdc,main_hwnd,hpic,SysLv_DC,MainhWnd, hSysListView
    tt("Begin")
    sleep,900
    gui,Back:New,-DPIScale +toolwindow +owner -SysMenu +E0x80020 ;+AlwaysOnTop
    gui,Back:+LastFound +HwndMainhWnd -Caption
    gui,Back:color,99ccff
    winSet,Transcolor,99ccff
    pToken:= Gdip_Startup()	;	winset,transcolor, 0
    gui,pic: New,-DPIScale +hwndhpic  +parentBack +ToolWindow E0x80020 ;+AlwaysOnTop +e0x20
    gui,pic: +LastFound -Caption -SysMenu +OwnDialogs
    gui,pic: color,0f3f5c	;	winset,transcolor,0f00f0
    gui,Back:Show,na x0 y0 w%a_screenwidth% h%a_screenheight%
    main_DC:= DllCall("GetDC","UInt",MainhWnd)
        mdc:= DllCall("GetDC","UInt",hpic)
     DllCall("gdi32.dll\SetStretchBltMode","Uptr",main_DC,"UInt",3)
    ,DllCall("gdi32.dll\SetStretchBltMode","Uptr",SysLv_DC,"UInt",3)
    ,DllCall("gdi32.dll\SetStretchBltMode","Uptr",mdc,"UInt",3)
    hProgman:= WinExist("ahk_class WorkerW", "FolderView")? WinExist()
    :  WinExist("ahk_class Progman", "FolderView")
    ShDef_DC:= 	DllCall("GetDC","UInt",hShellDefView:= DllCall("user32.dll\GetWindow","ptr",hProgman,"int",5,"ptr"))
    SysLv_DC:= 	DllCall("GetDC","UInt",	hSysListView:= DllCall("user32.dll\GetWindow","ptr",hShellDefView,"int",5,"ptr"))
    DllCall("SetParent","ptr",hpic,"ptr",dd:= desktop()) ; DllCall("SetParent","ptr",hpic,"ptr",MainhWnd)
    gui,pic: show,na x0 y0 w%a_screenwidth% h%a_screenheight% 	;	winset,transcolor,0f00f0
    DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
    ,		"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",0xff<<16|1<<24, "Uint", 2)
    ,trans(hSysListView,1)
    mdc:= DllCall("GetDC","UInt",hpic) 
    ,tt("Replaced",1)
    sleep,900

    mdc:= DllCall("GetDC","UInt",hpic)
    sleep,1000

Return
}

F1::
    FadeDesktopOut()
Return

F2::
    FadeDesktopIn() 
Return


FadeDesktopOut() {
    global mdc,main_hwnd,hpic,SysLv_DC,MainhWnd, hSysListView

    tt("Fade-out",1)
    loop,63 {
        Sleep()
        DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
    ,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0xff-A_Index*4)<<16|1<<24,"Uint",2)
        DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
    ,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0xff-A_Index*4)<<16|1<<24,"Uint",2)
    }
    Sleep()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",0<<16|1<<24,"Uint",2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P",a_screenwidth|a_screenheight<<32
,	"Uint",mdc,"int64P",0,"Uint",0,"intP",0<<16|1<<24,"Uint",2)
}

FadeDesktopIn() {
    global mdc,main_hwnd,hpic,SysLv_DC,MainhWnd, hSysListView
    
    tt("Fade-in",1)
    loop,63 {
        Sleep()
        DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
    ,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",(0x00+A_Index*4)<<16|1<<24, "Uint", 2)
        DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
    ,	"Uint",mdc,"int64P",0,"Uint",0,"intP",(0x00+A_Index*4)<<16|1<<24, "Uint", 2)
    }
    Sleep()
	DllCall("UpdateLayeredWindow","Uint",hpic,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
,	"Uint",SysLv_DC,"int64P",0,"Uint",0,"intP",0xFF<<16|1<<24, "Uint", 2)
	DllCall("UpdateLayeredWindow","Uint",MainhWnd,"Uint",0,"Uint",0,"int64P", a_screenwidth|a_screenheight<<32
    ,	"Uint",mdc,"int64P",0,"Uint",0,"intP",0xFF<<16|1<<24, "Uint", 2)
}

clean(){
    global mdc,main_hwnd,hpic,SysLv_DC,MainhWnd, hSysListView
    
    winset,style,-0x10000000,ahk_id %hSysListView%
    trans(hSysListView,"off")
    winset,style,+0x10000000,ahk_id %hSysListView%
    winset,style,+0x46003A40,ahk_id %hSysListView%
    trans(hpic,1)
    gui,pic: hide
    gui,pic: destroy
	Gdip_Shutdown(ptoken)
}

trans(hwnd,val) {
	winset,transparent,% val,ahk_id %hwnd%
}

style(hwnd,style) {
	winset,style,% style,ahk_id %hwnd%
}

TT(TxT="",X:="",Y="",Dur="") {
	(TxT=""? TxT:= A_now)
	if(x && !isInt(X)) {
		((isInt(Y))? (Y? Dur:= Y))	;Transpose potential Dur arg.
		somethingElseThatMightBeDeclarableLater:= (Dur? Dur:())
		switch,(tt_loc:=X)	{
			case "center"	: X:=	(A_screenwidth *.5) -80,Y:= (A_screenheight*.5) -35
			case "!tray"	: X:=	(A_screenwidth -10),	Y:= (A_screenheight -10)
			case "tray"		: X:=	(A_screenwidth -10),	Y:=	45
		}
	} else,(!Y&&!Dur? Dur:= ((X)? X:-880))				;(Def timeout 880ms)
	((Dur&&!Dur=0)? ((Dur<100)&&(-100<Dur))? Dur*=1000)	;(Timeout as param.2 (int||str))
	; ToolTip,% TxT,% (X&&Y? X:""),% (X&&Y? Y:""),1		;(y="center"? y:= (A_screenheight*.5)-35)
	SetTimer,Time0ut,% ((instr(Dur,"-")||(Dur<0))? Dur:("-" . Dur))
	return,~errOrlevel
} ; (x="center"?Dur:=y, x:=(A_screenwidth*0.5)-80, y:=(A_screenheight*.5)-35,)

sl33p() {
	loop,500 {
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
		sleep,-1,sleep,-1,sleep,-1,sleep,-1,sleep,-1
	}
}

Sleep(DurMSecs=4) { ; 4ms *MW 2023 ;
	DllCall("Winmm\timeBeginPeriod","UInt",3)
	DllCall("Sleep","UInt",DurMSecs)
	DllCall("Winmm\timeEndPeriod","UInt",3)
}

Time0ut() {
	tooltip,
	return,
}

DESKTOP(def="") { ;mw wip
    DetectHiddenWindows, On
    DetectHiddenText,    On
    SetTitleMatchMode,   2
    SetTitleMatchMode,   Slow 
    
	WinGet,LL,List,ahk_class WorkerW
	loop,%LL%
	{
		va:= LL%A_Index%
		winget, deskhandle, id, ahk_id %va%
		controlget,desklistviewhnd,hwnd,,SysListView321 , ahk_id %va%
		SendMessage, 0x1004, 0, 0,, Ahk_ID %desklistviewhnd%
		if !(errorlevel = "FAIL") {
			itemcount:=errorlevel
			return,va
		}
	}
	return,va
}

isInt(nr){ 
	If nr is integer
		return true
	else
		return false
}

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 195 guests