Resize and move open windows

Welcome Forums General PowerShell Q&A Resize and move open windows

Viewing 4 reply threads
  • Author
    Posts
    • #167995
      Participant
      Topics: 74
      Replies: 167
      Points: 83
      Rank: Member

      I have a script to open 8 windows using VNC viewer (for seeing screens from computer).  This works fine.  After the script runs and I have the 8 windows open, I have to manually snap them to the monitors so they look tiled.  Is there a way to resize a window and move it using powershell?

      This is what I have so far.  This just opens the 8 screens using TightVNC Viewer.

      $laptops = '172.16.2.88', '172.16.1.145', '172.16.2.75', '172.16.2.87',
      '172.16.2.84', '172.16.2.83', '172.16.2.79' , '172.16.2.77'
      
      $wshell = New-Object -ComObject wscript.shell;
      
      foreach ($l in $laptops) {
      Start-Process -FilePath 'C:\Program Files\TightVNC\tvnviewer.exe'
      sleep 2
      $vlc = Get-Process -Name tvnviewer
      sleep 1
      $wshell.SendKeys($l)
      Write-Host "Using VNC for" $l -ForegroundColor Green
      sleep 1
      $wshell.SendKeys('~')
      sleep 1
      $wshell.SendKeys('12345')
      sleep 1
      $wshell.SendKeys('~')
      sleep 1
      }
    • #168157
      Participant
      Topics: 2
      Replies: 1000
      Points: 1,982
      Helping Hand
      Rank: Community Hero

      What are you asking here?

      8 separate monitors and tiled does not make since. If you have 8 windows open and 8 monitors to use, are you saying, you want each window on one of each monitor?

      Tiled, means you want them on one monitor, then you'd call windows proper to tile / cascade windows feature not use sendkeys stuff.

      For example:

      How Can I Tile the Windows on the Desktop?

       

       

    • #168565
      Participant
      Topics: 74
      Replies: 167
      Points: 83
      Rank: Member

      One monitor, with 8 VLC windows open. I'm able to use AutoIT scripts to move and resize windows, so may be that's the right path. I just need to figure out the coordinate system, but so far AutoIT is doing what I want.

    • #168940
      Participant
      Topics: 2
      Replies: 1000
      Points: 1,982
      Helping Hand
      Rank: Community Hero

      Yeppers, PS is not really the first choice for GUI / App Window automation.

      AutoIT, Selenium, WASP, etc. are purposed built things for such efforts. Well, there's rolling your own via .Net natively, but that requires you to know C# and how to tap the Win32 API to do that.

    • #169030
      Participant
      Topics: 74
      Replies: 167
      Points: 83
      Rank: Member

      I was able to use PowerShell and AutoIT to automatically snap windows. Everything works the way I want.

Viewing 4 reply threads
  • The topic ‘Resize and move open windows’ is closed to new replies.