I am trying to automate one of the application installation which does not support silent installation flag. I am using the logic of the mouse click to do the installation. Similar example is here in the below link. Mouse Click automation with powershell (or other non-external software) With the above link I am able to achieve the objective but now I am worried about the accuracy of the mouse position. I guess mouse position differ based on screen size. So I came up with an idea to move the form to the left corner(similar to run prompt position) so I dont need to worry about the position. Please help me on this. Below is the sample working code.
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$signature=@'
[DllImport("user32.dll",CharSet=CharSet.Auto,CallingConvention=CallingConvention.StdCall)]
public static extern void mouse_event(long dwFlags, long dx, long dy, long cButtons, long dwExtraInfo);
'@
$SendMouseClick = Add-Type -memberDefinition $signature -name "Win32MouseEventNew" -namespace Win32Functions -passThru
$x = 752
$y = 514
[System.Windows.Forms.Cursor]::Position = New-Object System.Drawing.Point($x, $y)
start-process "D:\Binaries\ePGM.exe"
sleep -Seconds 09
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
sleep -Seconds 20
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000002, 0, 0, 0, 0);
$SendMouseClick::mouse_event(0x00000004, 0, 0, 0, 0);