کد:
Option Explicit
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) 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 wFlags As Long) As Long
Private Const SWP_SHOWWINDOW = &H40
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOACTIVATE = &H10
Private Const SW_HIDE = 0
Private Const SW_SHOW = 5
Sub HideMyApp()
Dim hwd As Long
hwd = FindWindow(vbNullString, "Untitled - Notepad")
If hwd > 0 Then
'ShowWindow hwd, SW_HIDE
SetWindowPos hwd, 1, 0, 0, 0, 0, SWP_HIDEWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub
Sub ShowMyApp()
Dim hwd As Long
hwd = FindWindow(vbNullString, "Untitled - Notepad")
If hwd > 0 Then
'ShowWindow hwd, SW_SHOW
SetWindowPos hwd, 1, 0, 0, 0, 0, SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End If
End Sub