VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



The following Code Helps To refresh Desktop using a different approach (This will be Helpful if You

by BrijMohan.K (3 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sat 3rd February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

The following Code Helps To refresh Desktop using a different approach (This will be Helpful if You are trying to Change Wallpaper,Using

API Declarations


x As Long
y As Long
End Type
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
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
Const VK_F5 = &H74
Const KEYEVENTF_KEYUP = &H2
Const MOUSEEVENTF_LEFTDOWN = &H2
Const MOUSEEVENTF_LEFTUP = &H4
Dim a As Integer, b As Integer
Dim cname As String
Dim cp As POINTAPI
Dim rval As Long

Rate The following Code Helps To refresh Desktop using a different approach (This will be Helpful if You



rval = GetCursorPos(cp)
 If a = 0 Then a = cp.x
 If b = 0 Then b = cp.y
SetCursorPos 5, 5
Me.Hide
Timer1.Enabled = True
Timer1.Interval = 10
End Sub
Public Sub refreshdesktop()
mouse_event &H2, 0, 0, 0, 0
mouse_event &H4, 0, 0, 0, 0
keybd_event &H74, 0, 0, 0
keybd_event &H74, 0, KEYEVENTF_KEYUP, 0
r = ShellExecute(Me.hwnd, vbNullString, "C:\WINDOWS\SYSTEM\Show Desktop.scf", 0, 0, SW_SHOWNORMAL)
SetCursorPos a, b
Unload Me
End
End Sub
Private Sub Timer1_Timer()
Dim hwnd As Long
rval = GetCursorPos(cp)
hwnd = WindowFromPoint(cp.x, cp.y)
cname = Space(128)
rval = GetClassName(hwnd, cname, 128)
Form1.Caption = Left(cname, InStr(cname, Chr(0)) - 1)
If Form1.Caption = "Internet Explorer_Server" Then refreshdesktop
r = ShellExecute(Me.hwnd, vbNullString, "C:\WINDOWS\SYSTEM\Show Desktop.scf", 0, 0, SW_SHOWNORMAL)
End Sub


Download this snippet    Add to My Saved Code

The following Code Helps To refresh Desktop using a different approach (This will be Helpful if You Comments

No comments have been posted about The following Code Helps To refresh Desktop using a different approach (This will be Helpful if You. Why not be the first to post a comment about The following Code Helps To refresh Desktop using a different approach (This will be Helpful if You.

Post your comment

Subject:
Message:
0/1000 characters