Jump to content
Docfxit

Automate Macrium Reflect update

Recommended Posts

Does anyone have a script to automate the update for Macrium Reflect ?

I'm trying to make one myself.  I'm getting stuck on this screen:

MacriumInstall.jpg.366812c05ef5bd829834f1afb231815c.jpg

AutoIt Window Info doesn't recognize the Home/Commercial button.

I have some code to recognize pixels but I don't know how to change this code to select the position of the circle to the left of Home.

#include <WinAPIGdi.au3>
Local $color, $PenWidth, $PS_SOLID

Sleep(100)
WinActivate("Macrium Reflect") ;wait 3 seconds for the app
Local $aPos = WinGetPos("Macrium Reflect")
If IsArray($aPos) Then
    ;                                   $aArray[0] = X position Horizontal
    ;                                   $aArray[1] = Y position Vertical
    ;                                   $aArray[2] = Width
    ;                                   $aArray[3] = Height
    Local $tLeft = $aPos[0] + ($aPos[2] / 4)
    Local $tTop = $aPos[1] + ($aPos[3] / 2) + 100
    ;                   PixelSearch ( left, top, right, bottom, color [, shade-variation = 0 [, step = 1 [, hwnd]]] )
    Local $aPixel = PixelSearch($tLeft, $tTop, $tLeft + 100, $tTop + 100, 0x00F0F0F0, 1, 1)
    Local $tRight = $tLeft + 100
    Local $tBottom = $tTop + 50
    _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4)
    If IsArray($aPixel) Then
;       MouseMove($aPixel[0] - 65, $aPixel[1] - 222) ;Just for debug
        MouseMove($tLeft - 50, $tTop - 232)     ;Just for debug
;       I removed the variable $aPixel. The cursor is still not relative to the window.
;       MouseClick("left", $aPixel[0] + 5, $aPixel[1] + 5, 1, 0)
        Sleep(9000)
        ;       MsgBox(48,"Stop", "Pause")
        ;       Send("{ALTDOWN}{N}{ALTUP}") ;click Next Button
    EndIf
EndIf

; Draw rectangle on screen.
Func _UIA_DrawRect($tLeft, $tRight, $tTop, $tBottom, $color = 0xFF, $PenWidth = 4)
    Local $hDC, $hPen, $obj_orig, $x1, $x2, $y1, $y2
    $x1 = $tLeft
    $x2 = $tRight
    $y1 = $tTop
    $y2 = $tBottom
    $hDC = _WinAPI_GetWindowDC(0) ; DC of entire screen (desktop)
    $hPen = _WinAPI_CreatePen($PS_SOLID, $PenWidth, $color)
    $obj_orig = _WinAPI_SelectObject($hDC, $hPen)

    _WinAPI_DrawLine($hDC, $x1, $y1, $x2, $y1) ; horizontal to right
    _WinAPI_DrawLine($hDC, $x2, $y1, $x2, $y2) ; vertical down on right
    _WinAPI_DrawLine($hDC, $x2, $y2, $x1, $y2) ; horizontal to left right
    _WinAPI_DrawLine($hDC, $x1, $y2, $x1, $y1) ; vertical up on left

    ; clear resources
    _WinAPI_SelectObject($hDC, $obj_orig)
    _WinAPI_DeleteObject($hPen)
    _WinAPI_ReleaseDC(0, $hDC)
EndFunc   ;==>_UIA_DrawRect

I figured out how to draw a box based on the position of $aPos.  I figured out how to move the mouse to the circle to the left of the Home.

If I move the window the box is drawn correct in the same position.  The mousemove positions the cursor in a totally different place. 

I'd like answers to the following:

1. I expected both the box and the cursor to be relative to the window.

2. I expected PixelSearch to find the circle.  It doesn't seem to.

MacriumLicense.jpg.55a473116bd106205281da31434889e0.jpg

Edited by Docfxit

Share this post


Link to post
Share on other sites

have you researched official "silent" options for this?

google "Macrium Reflect update" for example.

Share this post


Link to post
Share on other sites

I know they have a silent install with a commercial license.  I can't find any way to install with the command line for home users.

Thanks,

Docfxit

Share this post


Link to post
Share on other sites

How can I change this code so the mouse gets moved relative to the window?

#include <WinAPIGdi.au3>
Local $color, $PenWidth, $PS_SOLID

Sleep(100)
WinActivate("Macrium Reflect") ;wait 3 seconds for the app
Local $aPos = WinGetPos("Macrium Reflect")
If IsArray($aPos) Then
    ;                                   $aArray[0] = X position Horizontal
    ;                                   $aArray[1] = Y position Vertical
    ;                                   $aArray[2] = Width
    ;                                   $aArray[3] = Height
    Local $tLeft = $aPos[0] + ($aPos[2] / 4)
    Local $tTop = $aPos[1] + ($aPos[3] / 2) + 100
        MouseMove($tLeft - 50, $tTop - 232)     ;Just for debug
        Sleep(9000)
EndIf

Currently with this code, If I move the window the mouse ends up in a different position.

Share this post


Link to post
Share on other sites
49 minutes ago, Docfxit said:

How can I change this code so the mouse gets moved relative to the window?

You can start by carefully reading the help file for MouseMove.  Hint: Look in the "Related" section.

Share this post


Link to post
Share on other sites

Thanks for the hint.

I added Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client

It didn't solve my problem.  I must have something wrong in the logic.

I currently have this code:

#include <WinAPIGdi.au3>
Opt("MouseCoordMode", 0) ;1=absolute, 0=relative, 2=client
Local $color, $PenWidth, $PS_SOLID, $mousePositionLeft, $mousePositionTop

Sleep(100)
WinActivate("Macrium Reflect") ;wait 3 seconds for the app
Local $aPos = WinGetPos("Macrium Reflect")
If IsArray($aPos) Then
    ;                                   $aArray[0] = X position Horizontal
    ;                                   $aArray[1] = Y position Vertical
    ;                                   $aArray[2] = Width
    ;                                   $aArray[3] = Height
    Local $tLeft = $aPos[0] + ($aPos[2] / 4)
    Local $tTop = $aPos[1] + ($aPos[3] / 2) + 100
    MouseMove($tLeft - 50, $tTop - 232, 0)        ;Just for debug
    $mousePositionLeft = $aPos[0] + $tLeft - 50
    $mousePositionTop = $aPos[0] + $tTop - 232
    Sleep(9000)
EndIf

If everything was relative $mousePositionLeft and $mousePositionTop would be the same every time.

With the window in one position the results are:

MacriumPos1.jpg.d75275ac098ab0b676a40f505f44e099.jpg

With the window in a different position the results are:

MacriumPos2.jpg.2b9593cbe91dea469494f41bb5f26b9c.jpg

The mouse ends up in a totally different position relative to the window.

Share this post


Link to post
Share on other sites

My question would be how are you determining the x,y coordinates?  If you are using the Au3Info tool, then make sure that you set the coordinate mode to the desired option.  It can be found under "Option>Coord Mode".

Edited by TheXman

Share this post


Link to post
Share on other sites

How are you determining the correct coordinates that you want the mouse to move to, not the coordinates of the window?

Have you used the Au3Info tool before?  It can be very helpful in determining the coordinates.

Edited by TheXman

Share this post


Link to post
Share on other sites

Yes, i have used Au3Info before.  I need the script to find where the Home button is.  It needs to be automated.  That's what all the calculations are for.

The Home button should be in the exact same place relative to the window every time. 

Share this post


Link to post
Share on other sites

Then use the Au3Info tool and it will give you the exact coordinates.  You don't have to do any relative calculations.  It will give you the exact coordinates. (Assuming that you use the correct coordinate mode).  All you have to do, in your script, before doing the MouseMove, is make sure that the window that you are interested in is active.

Edited by TheXman

Share this post


Link to post
Share on other sites

So how do you take the x, y coordinate from the Au3Info tool and make the mouse click on that pixel?

Share this post


Link to post
Share on other sites
  • Open the Au3Info tool
  • Set the proper coordinate mode in the Au3Info tool
  • Have the window you are interested in open
  • Drag the Au3Info Finder Tool to the desired location on the window and drop it where you want it.
  • Look at the coordinates on the Mouse tab in the Au3Info Tool.  You can double click the "Position" line and it will even copy the coordinates to the clipboard so that you can paste it into your script.
Edited by TheXman

Share this post


Link to post
Share on other sites

Ok, So the first time I did that the Position was 204, 336

I moved the window.

the second time the Position was 150 339

If I don't move the window the Position is very repeatable.

 

PS: Cord mode = window

Edited by Docfxit

Share this post


Link to post
Share on other sites

Then you are using the wrong coordinate mode.  If you use Client or Window, it should be the same even when you move the window.

image.png.6187765599a721565cb631eee7d67c84.png

Edited by TheXman

Share this post


Link to post
Share on other sites
7 minutes ago, Docfxit said:

Ok, So the first time I did that the Position was 204, 336

I moved the window.

the second time the Position was 150 339

Are you looking on the MOUSE tab in the Au3Info Tool?  Or are you on the WINDOW  tab?

Share this post


Link to post
Share on other sites

With Cord mode = Client

The first time I did that the Position was 217, 244

I moved the window.

the second time the Position was 142 318

If I don't move the window the Position is very repeatable.

On the Mouse tab.

 

 

Edited by Docfxit

Share this post


Link to post
Share on other sites

The radio buttons on that installation screen look like standard Windows controls.  You shouldn't even need to use mouse clicks and movements.  You can access the controls directly.  You should be able to get the control info from the Au3Info Tool.

Share this post


Link to post
Share on other sites

I just tried it with a free trial from Macrium and everything works as expected and the coordinates, using Client Mode, are exactly the same no matter where I move the Window.  Not sure why it isn't working the same for you.  I've tried to help about as much as I can, sorry.

Edited by TheXman

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...