Nikromizera Posted October 16, 2015 Share Posted October 16, 2015 Hi everyone, I've been trying to learn SCAR to macro in a game. The sequence of actions that I need performed is as follows: 1. Leading a mouse within the boundary of an intractable object My solution: MoveMouseBox command while specifying the box within the object 2. Right clicking in this randomized spot on the object to bring up an interaction menu (opens near where you clicked) My solution: This is where I am stuck, I don't know how to make a mouse perform a right click on a random coordinate that it moves to from 1. 3. Selecting (mousing over) an option from the interaction menu and clicking it My solution: Since the menu button I want clicked doesn't change I could use the bitmap strategy to recognize the option 4. Repeating the entire process after a certain wait time My solution: Repeat function I'm using SCAR Divi 3.41 Thanks to whoever helps me with writing this script and teaching me. Quote Link to comment Share on other sites More sharing options...
Nikromizera Posted October 16, 2015 Author Share Posted October 16, 2015 Okay after much error, here is my first attempt at the scripting for the aforementioned situation: I cannot seem to be able to work out the bitmap issue as my bitmap image is not recognized. I tried using the built in bitmap tool and pasting that into the ('') but that also yielded the same result. With the present script I'm able to move to the desired location and my mouse is able to right click but the "Pray" command cannot be selected even though I took a bitmap image of it program VariableIntervalClickerpray; var x, y, randx, randy : Integer; Int : Integer; Bmp : TSCARBitmap; procedure SetupInfo; begin Int := 0; Bmp := TSCARBitmap.Create(''); Bmp.LoadFromPng(ScriptPath + 'Pray.bmp'); end; procedure ClickPray; begin if FindBitmap(x, y, Bmp, 740, 295, 1300, 720) then begin MoveMouseEx(x, y, 15); ClickMouseEx(x, y, mbLeft, 70 + Random(20)); end else WriteLn('Error'); end; begin SetupInfo; MoveMouseBoxEx(Box(970, 400, 1100, 500), 15); Wait (1000 + Random (500)); repeat GetMousepos(x,y); begin Randx := randomrange(-50,50); Randy := randomrange(-50,50); MoveMouse(x+randx,y+randy); Wait (1000 + Random (500)); ClickMouseEx(x+randx,y+randy, mbRight, 70 + Random(20)); Wait (1000 + Random (500)); ClickPray; Wait (1000 + Random (500)); WriteLn('Command run ' + IntToStr(Int) + 'time(s)'); Inc(Int); end; until Int = 5; end. Quote Link to comment Share on other sites More sharing options...
lovromirnik Posted October 16, 2015 Share Posted October 16, 2015 2. Right clicking in this randomized spot on the object to bring up an interaction menu (opens near where you clicked)My solution: This is where I am stuck, I don't know how to make a mouse perform a right click on a random coordinate that it moves to from 1. 3. Selecting (mousing over) an option from the interaction menu and clicking it My solution: Since the menu button I want clicked doesn't change I could use the bitmap strategy to recognize the option Hey, For number two the fix is easy, after moving the mouse to a random spot check for the location of the mouse before clicking. That way use GetMouseLoc(X, Y) and only then MouseClick(X, Y, mbRight) For number three use the Bitmaps like you described but remember that SCAR finds the Bitmap at the beginning coordinates. So when you'd move your mouse on the button it would move it to the top left edge of the button. Use some offsets. I made a picture for that: - - - Updated - - - Also this is how I'd go on making the first part of your program. There is no way of testing this myself because I do not know your game, or play any games really but maybe it will be helpful program PrayClick; var Menu : TSCARBitmap; X : Integer; Y : Integer; procedure ClickPray; begin Menu := TSCARBitmap.Create('deNoBNADL/wQABADkfX7va2z/gYH+dnbiVFX7iYn9dHSoY2PfTE39h4f8cXFXS0vbV1j1e3v7bm6bVVXBDBtj'); if (FindBitmapTol(X, Y, Menu, 740, 295, 1300, 720, 10) then begin MoveMouseBoxEx(X, Y, X + 12, Y + 5, 15); GetMousePos(X, Y); ClickMouse(X, Y, mbLeft) end else begin Writeln('Error'); end; end; begin ClickPray; end. Quote Link to comment Share on other sites More sharing options...