[Library] Aki Desktop - Get access to a window behind the Icons [Win x64]

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
User avatar
Mijikai
Addict
Addict
Posts: 927
Joined: Sun Sep 11, 2016 2:17 pm

[Library] Aki Desktop - Get access to a window behind the Icons [Win x64]

Post by Mijikai »

The Aki Desktop library gives you access to a Desktop Window behind the Icons. 8)
Useful for drawing/rendering on the Desktop (behind the Icons) Wallpaper Style.
Nothing more nothing less.

The include:

Code: Select all

EnableExplicit

;Project: AKI - DESKTOP LIB
;Version: Alpha 1
;Platform: Windows 10 (x64)

;Author: Mijikai

;Copyright 2021 by Mijikai all rights reserved

;License: Attribution-NonCommercial-NoDerivatives 4.0 International
;https://creativecommons.org/licenses/by-nc-nd/4.0/legalcode

#AKI_DESKTOP_VERSION = $0001

Import "aki_desktop.lib"
  akiDesktopInterface.i()
  akiDesktopVersion.i()
EndImport

Interface AKI_DESKTOP
  Update.i();resets everything (call if the desktop was updated or has changed - ex. if the resolution changed) / returns #True or #False
  Handle.i();the handle to a (the) desktop window (behind the icons) / returns the handle
  Size.i(*Width.Integer,*Height.Integer);get width and height of the desktop / returns #True or #False
  Link.i(Handle.i);makes a window a child to the desktop window (only one window!) / returns <> #Null on success
  Unlink.i();resets all changes to the desktop and/or unlinks a child window! / returns #Null
  Release.i();releases the interface (without changing or resetting the desktop!) / returns #Null
EndInterface
Download:
https://www.dropbox.com/s/539xknibh34zd ... a.zip?dl=0

Have fun :D
Last edited by Mijikai on Sat Jul 17, 2021 10:41 pm, edited 7 times in total.
BarryG
Addict
Addict
Posts: 1565
Joined: Thu Apr 18, 2019 8:17 am

Re: [Library] Aki Desktop - Draw on Desktop behind the Icons [Win x64]

Post by BarryG »

How do you use it? When I compile/run, it just exits. Since you haven't provided the full source, I have no idea what to do.
User avatar
Mijikai
Addict
Addict
Posts: 927
Joined: Sun Sep 11, 2016 2:17 pm

Re: [Library] Aki Desktop - Draw on Desktop behind the Icons [Win x64]

Post by Mijikai »

There is no source just the include and a link to the lib.
The lib will give you access to a window behind the desktop icons.
How the window is used is up to the programmer.
Usually the window is used to create widgets and interactive or animated wallpapers.

Example:

Code: Select all

EnableExplicit

XIncludeFile "aki_desktop.pbi"
XIncludeFile "spp.pbi";https://www.purebasic.fr/english/viewtopic.php?f=27&t=76553

Procedure.i Main()
  Protected *dsk.AKI_DESKTOP
  Protected dsk_width.i
  Protected dsk_height.i
  Protected *spp.SPP
  *dsk = akiDesktopInterface()
  If *dsk
    *dsk\Size(@dsk_width,@dsk_height)
    *spp = sppContext(*dsk\Handle(),dsk_width >> 8,dsk_height >> 8)
    If *spp  
      Repeat
        dsk_width + 1
        *spp\Clear($FFFF00FF + dsk_width);<- change desktop background (color)
        *spp\SwapBuffer()
        Delay(10);<- ugly delay (dont do this in a real app!)
      Until GetAsyncKeyState_(#VK_ESCAPE) & $8000;<- exit if ESC is pressed
      *dsk\Unlink();<- reset desktop (window)
      *spp\Release()
    EndIf
    *dsk\Release()
  EndIf
  ProcedureReturn #Null
EndProcedure

Main()

End
fluent
User
User
Posts: 67
Joined: Sun Jan 24, 2021 10:57 am

Re: [Library] Aki Desktop - Get access to a window behind the Icons [Win x64]

Post by fluent »

Thanks for sharing. Does it support multiple monitors?
User avatar
Mijikai
Addict
Addict
Posts: 927
Joined: Sun Sep 11, 2016 2:17 pm

Re: [Library] Aki Desktop - Get access to a window behind the Icons [Win x64]

Post by Mijikai »

fluent wrote: Mon Jul 19, 2021 12:57 pm Thanks for sharing. Does it support multiple monitors?
I tested it with three monitors - the area affected is the combined (whole) dektop/screen area.
There is no support for individual monitors but thats not really a problem as one could query (ex. ExamineMonitors())
each monitor and adjust the rendering.

Here is another more complex example that renders a animated shader on the desktop. 8)
Enable threadsafe!

Code: Select all

EnableExplicit

XIncludeFile "aki_desktop.pbi"
XIncludeFile "spp.pbi";https://www.purebasic.fr/english/viewtopic.php?f=27&t=76553

Structure VEC2
  x.f:y.f
EndStructure

Structure VEC3
  x.f:y.f:z.f
EndStructure

Structure VEC4
  x.f:y.f:z.f:w.f
EndStructure

Global sdr_time.f
Global sdr_width.f
Global sdr_height.f

Macro Vec2(_v_,_x_,_y_)
  _v_\x = _x_:_v_\y = _y_
EndMacro

Macro Vec4(_v_,_x_,_y_,_z_,_w_)
  _v_\x = _x_:_v_\y = _y_:_v_\z = _z_:_v_\w = _w_
EndMacro

Macro Vec2Rotate(_v_,_a_,_out_)
  _out_\x = _v_\x * Cos(_a_) - _v_\y * Sin(_a_)
  _out_\y = _v_\x * Sin(_a_) + _v_\y * Cos(_a_)
EndMacro

Macro Vec2UV(_v_,_w_,_h_,_out_)
  _out_\x = ((_v_\x / _w_) * 2.0 - 1.0) * (_w_ / _h_)
  _out_\y = (_v_\y / _h_) * 2.0 - 1.0
EndMacro

Procedure.i Callback(*coord.VEC2,*color.VEC4)
  Protected uv.VEC2,rot.VEC2,col.VEC3,d.f,m.f
  Vec2UV(*coord,sdr_width,sdr_height,uv)
  Vec2Rotate(uv,sdr_time,rot)
  d = 0.6 - Sin(Abs(rot\x) * Cos(Abs(uv\x) + rot\x) * 40.0) * 1.1
  d + Cos(Abs(Mod(d,20.0)))
  If Abs(uv\x + Sin(sdr_time * 10.0 + uv\y * 4) / 10.0) < 0.4
    col\x = Abs(uv\x + Sin(sdr_time * 8.0 + uv\y * 4) / 10.0) + d / 80.0
    col\y = col\x / 10.0
    col\z = 1.0 - col\x
  Else
    col\x = Abs(uv\x) / d - 0.4
    col\y = Sin(Sin(sdr_time * 2.0) * 5.0 * Abs(rot\y)) - d
    col\z = 1.0 - col\x + Cos(Abs(rot\y)) - d
  EndIf
  Vec4(*color,col\x,col\y,col\z,1.0)
  ProcedureReturn
EndProcedure

Procedure.i Main()
  Protected *dsk.AKI_DESKTOP
  Protected dsk_width.i
  Protected dsk_height.i
  Protected *spp.SPP
  Protected exit.i
  If akiDesktopVersion() = #AKI_DESKTOP_VERSION
    If sppVersion() = #SPP_VERSION
      *dsk = akiDesktopInterface()
      If *dsk
        *dsk\Size(@dsk_width,@dsk_height)
        dsk_width >> 3
        dsk_height >> 3
        *spp = sppContext(*dsk\Handle(),dsk_width,dsk_height)
        If *spp
          If *spp\Event(33)
            sdr_width = dsk_width
            sdr_height = dsk_height
            *spp\PixelProc(@Callback(),#True)
            Repeat
              *spp\Clear()
              *spp\SwapBuffer()
              *spp\Wait()
              *spp\Info(#Null,@sdr_time)
              If Not exit
                exit = GetAsyncKeyState_(#VK_ESCAPE) & $8000
              EndIf
            Until exit
          EndIf
          *spp\Release()
        EndIf
        *dsk\Unlink()
        *dsk\Release()
      EndIf
    EndIf
  EndIf
  ProcedureReturn 
EndProcedure

Main()

End
Post Reply