Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: JTinkers/ScribeBot
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0.731b
Choose a base ref
...
head repository: JTinkers/ScribeBot
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
  • 17 commits
  • 21 files changed
  • 4 contributors

Commits on Jul 16, 2018

  1. Added bitwise operations

    JTinkers committed Jul 16, 2018
    Copy the full SHA
    2da0ea8 View commit details

Commits on Jul 28, 2018

  1. Improved packages, color class

    - You can now load bitmap as a color 2D table
    - Fixed inability to edit zip packages within ScribeBot
    JTinkers committed Jul 28, 2018
    Copy the full SHA
    6361449 View commit details

Commits on Aug 28, 2018

  1. Update README.md

    JTinkers authored Aug 28, 2018
    Copy the full SHA
    3d75591 View commit details
  2. Fixed ColorContainer

    JTinkers committed Aug 28, 2018
    Copy the full SHA
    134f83c View commit details
  3. Copy the full SHA
    7ced066 View commit details

Commits on Sep 15, 2018

  1. Update README.md

    JTinkers authored Sep 15, 2018
    Copy the full SHA
    a9521d9 View commit details

Commits on Jan 1, 2019

  1. Copy the full SHA
    92d5ddc View commit details
  2. Copy the full SHA
    bfe7775 View commit details

Commits on Apr 7, 2019

  1. Copy the full SHA
    eacb9fe View commit details

Commits on Apr 9, 2019

  1. Copy the full SHA
    a52c4a7 View commit details
  2. Minor changes

    JTinkers committed Apr 9, 2019
    Copy the full SHA
    b95c206 View commit details
  3. Copy the full SHA
    2e36a7c View commit details

Commits on Aug 22, 2019

  1. Release-0.736b

    JTinkers committed Aug 22, 2019
    Copy the full SHA
    c48a436 View commit details

Commits on Apr 20, 2020

  1. Update README.md

    JTinkers authored Apr 20, 2020
    Copy the full SHA
    e3a5a39 View commit details
  2. Added 'getAttribute' method

    JTinkers committed Apr 20, 2020
    Copy the full SHA
    ae15e8f View commit details
  3. Copy the full SHA
    2e36c58 View commit details

Commits on Jun 3, 2020

  1. Update README.md

    JTinkers authored Jun 3, 2020
    Copy the full SHA
    3711c05 View commit details
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -26,8 +26,6 @@ With a little knowledge of Lua, you can automate mundane tasks, create macros or
<img src="https://i.imgur.com/rDgWKLF.png" />
</p>

### Join our discord server if you have questions/suggestions or a cool script to share: <a href=https://discord.gg/nXdGWnQ><img src="https://discordapp.com/assets/fc0b01fe10a0b8c602fb0106d8189d9b.png" width="100"></a>

## Important Notice
This program uses unmanaged code ([msdn topic](https://msdn.microsoft.com/en-us/library/ms973872.aspx#manunman_topic6)) and provides low-level functionality that if used improperly (intentionally or not) could affect system's security and reliability.
It's possible to write a malicious script - it's **highly advised** to open packages with package editor and read code before executing it, especially if it comes from untrusted sources.
@@ -51,9 +49,6 @@ It's possible to write a malicious script - it's **highly advised** to open pack
| screen | Recognize text, capture screen, read screen pixels, manage screens | Tesseract |
| webdriver | Create web automations | Selenium |

## Known bugs and odd-behavior
- None

## Code Examples

You can find a simplistic stopwatch script below.
@@ -150,6 +145,7 @@ Some functions that weren't listed below can be found [here](http://www.moonshar
| `webelement.location` | Get location of the element | - | Point pos |
| `webelement.size` | Get size of the element | - | Size size |
| `webelement.text` | Get text inside the element | - | string text |
| `webelement.getAttribute` | Get value of an attribute | string attribute | string value |

<p align="center">
<i>README last updated with upload of Release-0.73b</i>
5 changes: 3 additions & 2 deletions ScribeBot/Core.cs
Original file line number Diff line number Diff line change
@@ -88,11 +88,12 @@ public static void Initialize()
MainWindow.ShowDialog();
})
{
Name = "Interface Thread"
Name = "Interface Thread",
};
InterfaceThread.SetApartmentState(ApartmentState.STA);
InterfaceThread.Start();

Scripter.Initialize();
Scripter.Initialize();
}

/// <summary>
7 changes: 7 additions & 0 deletions ScribeBot/Data/Packages/ExamplePackage/info.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"Name": "ExamplePackage",
"Description": "Don't turn this into package, just drop to your packages folder!",
"Authors": "JonekCode",
"Contact": "",
"EntryPoint": "main.lua"
}
1 change: 1 addition & 0 deletions ScribeBot/Data/Packages/ExamplePackage/main.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
print("I run fine!")
82 changes: 52 additions & 30 deletions ScribeBot/Engine/Containers/ColorContainer.cs
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MoonSharp.Interpreter;

namespace ScribeBot.Engine.Containers
{
/// <summary>
/// Container structure for System.Drawing.Color
/// </summary>
[MoonSharpUserData]
struct ColorContainer
{
public int R, G, B;

public ColorContainer( int r, int g, int b )
{
R = r;
G = g;
B = b;
}

/// <summary>
/// Override to simplify console output.
/// </summary>
/// <returns>Formatted string.</returns>
public override string ToString() => $"Color[ R = {R}, G = {G}, B = {B} ]";
}
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MoonSharp.Interpreter;

namespace ScribeBot.Engine.Containers
{
/// <summary>
/// Container structure for System.Drawing.Color
/// </summary>
[MoonSharpUserData]
public struct ColorContainer
{
public int R, G, B;

public ColorContainer( int r, int g, int b )
{
R = r;
G = g;
B = b;
}

public static ColorContainer[][] FromBitmap(string path)
{
var bmp = new Bitmap(path);

var colors = new ColorContainer[bmp.Width][];
for (int i = 0; i < bmp.Height; i++)
{
colors[i] = new ColorContainer[bmp.Width];
}

for (int y = 0; y < bmp.Height; y++)
{
for (int x = 0; x < bmp.Width; x++)
{
colors[x][y] = new ColorContainer(bmp.GetPixel(x, y).R, bmp.GetPixel(x, y).G, bmp.GetPixel(x, y).B);
}
}

return colors;
}

/// <summary>
/// Override to simplify console output.
/// </summary>
/// <returns>Formatted string.</returns>
public override string ToString() => $"Color[ R = {R}, G = {G}, B = {B} ]";
}
}
2 changes: 1 addition & 1 deletion ScribeBot/Engine/Containers/PointContainer.cs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ namespace ScribeBot.Engine.Containers
/// Container structure for System.Drawing.Point
/// </summary>
[MoonSharpUserData]
struct PointContainer
public struct PointContainer
{
public int X, Y;

2 changes: 1 addition & 1 deletion ScribeBot/Engine/Containers/SizeContainer.cs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ namespace ScribeBot.Engine.Containers
/// Container structure for System.Drawing.Size
/// </summary>
[MoonSharpUserData]
struct SizeContainer
public struct SizeContainer
{
public int Width, Height;

53 changes: 46 additions & 7 deletions ScribeBot/Engine/Proxies/WebDriverProxy.cs
Original file line number Diff line number Diff line change
@@ -8,6 +8,8 @@
using OpenQA.Selenium.Support.UI;
using OpenQA.Selenium.Interactions;
using MoonSharp.Interpreter;
using System.Reflection;
using System.Text.RegularExpressions;

namespace ScribeBot.Engine.Proxies
{
@@ -75,23 +77,60 @@ static WebDriverProxy()
/// </summary>
public void Close() => Driver.Quit();

private Regex keyPattern = new Regex(@"\{(\w+)\}");

/// <summary>
/// Send key press.
/// </summary>
/// <param name="key">Key to emulate.</param>
public void SendKeyPress(string key) => Driver.Keyboard.PressKey(key);
public void SendKeyPress(string key)
{
if (keyPattern.IsMatch(key))
{
key = keyPattern.Match(key).Groups[1].Value;

var prop = (string)(typeof(Keys).GetField(key).GetValue(null));

Driver.Keyboard.PressKey(prop);
}
else
Driver.Keyboard.PressKey(key);
}

/// <summary>
/// Send key release.
/// </summary>
/// <param name="key">Key to emulate.</param>
public void SendKeyRelease(string key) => Driver.Keyboard.ReleaseKey(key);
public void SendKeyRelease(string key)
{
if (keyPattern.IsMatch(key))
{
key = keyPattern.Match(key).Groups[1].Value;

/// <summary>
/// Send a sequence of key presses and releases.
/// </summary>
/// <param name="keySequence">Sequence of keys to emulate.</param>
public void SendKeys(string keySequence) => Driver.Keyboard.SendKeys(keySequence);
var prop = (string)(typeof(Keys).GetField(key).GetValue(null));

Driver.Keyboard.ReleaseKey(prop);
}
else
Driver.Keyboard.ReleaseKey(key);
}

public void SendKeys(params string[] keys)
{
keys.ToList().ForEach(x =>
{
if (keyPattern.IsMatch(x))
{
var key = keyPattern.Match(x).Groups[1].Value;

var prop = (string)(typeof(Keys).GetField(key).GetValue(null));

Driver.Keyboard.SendKeys(prop);
}
else
Driver.Keyboard.SendKeys(x);
});
}

/// <summary>
/// Find DOM elements on the website.
7 changes: 7 additions & 0 deletions ScribeBot/Engine/Proxies/WebElementProxy.cs
Original file line number Diff line number Diff line change
@@ -172,5 +172,12 @@ public WebElementProxy[] FindElementsByName(string name)

return elems.ToArray();
}

/// <summary>
/// Retrieve value of an attribute.
/// </summary>
/// <param name="attribute">Attribute name</param>
/// <returns></returns>
public object GetAttribute(string attribute) => Element.GetAttribute(attribute);
}
}
31 changes: 31 additions & 0 deletions ScribeBot/Engine/Wrappers/BitWrapper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using MoonSharp.Interpreter;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ScribeBot.Engine.Wrappers
{
[MoonSharpUserData]
class BitWrapper
{
//&
public static int BAnd(int a, int b) => a & b;

//|
public static int BOr(int a, int b) => a | b;

//^
public static int BXor(int a, int b) => a ^ b;

//~
public static int BFlip(int a) => ~a;

//<<
public static int BLShift(int a, int b) => a << b;

//>>
public static int BRShift(int a, int b) => a >> b;
}
}
Loading