Giter Site home page Giter Site logo

mathpathwaysautobot's Introduction

Logo Maths Pathways Auto Completer Bot

Please note this is a proof of concept and I do not intend for it to be used in malicious ways.
This Program utilises Microsoft's Power Automate and is designed to automatically complete Math Pathways Modules.


Contents

Some Context and info

From the first time I used Math Pathways I've been eager to make some sort of tool that automates the proccess of clicking through all the questions for me. I had tried multiple ways including attempting to make a browser extension, nodeJS script, and python script but all of those had some sort of limitation. This is until I came across a tool called Power Automate made by Microsoft. It allows you to automate many things including browsers (via the use of a browser extension added by the program)

How do I do this Myself?

Follow the steps below to set this up for yourself. Some screenshots and videos are provided for your convenience

What you will need

  • A Windows system
  • A Microsoft account (required for Power Automate)
  • Power Automate desktop program
  • Chrome (for easiest setup) or any other browser
  • Math Pathways account
  • Decent experience with Windows and/or Programming

Installing Power Automate

First and foremost, you must install Power Automate from the Microsoft store.

🖼️ Show Image(s)

Power Automate on the Microsoft Store

Once installed you'll need to login with your Microsoft account.
Simply enter the email address associated with your Microsoft Account.

🖼️ Show Image(s)

Power Automate Sign In

Installing browser extension/add-on

For this program to work properly you'll also need the browser extension for your browser of choice

Installing the extension should be quite straightforward

🖼️ Show Image(s)

Chrome Extension

Creating the flow

Now we have everything we need setup, it's time to create the flow!
If you followed the intructions correctly you should be at the Power Automate home/dashboard, simply click "New flow" and then name your flow whatever you wish.

🖼️ Show Image(s)

Power Automate home Name your flow

Adding the code

After creating the flow, you should see a window open that says "You don't have any actions here yet".

🖼️ Show Image(s)

Your flow window

If you're at the right place, you're ready to add the code!
Copy the code below by either selecting it all and pressing CTRL + C / right click > copy OR clicking the copy button located at the top right corner of the code block.

🖼️ Show Image(s)

Copy the code from the code block below

SET MPClass TO $'''https://your-mathpathway-class-URL.com'''
WebAutomation.LaunchChrome.LaunchChrome Url: MPClass WindowState: WebAutomation.BrowserWindowState.Normal ClearCache: False ClearCookies: False WaitForPageToLoadTimeout: 60 Timeout: 60 BrowserInstance=> Browser
WAIT 2
IF (WebAutomation.IfWebPageContains.WebPageDoesNotContainText BrowserInstance: Browser Text: $'''Continue activity''') THEN
    Display.ShowMessageDialog.ShowMessage Title: $'''Login''' Message: $'''Please login then click \"OK\" when done''' Icon: Display.Icon.Information Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> ButtonPressed
END
WebAutomation.GoToWebPage.GoToWebPage BrowserInstance: Browser Url: $'''%MPClass%/work''' WaitForPageToLoadTimeout: 60
WAIT 2
Display.ShowMessageDialog.ShowMessage Title: $'''MP Auto Bot ''' Message: $'''Start the MP Auto Bot by selecting \"OK\". Manually stop this flow to stop the bot''' Icon: Display.Icon.Warning Buttons: Display.Buttons.OK DefaultButton: Display.DefaultButton.Button1 IsTopMost: True ButtonPressed=> runbot
LOOP WHILE ($'''true''') = ($'''true''')
    MouseAndKeyboard.MoveMouseToTextOnScreenWithOCR.WaitForTextToAppearAndMoveMouseToTextOnScreenWithWindowsOcr TextToFind: $'''Check''' IsRegEx: False WindowsOcrLanguage: MouseAndKeyboard.WindowsOcrLanguage.English Occurence: 1 SearchForTextOn: MouseAndKeyboard.SearchTarget.EntireScreen ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 MovementStyle: MouseAndKeyboard.MovementStyle.Instant Timeout: 5 PositionRelativeToText: MouseAndKeyboard.PositionOnImage.MiddleCenter OffsetX: 0 OffsetY: 0 X=> LocationOfTextFoundX Y=> LocationOfTextFoundY Width=> WidthOfTextFound Height=> HeightOfTextFound
    ON ERROR
        GOTO skipclick
    END
    MouseAndKeyboard.SendMouseClick.Click ClickType: MouseAndKeyboard.MouseClickType.LeftClick MillisecondsDelay: 0
    WAIT 1
    LABEL skipclick
    IF (OCR.IfTextOnScreen.TextOnScreenExistsWithWindowsOcr TextToFind: $'''fast''' IsRegex: False WindowsOcrLanguage: OCR.WindowsOcrLanguage.English SearchForTextOn: OCR.SearchTarget.EntireScreen ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 TextLocationX=> LocationOfTextFoundX2 TextLocationY=> LocationOfTextFoundY2) THEN
        WAIT 1
        MouseAndKeyboard.MoveMouseToTextOnScreenWithOCR.WaitForTextToAppearAndMoveMouseToTextOnScreenWithWindowsOcr TextToFind: $'''Continue''' IsRegEx: False WindowsOcrLanguage: MouseAndKeyboard.WindowsOcrLanguage.English Occurence: 1 SearchForTextOn: MouseAndKeyboard.SearchTarget.EntireScreen ImageWidthMultiplier: 1 ImageHeightMultiplier: 1 MovementStyle: MouseAndKeyboard.MovementStyle.Instant Timeout: 5 PositionRelativeToText: MouseAndKeyboard.PositionOnImage.MiddleCenter OffsetX: 0 OffsetY: 0 X=> LocationOfTextFoundX Y=> LocationOfTextFoundY Width=> WidthOfTextFound Height=> HeightOfTextFound
                ON ERROR
                    GOTO skipclick
                END
        MouseAndKeyboard.SendMouseClick.Click ClickType: MouseAndKeyboard.MouseClickType.LeftClick MillisecondsDelay: 0
        WAIT 1
    END
    MouseAndKeyboard.MoveMouseToImage.ClickImage Images: [imgrepo['Image_2']] SearchForImageOn: MouseAndKeyboard.SearchTarget.EntireScreen MousePositionOnImage: MouseAndKeyboard.PositionOnImage.MiddleCenter OffsetX: 0 OffsetY: 0 Tolerance: 10 MovementStyle: MouseAndKeyboard.MovementStyle.Instant Occurence: 1 Timeout: 5 ClickType: MouseAndKeyboard.ClickType.LeftClick SecondsBeforeClick: 0 SearchAlgorithm: MouseAndKeyboard.ImageFinderAlgorithm.Legacy X=> X Y=> Y
    ON ERROR

    END
    WAIT 1
END
DISABLE END

# [ControlRepository][PowerAutomateDesktop]

{
  "ControlRepositorySymbols": [],
  "ImageRepositorySymbol": {
    "Name": "imgrepo",
    "ImportMetadata": {},
    "Repository": "{\r\n  \"Folders\": [],\r\n  \"Images\": [\r\n    {\r\n      \"Id\": \"0c8cf720-9f18-4209-91f6-1572cc1779cf\",\r\n      \"Name\": \"Image_2\",\r\n      \"Screenshot\": \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAANSURBVBhXY2BYPvM/AAQrAkD6JlbeAAAAAElFTkSuQmCC\",\r\n      \"ScreenshotPath\": \"imageRepo-screenshots\\\\\\\\58538345-00a5-4f81-ac27-ddf3cc6367f8.png\"\r\n    }\r\n  ],\r\n  \"Version\": 1\r\n}"
  },
  "ConnectionReferences": []
}

Now we have the code copied, return to the flow you created and paste the code with CTRL + V / right click > paste

🖼️ Show Image(s)

Paste the copied code into flow

ℹ️ Changing/Configuring your code (MORE OPTIONS TO BE ADDED SOON)

There are a few things you might want to change before you run your code.
ℹ️ It is required that you change the URL of your Math Pathways class (the URL which you use to access Math Pathways). At the top of all the code click the three dots on the right of the MPClass varible then click edit and set the URL accordingly.

🖼️ Show Image(s)

three dots of MPClass varible three dots of MPClass varible three dots of MPClass varible

If you know what you are doing you may change any of the code to meet your needs.
ℹ️ Once you've finished making any changes make sure to save your flow!

three dots of MPClass varible

Running the Math Pathways Auto Bot

Congrats! You made it to the fun part.
To run the Bot, click the ▶️ button located next to the save button.

🖼️ Show Image(s)

Run the flow

This will launch a browser window and automaically open the URL you set as your Math Pathways class. If your're not already logged in, a message box will pop up asking you to login.

three dots of MPClass varible

Select your user and enter your password to login, the Bot will not continue until you click "OK" on the message pop up.
When you click "OK" you should be redirected to your-mpclass.com/work and you will get another message pop up which when you are ready to start the Bot click "OK".

three dots of MPClass varible

ℹ️ PLEASE NOTE: If you don't already have a module started, are doing the warm up for the module, or currently have a test, the Bot will not work.
ℹ️ MAKE SURE:

  • If you don't have a module started, start one and complete the warm up if you have one, then you can start the bot
  • If you are still in a warm up for a module, complete the warm up then start the bot
  • If you have a test, stop the bot and complete the test
  • The "Check my answer" and "Complete question" buttons are visible on screen at all times, as the bot uses OCR to find and click the buttons. This also means you may need to manually scroll down at times. (for the best results, maximize the browser window)

Here is a short video of the bot working on a module.

botrunning.mp4

Stopping the Math Pathways Auto Bot

Due to limitations of Power Automate, I couldn't make a way to easily stop the bot from running.
To stop the Math Pathways Auto Bot you'll need to switch back to your Power Automate flow and stop it from there (if the Bot is running try to do this quickly as the program will still try and move your mouse)

🖼️ Show Image(s)

Run the flow

Support and Bugs

If you need some help and/or find any bugs create an issue at https://github.com/BamBoozledMC/MathPathwaysAutoBot/issues and I will get back to you when I can.

FAQ

What if I get the "Whoa! That was fast" pop up?
I have designed the bot to go slow enough so this doesn't happen, however in the case it does, the bot should detect it and close the pop up.

More things will be added here sometime soon

mathpathwaysautobot's People

Contributors

bamboozledmc avatar

Watchers

 avatar

mathpathwaysautobot's Issues

improvement: selenium

i'd reccomend using selenium with python or something which will give you improvements such as:

  • Being able to use your computer while the script is running
  • Being very reliable
  • Can be start and stopped very easily
  • will work on macos and linux
    but still cool concept!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.