Here’s a Few Options…
Sub SetTaskBarOnTop()
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As CString, ByVal lpWindowName As CString) As Integer
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
//Used to set window Order and Position
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer ) As Integer
//Make window topmost
Dim trayHandle as Integer = FindWindow("Shell_TrayWnd", nil)
Call SetWindowPos(trayHandle, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
End Sub
[code]Sub ShowDesktop()
Declare Sub keybd_event Lib “user32.dll” (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Const VK_STARTKEY = &H5B
Const VK_M = 77
Const KEYEVENTF_KEYUP = &H2
'WinKey down
keybd_event VK_STARTKEY, 0, 0, 0
'M key down
keybd_event VK_M, 0, 0, 0
'M key up
keybd_event VK_M, 0, KEYEVENTF_KEYUP, 0
'WinKey up
keybd_event VK_STARTKEY, 0, KEYEVENTF_KEYUP, 0
End Sub
[/code]
[code]Sub MakeTopMost(win as Window)
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
//Used to set window Order and Position
Declare Function SetWindowPos Lib “user32” Alias “SetWindowPos” (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer ) As Integer
//Make window topmost
Call SetWindowPos(win.Handle, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
End Sub
Sub SetNotTopMost(win as Window)
Const SWP_NOMOVE = 2
Const SWP_NOSIZE = 1
Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
//Used to set window Order and Position
Declare Function SetWindowPos Lib “user32” Alias “SetWindowPos” (ByVal hwnd As Integer, ByVal hWndInsertAfter As Integer, ByVal x As Integer, ByVal y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal wFlags As Integer ) As Integer
//Stop window from being topmost
Call SetWindowPos(win.Handle, HWND_NOTOPMOST, 0, 0, 0, 0,FLAGS)
End Sub
[/code]
[code]Sub SendFocusToWindow(Win as Window)
//Will draw attention to the window. If the window is behind another, it’s taskbar icon will flash
Declare Function SetForegroundWindow Lib “user32” (ByVal hWnd As Integer) As Integer
Call SetForegroundWindow(Win.Handle)
End Sub
[/code]
Using the ShowDesktop method you can also send a Windows-Host key press by using its keycode, just as virtual keys were used to minimize all the windows.