Send Ctrl+X / Replace string / Ctrl+V using a Hotkey?

Welcome Forums General PowerShell Q&A Send Ctrl+X / Replace string / Ctrl+V using a Hotkey?

Viewing 1 reply thread
  • Author
    • #88262
      Topics: 1
      Replies: 0
      Points: 0
      Rank: Member

      Hi, I used Autohotkey to script small Things for myself and I am Aware that this Task could be done with Autohotkey without Problems. However I Need to provide a script on many machines and would like to use Powershell instead so I do not Need to install Autohotkey everywhere.

      Task is:

      1. User has to select some text in browser or other window
      2. Press Hotkey, for example F12 on Keyboard to trigger script
      3. SCRIPT: send Ctrl+X to grab selected text .
      4. SCRIPT: replace dedicated character (for example #) with other string (CR/LR)
      5. SCRIPT: send Ctrl+V to paste modified text at same place where source text was

      I am just wondering if Powershell can do this, as I am newbie on Powershell. If anybody could confirm that this is possible I will dig into scrpting hoping to solve this

    • #88292
      Topics: 2
      Replies: 1013
      Points: 2,093
      Helping Hand
      Rank: Community Hero

      This has been possible ever since the VBScript days.
      It’s called SendKeys, though it does get panned by many over the years. I’ve had no real issues in using it.

      In PowerShell, it is just doing this.. Say, some Windows UI

      ### Start PowerUser Menu
      [void] [System.Reflection.Assembly]::LoadWithPartialName(“‘System.Windows.Forms”)

      A quick search using your favorite search engine, using the strings

      ‘VBScript SendKeys’
      ‘PowerShell SendKeys’

      … Will provide you a long list of articles to choose from.

      Also take a look at the WASP module, here:

Viewing 1 reply thread
  • The topic ‘Send Ctrl+X / Replace string / Ctrl+V using a Hotkey?’ is closed to new replies.