Docfxit Posted November 29, 2019 Posted November 29, 2019 (edited) 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: 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. expandcollapse popup#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. Edited November 30, 2019 by Docfxit
orbs Posted November 29, 2019 Posted November 29, 2019 have you researched official "silent" options for this? google "Macrium Reflect update" for example. Signature - my forum contributions: Spoiler UDF: LFN - support for long file names (over 260 characters) InputImpose - impose valid characters in an input control TimeConvert - convert UTC to/from local time and/or reformat the string representation AMF - accept multiple files from Windows Explorer context menu DateDuration - literal description of the difference between given dates Apps: Touch - set the "modified" timestamp of a file to current time Show For Files - tray menu to show/hide files extensions, hidden & system files, and selection checkboxes SPDiff - Single-Pane Text Diff
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 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
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 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.
TheXman Posted November 30, 2019 Posted November 30, 2019 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. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 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: With the window in a different position the results are: The mouse ends up in a totally different position relative to the window.
TheXman Posted November 30, 2019 Posted November 30, 2019 (edited) 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 November 30, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 You can see the script is determining the x, y coordinates at this line: $aPos = WinGetPos("Macrium Reflect")
TheXman Posted November 30, 2019 Posted November 30, 2019 (edited) 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 November 30, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 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.
TheXman Posted November 30, 2019 Posted November 30, 2019 (edited) 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 November 30, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 So how do you take the x, y coordinate from the Au3Info tool and make the mouse click on that pixel?
TheXman Posted November 30, 2019 Posted November 30, 2019 (edited) 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 November 30, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 (edited) 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 November 30, 2019 by Docfxit
TheXman Posted November 30, 2019 Posted November 30, 2019 (edited) 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. Edited November 30, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
TheXman Posted November 30, 2019 Posted November 30, 2019 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? CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Docfxit Posted November 30, 2019 Author Posted November 30, 2019 (edited) 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 November 30, 2019 by Docfxit
TheXman Posted November 30, 2019 Posted November 30, 2019 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. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
TheXman Posted November 30, 2019 Posted November 30, 2019 (edited) 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 November 30, 2019 by TheXman CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now