Move a powershell window

Feb 2, 2013 at 3:18 PM
Hi,

I would like to move a powershell console window.
I try this script :
Import-Module C:\Temp\WASP\WASP.dll -verbose:$false
Select-Window powershell -verbose:$false | send-keys "% M{LEFT 10}{ENTER}" -verbose:$false
But I get an error as it sent only "% "
But If I change powershell by notepad in the select-window it works fine !

How can I move the powershell console windows from where I run a script ?
Thank you for your help.

Ludovic.

PS : If you want to know why I need that ... It is because I have to make a silent install of Acrobat Reader 4.05 and my installation works only If I move the powershell consol window !!!
Coordinator
Feb 2, 2013 at 7:43 PM
I don't know -- that should work (and works on other windows), but on Windows 8, I can't make it work on that console window at all. Works on the ConEmu window, can I convince you to upgrade your console? http://code.google.com/p/conemu-maximus5/
Coordinator
Feb 2, 2013 at 8:06 PM
Oh, I just tested this, and it works fine with the preview of WASP2 which I released. The latest version is here http://poshcode.org/get/3931 (WASP.psm1) and requires (http://poshcode.org/get/3174 (Reflection.psm1) which requires http://poshcode.org/get/3173 (Autoload.psm1)

WIth those you can write:

Select-UIElement -PID $PID | Invoke-Transform.Move -x 0 -y 0
Feb 3, 2013 at 1:31 PM
Hi,

My first computer is installed with Windows 7 and Powershell v3 and your Wasp2 works fine.
But with another with Windows 7 and Powershell V2 it doesn't work.
The two first import-module work fine.
But the third failed.

Import-Module \PBCApplic\Applic\Outils\Scripts\PowerShell\WASP\WASP.psm1
Unable to find type [System.Windows.Automation.ControlType]: make sure that the assembly containing this type is loaded
.
At \PBCApplic\Applic\Outils\Scripts\PowerShell\WASP\WASP.psm1:427 char:57
  • [StaticField(([System.Windows.Automation.ControlType] <<<< ))]$ControlType
    • CategoryInfo : InvalidOperation: (System.Windows.Automation.ControlType:String) [], ParentContainsError
      RecordException
    • FullyQualifiedErrorId : TypeNotFound
Import-Module : The specified module '\PBCApplic\Applic\Outils\Scripts\PowerShell\WASP\WASP.psm1' was not loaded becau
se no valid module file was found in any module directory.
At line:1 char:14
  • Import-Module <<<< \PBCApplic\Applic\Outils\Scripts\PowerShell\WASP\WASP.psm1
    • CategoryInfo : ResourceUnavailable: (\PBCApplic\App...\WASP\WASP.psm1:String) [Import-Module], FileNot
      FoundException
    • FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Any suggestion ?

Ludovic.
Coordinator
Feb 3, 2013 at 5:00 PM
That class is in uiautomationtypes, which is explicitly loaded by the module, so I'm not sure how it could fail. Run the add-type line by hand and then test that you can access that type by just writing [System.Windows.Automation.ControlType] in the console.

The only thing I can think of is that you're having a problem loading assemblies because it's on a UNC share (they changed the security model around that in .net 4, which PowerShell 3 uses automatically), so you could try making a local copy on the box, if the test above succeeds.
Feb 4, 2013 at 8:28 AM
Hi,

I'm just a user (recently advanced ! but not ultra advanced !!) of powershell.
Your links are for "Autoload Module 1.2.ps1", "Reflection Module 4.1.ps1" and "UIAutomation 1.9.ps1"
I rename thee files like "Autoload.psm1", "Reflection.psm1" and "WASP.psm1"
I unblocked them.
And in a powershell (V2) console, I strike :
Import-Module C:\Temp\Autoload.psm1
Import-Module C:\Temp\Reflection.psm1
Import-Module C:\Temp\WASP.psm1
I got no message with the two frst commands and an error with the third.
If I strike the line Add-Type -AssemblyName "UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" I can then re-execute the third line without errors ...

Ludovic.
Coordinator
Feb 5, 2013 at 3:41 AM
That's really weird, since the code in that module file is:
if($PSVersionTable.CLRVersion -gt "4.0") {
    $Language = "CSharp" # Version 4
    Add-Type -AssemblyName "UIAutomationClient, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Add-Type -AssemblyName "UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
} else {
    # In PowerShell 2, we need to use the .Net 3 version
    $Language = "CSharpVersion3" 
    Add-Type -AssemblyName "UIAutomationClient, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Add-Type -AssemblyName "UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
}
It seems like you're on PowerShell v2, so unless you've tweaked PowerShell.exe.config, your host will return $PSVersionTable.CLRVersion as something like 2.0 -- which will result in running that Add-Type line in the module. If you want, you could tweak the WASP.psm1 module to remove the 4.0 stuff, but just remember you did that in case you upgrade to PowerShell 3 later:
    # In PowerShell 2, we need to use the .Net 3 version
    $Language = "CSharpVersion3" 
    Add-Type -AssemblyName "UIAutomationClient, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Add-Type -AssemblyName "UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Feb 5, 2013 at 6:59 AM
Hi,

I add a line in the WASP.psm1 just before the first IF : Write-Host "Hello"
With py powershell v2, after importing module Autoload and Reflexion, when I want to import the wasp module I get the error.
If I add the type manualy and re-import the wasp module I get my message "Hello".
It seems like the import-module pre-compile the file before executing it.

Ludovic.