How To Code a RuneScape Bot with RobotJS - Learn JavaScript by playing RuneScape 1/4
HTML-код
- Опубликовано: 4 авг 2024
- This tutorial will teach you how to code a RuneScape bot using JavaScript. No prior programming experience required! This guide is for beginners. We'll use Node.js and the RobotJS library and use a technique called GUI automation.
* This tutorial is for educational purposes only *
Full tutorial playlist: • Learn JavaScript by pl...
View the Source Code
GitHub repo: github.com/learncodebygaming/...
Download Links
Node.js: nodejs.org/
RobotJS: robotjs.io/
Visual Studio Code: code.visualstudio.com/download
Recommended JavaScript Resources
Eloquent JavaScript: amzn.to/3deUEfb or online edition at eloquentjavascript.net/
W3Schools: www.w3schools.com/js/default.asp
0:35 Disclaimer: Don't Cheat!
1:31 Using the browser console to run JavaScript
3:18 How to install Node.js
5:22 Using Notepad and PowerShell to write code
8:24 Using VSCode to write code
9:48 How to install RobotJS
A note on the "automatically install necessary tools" step of the Node.js installation:
If you already have Node installed, you can find the Additional Tools install link in the Start menu under "Node". Alternatively, you can install windows-build-tools from an elevated PowerShell or CMD.exe like this: npm install --global --production windows-build-tools
More details here: www.npmjs.com/package/robotjs...
In this tutorial series, I'm going to teach you how to program a simple Runescape bot in JavaScript. More specifically, we're going to be using Node.js and the RobotJS library to do GUI automation, and with those tools we're going to make a basic woodcutting bot. You don't need to have any prior programming experience to follow along. This tutorial is aimed at absolute beginners, so I'll be going slowly, showing you how to get everything set up, and explaining fundamental programming concepts as we go. So if you've ever been interested in programming or in JavaScript, this project should be a great place to get started.
JavaScript has always been a popular language with new programmers because it's very easy to get started with. All you need is a web browser. Every modern browser can run JavaScript.
So let's write your first line of code. If you're in Chrome, right-click anywhere on a web page and click Inspect. Then in the window that pops up, click on Console. You can do almost the exact same thing in Firefox or even the Edge browser.
This is the JavaScript console. You can write and execute JavaScript code from right here. If we type 3 + 4 and hit enter, you can see we get the expected result. You can also call a function like alert(‘Hello'); and when you hit enter, you can see a popup appear.
JavaScript is the language of frontend web development, so any programmer who wants to work on the web needs to be able to write JavaScript at some point. That's another reason why JavaScript is a good place to start learning, because most programmers will need to know it eventually anyway.
Now, for the woodcutting bot we're going to write, I'm going to teach you a technique called GUI automation. This is a technique where you write code to automate mouse movement and keyboard inputs, while using information from the screen to make decisions about what your code should do next. If you've seen my tutorial series on PyAutoGUI, we're using the same concepts here, except we'll be doing things in JavaScript instead of Python.
In order to use GUI automation, we won't be able to run our JavaScript code inside the browser. That's because browsers come with protections that prevent code from controlling a user's mouse and keyboard. This is a very good thing, because could you imagine if the websites you visited could control your mouse and keyboard... that would be terrible. So we need some way to run our code as a desktop application that has permission to control our mouse and keyboard.
To do that, we'll be using Node.js, a very popular JavaScript runtime that's used by professional developers all the time.
Download and install Node.js from their website, nodejs.org. The home page should give you a link to the recommended download for your platform. In my case that was the LTS 64-bit Windows Installer. When installing, you should click the checkbox to "Automatically install the necessary tools". If you don't, you'll get errors when we try to install the RobotJS library.
So that probably took a little while, but when it's finished, let's confirm it was installed correctly by using the terminal. On Windows, I prefer to use Git Bash, but you can also use PowerShell. Enter the command node --version and it'll output the installed version of node if it's installed correctly.
Continue with the written tutorial here: learncodebygaming.com/blog/ho...
Join me on Discord: / discord
I was just in discord with my friends like, "I wish I could learn how to code a bot in RS just to learn java." One google search later, I find this man.
Haha, that's awesome!
David Baxter worth noting that Java and JavaScript are two completely different languages.
Sucks for you. Because JavaScript is awful compared to java
@@michaellk2254 you suck
So violent men with that toxic masculinity get that out of here
This video took me from 0 javascript skills to being able to write some cool scripts, thank you so much for this video, would love to see more!
your personality gives me a very chill feeling, love the content
Just wanted to say thank you for these videos! You’re above most with your editing, a lot of tutorials are unwatchable because the people making them don’t ever zoom in on their screen so the viewer has to do guessing work 50% of the time
Great video man
Thank you, happy to hear that people appreciate the editing.
Yes!! This is EXACTLY what I needed to help me get into learning how to code. Instead of lesson after lesson I can implement my own fun ideas like this and still learn👍
I completely agree
Instead of spending weekend with my friends I will watch this!!! Previous material about OpenCV was so enjoyable and made me to take advantaged from this one!
This video is really helpful! The way you teach is very clear and precise. Thank you!
thanks bro you are so generous with your knowledge. The world needs more people like you, really appreciate all this effort just to help out people! You're a champion mate.
Brilliant video! This has gotten me very excited to learn coding. On to the next video!
I am still a beginner and needed a coding project to help me learn and this is exactly what I was looking for.
This video is very well put together! Thank you for the lesson, you are a good teacher.
i have been looking for a JavaScript tutorial for bots for such a long time thank you :) please make more like this !!!!
Thanks! I definitely plan on making more.
Thank you for this!!!! I am a CS major and I've been looking for ways to combine my knowledge with my extracurricular activities so this was spot on! I usually have rs running in the background chatting and skilling while I'm doing my school work, listening to lectures, etc.. so this is a neat project to combine both of my passions video games especially my OG favorite runescape and my "adulting" passion which is computer science and programming. So anyways thank you so much for this *disclaimer* I will not be using this knowledge to cheat Jagex or the RS community, I wholeheartedly believe in fair gaming and this is just an interesting way to learn the mechanics of both worlds! THANK YOU!!!!
this videos honestly got me more interested in coding than a year of secondary school python, great job
same.
this has been a kid dream of mine, man. Respect + for you
thanks for this! looking forward to learning more
God bless you man, this is inspiring me to learn to code through the games I love! It's so exciting
Have fun!
Underrated channel mate, subbed
really looking forward to watching this full serious so good so far!!
youre a really good teacher btw
@@Furrierity Thanks!
really like the tutorial, i am learning JS at the moment so this is a fun way of learning it to. hope i can do what you can do one day :).
Good video bro. Keep growing this channel.
Great stuff, lots of things i wanted to learn :) Smart !
Thanks, for helping me select a automation library and download/install it :)
Great video, thanks for all the valuable info!
You're welcome!
Really a refreshing way to learn javascript.I am pumped💪💪💪
Awesome!
Richard from Silicon Valley giving us a really nice tutorial very concise and well explained
This is a really great video, thank you!!
really cool series! thank you
Amsome video! Already a fan.
Underrated channel
Very well made / useful tutorial. Thank you!
I am learning website development but I haven’t learned JS yet. Finally I have a fun way to actually learn it.
Edit: Do you have any tutorials to learn Java through bots? Java is the main language I’ve been wanting to learn for years but OOP really stumps me and without a project to keep me interested I eventually give up.
Awesome tutorial thanks!
Awesome video mate.
Thanks!
Great video I love how detailed you was. I was wanting to learn more about coding is there any (hopefully free) coding documents/link guides for beginners you recommend?
just found this gem of a channel
really nice content! new sub here! happy new year from Panama bro!
Thanks, happy new year!
cant wait for part 2 ! keep it up Ben !!
by the way do you think programming this kind of bot is easier and more efficient in JAvaScript or Python ?
I think the easiness is about the same. Python has a few more GUI automation libraries floating around right now than JavaScript, so you get more options. Python is also more popular for machine learning, if you plan on doing that eventually. But there isn't anything holding JavaScript back either. It's really just up to what you prefer.
good video bro, i'm from Brazil, and, even though I don't speak english very well, I really liked that
Thank you
Super hyped!
Thanks! One tip for people who got the error - make sure when the thing pops up you click a key twice, and not just exit the tab.
Amazing videos man
Great idea, good stuff...
Great tutorials to follow along - one thing I noticed in your videos - you’re absolutely obsessed with everything that has to do with AutoGUI😂
GREAT TUTORIAL!
Thanks!
Yes you are very right. JavaScript is the best one with start with for understanding coding
Wow I'm amazed thanks man
thank you man
keep up the good work!
Thanks!
HELLO I WAS AFRAID TO LEARN NODE.JS BUT AFTER YOUR VIDEO I UNDERSTAND THAT NODE.JS IS NOT SO HARD I LIKE HOW YOU EXPLAIN ALL THINGS AND YOUR TALING MANERE JUST KEEP IT UP P.S THAT'S MY FIRST COMMENT ON RUclips + LIKE + SUBSCRIBE
Thanks, glad it helped you!
Just a tip, all caps is perceived as yelled in text. Knowing that, read your comment again and it turns a bit humorous. ;)
Wow, you got my sub!
such a sick channel! I wish I found this earlier
Thanks!
Thank you for the video so far I like your teaching style. I also like that I get to learn how to code with a game I love in a way that maintains integrity! For anyone that gets stuck around the 7:30 mark. I found that I had to go into the OneDrive directory first, then Desktop to woodcutter. Hope that helps :)
Thanks glad you like it! And thanks for the tip in case anyone else gets stuck there.
I’m having an issue where the robot can move the cursor in all applications beside runescape. I’m using the dreamscape RSPS because Ikov seems to not be working anymore. How could I go about fixing this? Is there something that dreamscape is using to prevent bots maybe?
Thank you so much
awesome!!!!
YOU ARE AMAZIIIIING 🇧🇷
Do more advanced stuff with runescape, very interesting and fun!
HAHAHAHAHAHAH piece of s**t
Great video!! I always thought that runescape bots had to be written in Java,
Thanks!
This is exactly what I've been looking for... I started coding python but find it hard to keep learning without real exercises. So I guess JS would be a nice way to learn. By any chance do you have a Discord community or an account I can reach you for specific questions if I'm ever stuck? I would really appreciate it. (Or play IKOV together lmao). Lmk!
Yeah I think doing projects is the best way to learn. You can do this with Python, too, using PyAutoGUI. I've got another video series about how to use that. I don't have a Discord channel setup, but several people have asked for it. For now you can email me questions at ben@learncodebygaming.com and I'd be glad to help, it just might take me a while to get back to you. I've been super busy with client work lately. Good luck, and have fun!
you are awesome!
Hi, can you please help with an issue:
The longer the script runs the more ram "node js server side javascript" uses, upto the point where it's >28gb of ram within 20 mins. Is there a way I should be flushing the ram somehow?
Does each screenshot get stored in ram? I'm doing a slightly more complicated bot and within a minute its using 2gb+ of ram and withing 10 mins its >10gb's. Any help to resolve this is appreciated! :)
IF one were to try and make an undetectable bot, would there be a benefit in python over JS? IF I am not modifying the code or using reflection to run commands, only object recog and autuGUI. Seems undetectable to me.
hey i have a problem when doing "npm install robotjs" as alot of python error came up then gyp errors then npm errors
maybe this is because im woorking with react?
great video
PEACE AND LOVE THANK YOU BRO!
Expect about 4 days between the release of each video in this series. Stay tuned!
@@maxra2142 Yes you can! There are a few OpenCV packages for NodeJS. It looks like opencv4nodejs is the most popular. The syntax will be different for JavaScript, but the functions and concepts are the same as what I cover in the OpenCV videos. I haven't used it before, so let us know how it goes if you give it a try! www.npmjs.com/package/opencv4nodejs
I'm stuck at 10:03 mark, how do I get to the next line? The cursor keeps staying at the end of "woodcutter", and when I press enter, it just copies itself instead of going to the next line where I'm supposed to input the "npm init -y" command. Could you please help, thank you.
God bless, a real one 🙏🏽
Been trying for days to get scroll mouse to work but cant, do you think you could look into in :)
Are you going to be using computer vision to detect game objects or some type of injection/hooking?
I'll be using pixel color matching to detect game objects. Will be teaching that in part 3.
I'm kinda confused having issues running the robotjs install inside WSL. but as able to install it through powershell
For Mac users:
You need to use "/" not "\" in terminal. AND After installing Node.js. You need to install "xcode command line tools"; type into the terminal: "xcode-select --install" .THEN you can install robotjs by typing in "npm i robotjs"
Thanks for sharing!
@@LearnCodeByGaming Great series you put up! Thanks for liking the comment!
Lets do it!!!
Another tip for those having issues with moveMouse. When I attempted it I could not get my mouse to work, and Robotjs didn't have a specific error to that simple function. I believe they are not registering correctly when you are either in full screen, have multiple monitors, or a specific size of monitor. Through trial and error I found when I make VSCode smaller and not full screen it will move my mouse to the top left corner, when it's full screen however, nothing happens.
Mine still runs hello word when I do it, Any solution?
@@dracoszn9360 Mine too >.
@@GBIruam May be a bit late of a reply, but make sure you save the code before running it
I can use this for old school runescape?
hey dude u are really cool!
So i know botting is against runescape rules. But would tgis also work on normal rynescape
I get an “Invalid or unexpected token” error in VS when I do the “node index.js” and it brings up a load of stuff, any help?
man's a beast, he has got 1 eye on his camera and 1 on rs while botting... efficient! respect.
douchebag
@@aa898246 you sure are buddy, ya sure are =]
how do I set up automatically set up necessary tools?
I checked the box for additional installs when setting up but I am still getting a bunch of errors.
Is this also the same methode for making osrs bots/scripts?
I like what I see here. What are more possibilities I wonder??
when i type in wood then hit tab it does nothing, when i type it out in full and hit enter it does nothing, any advice with this change directory quesiton?
how come when i go to vs code and try to add "bash" in the terminal shell it doesnt appear?? i have gitbash downloaded and followed everything in this video but it doesnt pop up for me. anyone have any ideas? i tried google and everything but nothing works.
what do i do even though i check the automatic install tools
Is it possible to make a bot that works with blue-stacks?
How far can you get anti ban wise with this framwork? (robotjs)?
I have an issue with the program. I can't use bash, it's stuck on wsl and everytime i tried to install robotjs I get either denied or when i run as admin it tells me "not found ram" "syntax error"
"(expecting "in")
I don't think RobotJS will work running on the Windows Subsystem for Linux because it needs to be able to make calls to the Windows API to do the mouse and keyboard inputs.
My man
Hey, so I installed node js for my Mac Book Air. When I went through the Download Wizard I did not get the option to "Automatically install the necessary tools" that tab just does not come up for me and therefore I am getting the "error". I tried looking through the settings to see if I could change this but found now way. Was wondering if you could go through a step by step and show us how to fix this problem if the Installer Wizard did not give us the option to "Automatically install the necessary tools"
Besides that, your video is great man!
ive tried this to the T of how you typed everything but i get an error message that says something about unable to load from outside of module
when I do cd .\Desktop\woodcutter\ it says cannot find because it does not exist. Any ideas what could be wrong or what i could be doing wrong?
I found the solution while scrolling comments had to type onedrive before desktop
i have the error and dont know how to fix it. where is this install nessecary packages button.
Can anyone help me? I've installed everything correctly but when I go to input the commands to start the moveMouse scipt it doesn't seem to work. Please help.
respect bro gj
I appreciate this tutorial A+++++++++++++++++
Please do a tutorial on like a coin flip in html/css/js/etc or black Jack, jackpot, anything upon those lines PLEASEEEE
how do you use open cv in this game?