Powerd911 – Numéro #1 au Canada

Comment utiliser Microsoft PowerShell® afin d’automatiser des actions dans PowerAMC

Comment ouvrir un modèle de données physiques

L’exemple ci-dessous permet d’ouvrir le modèle physique de données : (C: empmyPDM.pdm), de maximiser la fenêtre active de PowerAMC, de sélectionner le Menu=>Outils et de générer les scripts DDL de ce modèle physique.

$signature=@’
[DllImport(“user32.dll”,SetLastError = true)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
public static IntPtr GetWindow(string windowName){
return FindWindow(null,windowName);
}

  [DllImport(“user32.dll”,SetLastError = true)] public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
public static IntPtr GetControl(IntPtr value, string controlname){
return FindWindowEx(value, IntPtr.Zero, null, controlname);
}

  [DllImport(“user32.dll”,SetLastError = true)] public static extern int PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);
public static void LeftClick(IntPtr handle){
uint WM_LBUTTONDOWM = 0x0201;
uint WM_LBUTTONUP = 0x0202;
PostMessage(handle, WM_LBUTTONDOWM, 0, 0);
PostMessage(handle, WM_LBUTTONUP, 0, 0);
}

  [DllImport(“user32.dll”,SetLastError = true)] public static extern IntPtr ShowWindow(IntPtr hwnd, int nCmdShow);
public static IntPtr MaximizeWin(IntPtr hwnd){
int SW_MAXIMIZE = 3;
return ShowWindow(hwnd, SW_MAXIMIZE);
}
‘@

Add-Type -memberDefinition $signature -name “GUI” -namespace PD -passThru
add-type -path ‘C:Program FilesSybasePowerAMC 16Interop.PdCommon.dll’
add-type -path ‘C:Program FilesSybasePowerAMC 16Interop.PdPDM.dll’
Add-Type -AssemblyName System.Windows.Forms   # I want to call SendWait.

$pd = new-object -com poweramc.application
start-sleep 1
$pd.OpenModel(“C: empmyPDM.pdm”)
start-sleep 1
$PDwin=[PD.GUI]::GetWindow(“PowerAMC”)
[PD.GUI]::MaximizeWin($PDwin)

#Send ALT+T
[System.Windows.Forms.SendKeys]::SendWait(“%T”)
start-sleep 1
#Send Cntrl+Shift+P
[System.Windows.Forms.SendKeys]::SendWait(“^+P”)

Laisser un commentaire