Page 1 of 1

plz help me convert V1 code to V2

Posted: 22 Feb 2021, 04:45
by viv
My script use a function by
https://www.autohotkey.com/boards/viewtopic.php?t=60866

Now I ready to switch to V2
but have some problem
this one
I need to convert this function to v2
and I dont learn DllCall (so...May require complete code)
Thank you all for your help

Code: Select all

HideShowTaskbar(action) {
   static ABM_SETSTATE := 0xA, ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
   VarSetCapacity(APPBARDATA, size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize, 0)
   NumPut(size, APPBARDATA), NumPut(WinExist("ahk_class Shell_TrayWnd"), APPBARDATA, A_PtrSize)
   NumPut(action ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)
   DllCall("Shell32\SHAppBarMessage", UInt, ABM_SETSTATE, Ptr, &APPBARDATA)
}

Re: plz help me convert V1 code to V2  Topic is solved

Posted: 23 Feb 2021, 19:53
by swagfag

Code: Select all

HideShowTaskbar(shouldHide) {
	static size := 2*A_PtrSize + 2*4 + 16 + A_PtrSize
	APPBARDATA := BufferAlloc(size, 0)
	NumPut('UInt', size, APPBARDATA)
	NumPut('Ptr', WinExist('ahk_class Shell_TrayWnd'), APPBARDATA, A_PtrSize)
	
	static ABS_AUTOHIDE := 0x1, ABS_ALWAYSONTOP := 0x2
	NumPut('Ptr', shouldHide ? ABS_AUTOHIDE : ABS_ALWAYSONTOP, APPBARDATA, size - A_PtrSize)

	static ABM_SETSTATE := 0xA
	DllCall('Shell32\SHAppBarMessage', 'UInt', ABM_SETSTATE, 'Ptr', APPBARDATA, 'Ptr')
}

Re: plz help me convert V1 code to V2

Posted: 25 Jul 2021, 08:56
by lmstearn
Just a heads up, BufferAlloc is now replaced by the Buffer Object.