Thursday, November 27, 2025

How to send one thousand time window keys with powershell

 for ($i = 0; $i -lt 1000; $i++) {


    (New-Object -ComObject "wscript.shell").SendKeys("^{ESC}")

    # Optional: Add a small delay (e.g., 10 milliseconds) to prevent overwhelming the system

    Start-Sleep -Milliseconds 10

}


Note:-     Start-Sleep -Milliseconds 10 // Fastest

    Start-Sleep -Milliseconds 100  //More Fast

    Start-Sleep -Milliseconds 1000  //Slow

How to click window button and open file explorer with powershell

 (New-Object -ComObject "wscript.shell").SendKeys("^{ESC}")


Start-Sleep -Seconds 3

[System.Windows.Forms.SendKeys]::SendWait("file explorere")


[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")

One thousand times left click in PowerShell

 Add-Type -AssemblyName System.Windows.Forms

Add-Type -AssemblyName System.Drawing


function Send-MouseClick {

    # Define the necessary Win32 API function for mouse events

    $signature = @'

    [DllImport("user32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]

    public static extern void mouse_event(uint dwFlags, uint dx, uint dy, uint cButtons, uint dwExtraInfo);

'@


    $mouseEvents = Add-Type -MemberDefinition $signature -Name "Win32MouseEvents" -Namespace "Windows" -PassThru


    # Mouse event flags

    $MOUSEEVENTF_LEFTDOWN = 0x0002

    $MOUSEEVENTF_LEFTUP = 0x0004


    # Get current cursor position

    $cursorPos = [System.Windows.Forms.Cursor]::Position

    $x = $cursorPos.X

    $y = $cursorPos.Y


    # Perform the left mouse button down and up events

    $mouseEvents::mouse_event($MOUSEEVENTF_LEFTDOWN, $x, $y, 0, 0)

    $mouseEvents::mouse_event($MOUSEEVENTF_LEFTUP, $x, $y, 0, 0)

}


# Loop 1000 times to perform 1000 clicks

for ($i = 0; $i -lt 1000; $i++) {

    Send-MouseClick

    # Optional: Add a small delay (e.g., 10 milliseconds) to prevent overwhelming the system

    Start-Sleep -Milliseconds 10

}


Write-Host "1000 clicks performed."


Tuesday, November 25, 2025

How to add comments in Excel

 With single cottes   ' test '

How to save file with VBA - How to save file with Macro - in Excel or MS Word

 Sub Macro2()


Shell "winword", vbNormalFocus   

   SendKeys "George W. Bush"

   SendKeys "%{F4}", True

    SendKeys "{ENTER}", True  

   'SendKeys "George W. Bush.txt", True'                       'Comment'  

   'SendKeys "%S"'                                     'Comment'

End Sub