Wednesday, December 31, 2025

Right click in powershell 50 times

 #Context menu with Powershell


 for ($i = 1; $i -le 500; $i++) {


  [System.Windows.Forms.SendKeys]::SendWait("^+{F10}") 

    Write-Host "Iteration: $i"


}



Tuesday, December 30, 2025

Monday, December 29, 2025

Single left click in VBA - Excel

 


    Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y 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)



' Define the mouse events

Public Const MOUSEEVENTF_LEFTDOWN = &H2

Public Const MOUSEEVENTF_LEFTUP = &H4

Public Const MOUSEEVENTF_ABSOLUTE = &H8000

Public Const MOUSEEVENTF_MOVE = &H1


Sub SimulateLeftClick(ByVal x As Long, ByVal y As Long)

    ' Move the cursor to the specified coordinates (screen coordinates)

    SetCursorPos x, y

    

    ' Perform the left click (Down and then Up)

    mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0

    mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0

End Sub


Sub TestClick()

    ' Clicks at screen coordinates X=50, Y=50

    Call SimulateLeftClick(40, 200)

End Sub


Friday, December 26, 2025

Wednesday, December 24, 2025

How to Play two videos with videos.js

 <html>

<head>

  <link href="https://vjs.zencdn.net/8.23.4/video-js.css" rel="stylesheet" />


  <!-- If you'd like to support IE8 (for Video.js versions prior to v7) -->

   <script src="https://vjs.zencdn.net/ie8/1.1.2/videojs-ie8.min.js">

   

    function init() {

        var url = "https://dash.akamaized.net/akamai/test/caption_test/ElephantsDream/elephants_dream_480p_heaac5_1_https.mpd",

            video = video = document.querySelector('video'),

            player;


        player = dashjs.MediaPlayer({}).create();

        player.initialize(video, url, true);

    }

</script>

</head>


<body>

<video

    id="my-player"

    class="video-js"

    controls

    preload="auto"

    poster="//vjs.zencdn.net/v/oceans.png"

    data-setup='{}'>

  <source src="//vjs.zencdn.net/v/oceans.mp4" type="video/mp4"></source>

  <source src="//vjs.zencdn.net/v/oceans.webm" type="video/webm"></source>

  <source src="//vjs.zencdn.net/v/oceans.ogv" type="video/ogg"></source>

  <p class="vjs-no-js">

    To view this video please enable JavaScript, and consider upgrading to a

    web browser that

    <a href="https://videojs.com/html5-video-support/" target="_blank">

      supports HTML5 video

    </a>

  </p>

</video>

  

   <video

      id="my-video"

      class="video-js vjs-default-skin"

      controls

      preload="auto"

      width="560"

      height="300"

      data-setup='{}'>

   

      <source

         src="https://vjs.zencdn.net/v/oceans.mp4"

         type="video/mp4"

         size="1080"

      >

      <track

         kind="subtitles"

         src="https://gist.githubusercontent.com/samdutton/ca37f3adaf4e23679957b8083e061177/raw/e19399fbccbc069a2af4266e5120ae6bad62699a/sample.vtt"

         srclang="en"

         label="English"

         

      >

   </video>

  </body>

  <html>

  

  

  




Monday, December 22, 2025

Refresh With powershell

 Start-Sleep -Seconds 3

 [System.Windows.Forms.SendKeys]::SendWait("^+{F10}") 

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

Excel Shortcuts - Merging of Two cells

CTRL + E----- To merge two cells


ALT + H +O +I ----------- Column width Auto size

ALT +H + W   or ALT + H + O +A  ---------- Auto size column height


Right Click in powershell - Context menu in Powershell

 #Context menu with Powershell

 [System.Windows.Forms.SendKeys]::SendWait("^+{F10}") 


Shift + F10

how to create Folder in Powershell - How to open explorer and create folder in powershell

 Add-Type -AssemblyName System.Windows.Forms

Add-Type -AssemblyName Microsoft.VisualBasic


Start-Process -FilePath "explorer.exe"


# Wait for WinWord to open and become active


Start-Sleep -Seconds 1


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

Start-Sleep -Seconds 1

(New-Object -ComObject "wscript.shell").SendKeys("D:\")

Start-Sleep -Seconds 1

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

#Context menu with Powershell

 [System.Windows.Forms.SendKeys]::SendWait("^+{F10}") 


 Start-Sleep -Seconds 1

 [System.Windows.Forms.SendKeys]::SendWait("^+n") 

 Start-Sleep -Seconds 1

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

 


 

How to set gif image in window 11 - How to set GIF wallpaper in Window 11

 Use Lively Wallpaper  software 


ref:- https://apps.microsoft.com/detail/9ntm2qc6qws7?hl=en-US&gl=US

Friday, December 19, 2025

how to send a to z in Powershell - How to send alphabets in Powershell


#Note This first line is mandatory 

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")


# Start WinWord (if not already running)

Start-Process -FilePath "excel.exe"

# Wait for WinWord to open and become active

Start-Sleep -Seconds 3


# Activate the WinWord window (adjust the title if necessary)

$wshell = New-Object -ComObject wscript.shell

#$wshell.AppActivate("Document1 - Word") # Or the actual document title

Start-Sleep -Seconds 1

 for ($i = 1; $i -le 5; $i++) {

 $j = [char](65 + $i)


[System.Windows.Forms.SendKeys]::SendWait("$j")

}


or


for ($test = 0; $test -lt 26; $test++)

{

    [char](65 + $test)

}

How to pause printer or stop printer for printing

>click on Start button

> Type Printers and scanners

>Select printer(Printer that you work like HP or Other) and Manage

> Click on Open Print Queue

> Click on Printer And Click on pause Printing(Check and Uncheck for Printing)

Monday, December 15, 2025

How to get x axis and y axis position of Mouse cursor in Powershell

 # Load the necessary assemblies for accessing mouse position information

Add-Type -AssemblyName System.Drawing

Add-Type -AssemblyName System.Windows.Forms


Write-Host "Move your mouse. Press Ctrl+C to stop."


while ($true) {

    # Get the current mouse position

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

    $x = $cursorPosition.X

    $y = $cursorPosition.Y

    

    # Print the coordinates. Using Write-Host with -NoNewline and carriage return `r` 

    # overwrites the previous line in the console for a cleaner continuous update.

    Write-Host "`rX: $x | Y: $y" -NoNewline

    

    # Wait for a short period to prevent the loop from consuming too much CPU

    Start-Sleep -Milliseconds 100

}



or for single position



Add-Type -AssemblyName System.Windows.Forms

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

Write-Host "Current mouse position is X: $($mousePosition.X), Y: $($mousePosition.Y)"

How to move mouse position with powershell - Inverse for loop in Powershell

 for ($i = 100; $i -ge 10; $i--) {

   Start-Sleep -Milliseconds 1


   Write-Host "Iteration: $i"

 [System.Windows.Forms.Cursor]::Position =  "$i, $i "

}


or with 10 decrement

 for ($i = 1000; $i -ge 10; $i -= 10) {

   Start-Sleep -Milliseconds 1

   Write-Host "Iteration: $i"

 [System.Windows.Forms.Cursor]::Position =  "$i, $i "

}

How to change the Cursor position with Powershell - How to change the mouse position with Powershell

 [System.Windows.Forms.Cursor]::Position = "700,700"


How to open and send keys in Calculator and Add operation in Powershell

 Add-Type –AssemblyName UIAutomationClient

Add-Type –AssemblyName UIAutomationTypes

$calc = [Diagnostics.Process]::Start('calc')

#wait for the UI to appear

$null = $calc.WaitForInputIdle(5000)

sleep –s 2

$calcWindowId = ((Get-Process).where{$_.MainWindowTitle -eq 'Calculator'})[0].Id

$root = [Windows.Automation.AutomationElement]::RootElement

$condition = New-Object Windows.Automation.PropertyCondition([Windows.Automation.AutomationElement]::ProcessIdProperty, $calcWindowId)

$calcUI = $root.FindFirst([Windows.Automation.TreeScope]::Children, $condition)


function FindAndClickButton($name){

$condition1 = New-Object Windows.Automation.PropertyCondition([Windows.Automation.AutomationElement]::ClassNameProperty, "Button")

$condition2 = New-Object Windows.Automation.PropertyCondition([Windows.Automation.AutomationElement]::NameProperty, $name)

$condition = New-Object Windows.Automation.AndCondition($condition1, $condition2)

$button = $calcUI.FindFirst([Windows.Automation.TreeScope]::Descendants, $condition)

$button.GetCurrentPattern([Windows.Automation.InvokePattern]::Pattern).Invoke()

}


#get and click the buttons for the calculation


FindAndClickButton Five

FindAndClickButton Plus

FindAndClickButton Nine

FindAndClickButton Equals


#get the result

$condition = New-Object Windows.Automation.PropertyCondition([Windows.Automation.AutomationElement]::AutomationIdProperty, "CalculatorResults")

$result = $calcUI.FindFirst([Windows.Automation.TreeScope]::Descendants, $condition)

$result.current.name

Wednesday, December 10, 2025

How to copy and paste in notepad excel with Arrow VBA

 Sub CommandButton1_Click()


    Shell "Notepad.exe", vbNormalFocus


    Dim I As Integer


    SendKeys "one"


    SendKeys "{Enter}"

     Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "^a"

     Application.Wait (Now + TimeValue("00:00:01"))

     SendKeys "^c"

     Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "{right}"

 Application.Wait (Now + TimeValue("00:00:01"))

    SendKeys "two"

 Application.Wait (Now + TimeValue("00:00:01"))

End Sub





How to send up and down keys in Excel or VBA

 https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/sendkeys-statement

How to open notepad with for loop and enter a to z characters in excel automatically - alphabets in excel

 Sub SendAlphabet_AtoZ()


Shell "Notepad.exe", vbNormalFocus

    Dim i As Integer

    Dim char_code As Integer

    Dim current_char As String

    Dim row_num As Integer

    

    

     Dim z As Integer


For z = 1 To 50

    row_num = 1

    ' Loop through ASCII codes for lowercase 'a' (97) to 'z' (122)

    For char_code = 50 To 122

        ' Convert the ASCII code to a character

        current_char = Chr(char_code)

        Application.Wait (Now + TimeValue("00:00:00"))

        ' Place the character in the active worksheet in column A

         SendKeys current_char

        

        ' Move to the next row

        

    Next char_code


Next z

  

End Sub

How to send Ctrl + F4 key in Powershell - How to send CTRL ALT Shift keys in Powershell - How to open Application in Powershell - How to open File Explorer in Powershell

 Start-Sleep -Seconds 5


$wshell = New-Object -ComObject WScript.Shell

$wshell.SendKeys("^{F4}")



or

#Note This first line is mandatory 


[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")

# Start WinWord (if not already running)

Start-Process -FilePath "explorer.exe"

# Wait for WinWord to open and become active

Start-Sleep -Seconds 3

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

# Activate the WinWord window (adjust the title if necessary)

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


ref:- https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=windowsdesktop-10.0


https://stackoverflow.com/questions/19824799/how-can-i-send-ctrl-or-alt-any-other-key

How to count status in selected sheet open or close

 =Countif('SheetName'!I3:I998, "Open")


I3:I998 is range