Untitled

From random_gangsta, 2 Years ago, written in PowerShell, viewed 7 times.
URL https://pastebin.h0me.dk/view/9084efde Embed
Download Paste or View Raw
  1. Add-Type @"
  2.    using System;
  3.    using System.Runtime.InteropServices;
  4.  
  5.    public class User32 {
  6.        [DllImport("user32.dll", SetLastError = true)]
  7.        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
  8.  
  9.        [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  10.        public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
  11.  
  12.        public const uint WM_KEYDOWN = 0x0100;
  13.        public const uint WM_KEYUP = 0x0101;
  14.    }
  15. "@
  16.  
  17. # Set the title or class name of the target window
  18. $windowTitle = "Your Window Title"
  19.  
  20. # Find the target window
  21. $windowHandle = [User32]::FindWindow([NullString]::Value, $windowTitle)
  22.  
  23. # Check if the window is found
  24. if ($windowHandle -ne [IntPtr]::Zero) {
  25.     # Send a key press (e.g., the 'A' key)
  26.     [User32]::SendMessage($windowHandle, [User32]::WM_KEYDOWN, [IntPtr]'A', [IntPtr]::Zero)
  27.     [User32]::SendMessage($windowHandle, [User32]::WM_KEYUP, [IntPtr]'A', [IntPtr]::Zero)
  28. } else {
  29.     Write-Host "Window not found."
  30. }

Reply to "Untitled"

Here you can reply to the paste above

captcha