Elysiano Posted July 11, 2018 Share Posted July 11, 2018 Hello everyone, I have been working on a mouse recorder which can be used inside OSBot. It works fine, it repeats what I recorded, but it is ‘lagging’ when the mouse needs to move a lot of distance or just needs to move very fast circles (see .gifs below). https://imgur.com/a/jfuEd5w - When I recorded the mouse movement (+/- 8 seconds) https://imgur.com/a/B1mUOqf - When I played the recording of the mouse movement (+/- 15 seconds) As you can see, when the recording gets played it takes almost double the time. This is the core of the code from the mouse player which plays the data from following .txt file (see attachments, too many lines for forum I think) //Plays the mouse data /* The mouseRecordingData is an arrayList which contains data from the txt file as where to move, etc. */ void playMouseData() throws InterruptedException{ for(int i = 0; i < mouseRecordingData.size(); i++){ //move mouse getMouse().move(mouseRecordingData.get(i).getX(), mouseRecordingData.get(i).getY()); sleep(mouseRecordingData.get(i).getTime()); } } I am wondering, what can I do to improve the smoothness and speed of the mouse recording to stop this ‘lagging’? If you need more files or data, please let me know. Thank you in advance! MacroFile.txt Quote Link to comment Share on other sites More sharing options...
Hel Posted July 11, 2018 Share Posted July 11, 2018 18 hours ago, Elysiano said: Hello everyone, I have been working on a mouse recorder which can be used inside OSBot. It works fine, it repeats what I recorded, but it is ‘lagging’ when the mouse needs to move a lot of distance or just needs to move very fast circles (see .gifs below). https://imgur.com/a/jfuEd5w - When I recorded the mouse movement (+/- 8 seconds) https://imgur.com/a/B1mUOqf - When I played the recording of the mouse movement (+/- 15 seconds) As you can see, when the recording gets played it takes almost double the time. This is the core of the code from the mouse player which plays the data from following .txt file (see attachments, too many lines for forum I think) //Plays the mouse data /* The mouseRecordingData is an arrayList which contains data from the txt file as where to move, etc. */ void playMouseData() throws InterruptedException{ for(int i = 0; i < mouseRecordingData.size(); i++){ //move mouse getMouse().move(mouseRecordingData.get(i).getX(), mouseRecordingData.get(i).getY()); sleep(mouseRecordingData.get(i).getTime()); } } I am wondering, what can I do to improve the smoothness and speed of the mouse recording to stop this ‘lagging’? If you need more files or data, please let me know. Thank you in advance! MacroFile.txt From my understanding, the getMouse().move(x,y) creates it's own path to the destination, So you trying to record each pixel movement, then calling getMouse().move(x, y), uses a lot of CPU. You'd be better off using a custom mouse controller ( to get perfect pixel to pixel recreation), or just recording where the mouse stops, and allow the OSBot mouse controller to create the path to it. Quote Link to comment Share on other sites More sharing options...
Elysiano Posted July 11, 2018 Author Share Posted July 11, 2018 48 minutes ago, Slut said: From my understanding, the getMouse().move(x,y) creates it's own path to the destination, So you trying to record each pixel movement, then calling getMouse().move(x, y), uses a lot of CPU. You'd be better off using a custom mouse controller ( to get perfect pixel to pixel recreation), or just recording where the mouse stops, and allow the OSBot mouse controller to create the path to it. With custom mouse controller, do you mean the Java Robot Class and such? As for the CPU usage, running the script and mouse recording does not seem to increase the CPU usage Quote Link to comment Share on other sites More sharing options...
Hel Posted July 11, 2018 Share Posted July 11, 2018 17 hours ago, Elysiano said: With custom mouse controller, do you mean the Java Robot Class and such? As for the CPU usage, running the script and mouse recording does not seem to increase the CPU usage Well you can't use the Robot class through OSBot, the permissions are blocked for security reasons, but you can implement something similar, yes. Quote Link to comment Share on other sites More sharing options...
Elysiano Posted July 11, 2018 Author Share Posted July 11, 2018 4 minutes ago, Slut said: Well you can't use the Robot class through OSBot, the permissions are blocked for security reasons, but you can implement something similar, yes. Yup really unfortunate. Do you have any similar custom mouse controllers you can recommend? Quote Link to comment Share on other sites More sharing options...
Explv Posted July 11, 2018 Share Posted July 11, 2018 7 minutes ago, Elysiano said: Yup really unfortunate. Do you have any similar custom mouse controllers you can recommend? You can use the generateBotMouseEvent function to move the mouse instantly to another point: public void moveMouseInstantly(final int x, final int y) { getBot().getMouseEventHandler().generateBotMouseEvent(MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, x, y, 0, false, MouseEvent.NOBUTTON, true); } 2 Quote Link to comment Share on other sites More sharing options...
Elysiano Posted July 11, 2018 Author Share Posted July 11, 2018 1 hour ago, Explv said: You can use the generateBotMouseEvent function to move the mouse instantly to another point: public void moveMouseInstantly(final int x, final int y) { getBot().getMouseEventHandler().generateBotMouseEvent(MouseEvent.MOUSE_MOVED, System.currentTimeMillis(), 0, x, y, 0, false, MouseEvent.NOBUTTON, true); } Thanks! It's running alot faster and more 'human like' now 1 Quote Link to comment Share on other sites More sharing options...