VB.NET - Automate desktop apps with Sendkeys and Win32 functions @JFLHV
VB.NET - Automate desktop apps with Sendkeys and Win32 functions  @JFLHV
Uploaded February 2022 | Updated September 2026, 1 week ago
How I automate Windows desktop apps with VB.NET using Sendkeys and Win32 functions. It covers waiting until a specific window is active, explicit wait, simulating keyboard input with Sendkeys and simulating left click and right click.

#vbdotnet

Win32
-------------------
Private Declare Function GetForegroundWindow Lib "user32" () As IntPtr

Private Declare Auto Function GetWindowText Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpString As System.Text.StringBuilder,
ByVal cch As Integer) As Integer

Public Declare Sub mouse_event Lib "user32" (ByVal dwFlags As UInteger, ByVal dx As UInteger, ByVal dy As UInteger, ByVal dwData As UInteger,
ByVal dwExtraInfo As Integer)

Const MOUSEEVENTF_LEFTDOWN As UInteger = &H2
Const MOUSEEVENTF_LEFTUP As UInteger = &H4
Const MOUSEEVENTF_RIGHTDOWN As UInteger = &H8
Const MOUSEEVENTF_RIGHTUP As UInteger = &H10


Regex function
--------------------------
Regex.Replace(str, "[+^%~(){}]", "{$0}")


Sendkeys Codes
---------------------------
docs.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys


0:00 Summary of automation tasks
0:20 Wait for active window
1:22 Sendkeys functions
2:45 Mouseclicks
3:32 Demo UI to run scripts
VB.NET - Automate desktop apps with Sendkeys and Win32 functionsVB.NET - Animated passive notification in WinformsC# - WPF .NET app in VS CodeiMovie - Video inside text effect10 basic shapes animated green screenParking spot Google Maps AndroidScan text from camera on Google Pixel.NET MAUI to Android Emulator from command lineC# - Round WPF control corners using default templateSpotlight effect iMovie macOS30 second progress timer countdown green screenInkscape add pages
JFLHV |

VB.NET - Automate desktop apps with Sendkeys and Win32 functions

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER