Amazon Workspaces in Full screen – Switching back to host desktop

Quick solution for the problem related to amazon workspaces in full-screen mode.
The only way to switch back to the host system, is to exit full screen – but this is a problem since all the application windows are resized and re positioned.

Unfortunately amazon does not have a fix for this from 2014 to 2018 – as far asĀ  I know.
Link: https://forums.aws.amazon.com/thread.jspa?messageID=566726

I usually have word open on my host machine, and since I didn’t want to install visual studio or make a java application.. I decided to make a VBA macro.
The following VBA macro creates for me an Always On Top dialog (even on top of the full-screen dual monitor amazon workspaces).

Clicking the on the dialog causes me host start-menu to pop up, and I can access any of my running host applications or run new ones.

And this works without having to disconnect or leave my full screen mode.

The code follows:

Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2
Private Const HWND_TOPMOST = -1

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function SetWindowPos Lib "user32" (ByVal Hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal uFlags As Long) As Long

Option Explicit
 
Private Declare Function ShellExecute Lib "shell32.dll" _
    Alias "ShellExecuteA" _
        (ByVal Hwnd As Long, _
         ByVal lpOperation As String, _
         ByVal lpFile As String, _
         ByVal lpParameters As String, _
         ByVal lpDirectory As String, _
         ByVal nShowCmd As Long) As Long
         
Const SW_SHOWNORMAL = 1

Sub showDesktopWindow()
' Insert Rows Below
    UserForm1.Show vbModeless
     AlwaysOnTop ("UserForm1")
End Sub


Public Sub AlwaysOnTop(caption As String)

    Dim ret As Long
    Dim Hwnd As Long
    
    Hwnd = FindWindow(vbNullString, caption)
    ret = SetWindowPos(Hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
    
End Sub

The main macro that I run via a quick-access button is: AlwaysOnTop (“UserForm1”)

Reference:

http://www.vbforums.com/showthread.php?626778-UserForm-Always-on-Top&p=3878421&viewfull=1#post3878421