Computer Science Canada

Custom types and Embed Java in Python

Author:  Nathan4102 [ Fri Apr 05, 2013 8:43 am ]
Post subject:  Custom types and Embed Java in Python

Two quick questions:

First, is it possible to create a variable type in python? I'm looking for a type formatted like (x, y) to store co-ordinates that I could call like:

Python:
Point1 = (2, 4)
MoveMouse(Point1.x, Point1.y)

#OR

MoveMouse(Point1[x], Point1[y])

#Preferably not

MoveMouse(Point1[0], Point1[1])


Is this possible?

Second question, I'm working on a Runescape marco'ing client to work on my python skills, but I'm wondering if its even possible to get a Runescape client inside a python GUI. I don't need to be told exactly how to do it, but if someone could tell me what I'd need to do it, or lead me in the right direction, that would be great!

Thanks,
Nathan

Author:  wtd [ Fri Apr 05, 2013 9:45 am ]
Post subject:  RE:Custom types and Embed Java in Python

Tuples are already a part of Python.

code:
>>> type((2,3))
<type 'tuple'>
>>>

Author:  Nathan4102 [ Fri Apr 05, 2013 12:43 pm ]
Post subject:  RE:Custom types and Embed Java in Python

It'll do, but is there any way to address the first number with X and the second with Y like in my example?

Author:  wtd [ Fri Apr 05, 2013 12:48 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Perhaps you should use a dictionary.

Author:  Nathan4102 [ Fri Apr 05, 2013 1:38 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Dictionaries are supposed to be used like constants, non changing, correct? I'd have my points changing constantly. Is there really no way to create a new variable type?

Author:  wtd [ Fri Apr 05, 2013 2:48 pm ]
Post subject:  RE:Custom types and Embed Java in Python

code:
>>> foo = { "x": 42, "y": 27 }
>>> foo["x"]
42
>>> foo["x"] = 3
>>> foo["x"]
3
>>>

Author:  Nathan4102 [ Fri Apr 05, 2013 3:02 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Alright, ill make that work. Thanks!

Author:  Nathan4102 [ Fri Apr 05, 2013 3:22 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Still looking for answers to my second question!

Author:  wtd [ Fri Apr 05, 2013 3:59 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Of course, you could always just make a TwoDimensionalPoint class...

Author:  Nathan4102 [ Fri Apr 05, 2013 4:12 pm ]
Post subject:  RE:Custom types and Embed Java in Python

OOP and classes are new to me, could you explain? Smile

Author:  Cancer Sol [ Fri Apr 05, 2013 5:53 pm ]
Post subject:  Re: Custom types and Embed Java in Python

Even though I'm not sure if it's the right place to ask, but can someone please lead me in the right direction, for Nathan's second question, except, in C++.
It'd be great if someone could just do in Python, idc really, just so that I know what to do Razz

Author:  Nathan4102 [ Fri Apr 05, 2013 6:34 pm ]
Post subject:  RE:Custom types and Embed Java in Python

A browser might work too, as long as it could run a java applet...

Author:  linuxp [ Sat Apr 06, 2013 1:24 am ]
Post subject:  Re: Custom types and Embed Java in Python

class?

code:

class pos:
    def __init__(self,x,y):
        self.x = x
        self.y = y

pa = pos(10,20)
 
move(pa.x,pa.y)

Author:  Tony [ Sat Apr 06, 2013 1:37 am ]
Post subject:  RE:Custom types and Embed Java in Python

@Nathan ? it might help if you explain what you want to do with the Java.

Author:  Nathan4102 [ Sat Apr 06, 2013 8:25 am ]
Post subject:  RE:Custom types and Embed Java in Python

Thanks Linux! And tony, I want only the java applet of runescape in my marcoing client from this site: Runescape.com/game.ws

I've seen other clients do it, so it can't be impossible...

Author:  Zren [ Sat Apr 06, 2013 4:34 pm ]
Post subject:  Re: Custom types and Embed Java in Python

linuxp @ Sat Apr 06, 2013 1:24 am wrote:
class?

code:

class pos:
    def __init__(self,x,y):
        self.x = x
        self.y = y

pa = pos(10,20)
 
move(pa.x,pa.y)


If you're going to go that route (and you don't need any class functions in the class), I recommend using namedtuple. http://docs.python.org/2/library/collections.html#collections.namedtuple

A cool thing with python and tuples is that you can unpack them when assigning.

Python:

p = (10, 20)

# Attempting to assign a tuple to multiple values at once will unpack the sequence into their respective variables.
px, py = p
print px # 10
print py # 20





I'll also copy-paste from the sidebar a response to your other question.

Zren: In nearly every modern browser you can right click a non-plugin web page element (not flash/java) and click Inspect Element. It will show an HTML tree which will probably contain the applet's URL as one of the <applet> tag's attribute values. I'm 99% certain that the applet Javex distributes won't work outside of the official website. If it could, that's just begging to be abused.

Note that relative urls, (Eg: file.ext) while at the page domain.com/folder/ would have the url at domain.com/folder/file.ext.
Also note that Runescape's game page uses an iFrame (a webpage inside a webpage).

Mmmmmm chicken.

Author:  Nathan4102 [ Sat Apr 06, 2013 4:56 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Ooh, named tuples look waay better then that class stuff, I'll use that. Thanks Smile

For the runescape thing, I don't get it! Other bots have runescape running in their client, with none of the other webpage components there. Maybe I'll get it soon, or maybe I could just get it from another bot Wink

Here are two interesting lines I found in the source, not too sure what they mean exactly though...

CODE:
<applet name="runescape" id="game" width="100%" height="100%" alt="For assistance please visit http://services.runescape.com/m=rswiki/en/Technical_Help" archive="gamepackNWlsTOAXf/HLG172Sko0S5rmkaoY9yb7_2950476.jar" code="Rs2Applet.class" mayscript="" title="Java(TM)"><param name="java_arguments" value="-Xmx256m -Xss2m -Dsun.java2d.noddraw=true -XX:CompileThreshold=1500 -Xincgc -XX:+UseConcMarkSweepGC -XX:+UseParNewGC"><param name="image" value="http://www.runescape.com/img/game/splash2.gif"><param name="centerimage" value="true"><param name="separate_jvm" value="true"><param name="boxborder" value="false"><param name="boxbgcolor" value="black"><param name="1" value="false"><param name="25" value="0"><param name="34" value="0"><param name="14" value="31"><param name="29" value="0"><param name="17" value="wwGlrZHF5gJ8wW8HfhfOujindKOAuD9ZZef7rnsbjgA"><param name="18" value="false"><param name="12" value="false"><param name="4" value="1102"><param name="20" value="18716"><param name="6" value="0"><param name="26" value="false"><param name="7" value="NWlsTOAXf/HLG172Sko0S5rmkaoY9yb7"><param name="10" value=""><param name="-1" value="gqM74oPrSY-mQtDoS5pOYA"><param name="15" value="false"><param name="16" value=""><param name="9" value="DAA6C526B37AE38F6C6B5560CFFDB7D9FCF560873E2BDF432CE51F364635C42B9C0CE655B789847BF0480F77536D2145"><param name="31" value="-967523993"><param name="2" value=""><param name="11" value="true"><param name="33" value=""><param name="5" value="0"><param name="0" value="HgemRmgCxHEjA3nirgZyoA"><param name="23" value="true"><param name="28" value=""><param name="35" value="lobby3.runescape.com"><param name="27" value=".runescape.com"><param name="13" value="true,false,0,43,200,18,0,21,354,-15,Verdana,11,0xF4ECE9,candy_bar_middle.gif,candy_bar_back.gif,candy_bar_outline_left.gif,candy_bar_outline_right.gif,candy_bar_outline_top.gif,candy_bar_outline_bottom.gif,loadbar_body_left.gif,loadbar_body_right.gif,loadbar_body_fill.gif,6"><param name="8" value="false"><param name="30" value="0"><param name="24" value="0"><param name="32" value="0"><div class="nojava"><h1>Please Update Java</h1><p>It appears that you do not have Java installed, or your version of Java is out of date. To play this game for free please <a target="_blank" href="http://www.java.com/en/download/index.jsp">click here</a> to download the latest version of Java. Alternatively, <a target="_blank" href="http://www.runescape.com/downloads.ws">click here</a> to get the downloadable version of the game.</p><p>If you have already installed the downloadable version, please look for the <img src="http://www.runescape.com/img/game/rs_icon.gif" alt="RS"> icon on your computer desktop and double-click to play.</p></div></applet>


CODE:

<iframe id="game" src="http://world31.runescape.com/,j0,f214668360795591749" frameborder="0"></iframe>


pacman agrees

Author:  Cancer Sol [ Sat Apr 06, 2013 5:54 pm ]
Post subject:  Re: RE:Custom types and Embed Java in Python

Nathan4102 @ 4/6/2013, 4:56 pm wrote:
Ooh, named tuples look waay better then that class stuff, I'll use that. Thanks Smile

For the runescape thing, I don't get it! Other bots have runescape running in their client, with none of the other webpage components there. Maybe I'll get it soon, or maybe I could just get it from another bot Wink

Here are two interesting lines I found in the source, not too sure what they mean exactly though...

CODE:
<applet name="runescape" id="game" width="100%" height="100%" alt="For assistance please visit http://services.runescape.com/m=rswiki/en/Technical_Help" archive="gamepackNWlsTOAXf/HLG172Sko0S5rmkaoY9yb7_2950476.jar" code="Rs2Applet.class" mayscript="" title="Java(TM)"><param name="java_arguments" value="-Xmx256m -Xss2m -Dsun.java2d.noddraw=true -XX:CompileThreshold=1500 -Xincgc -XX:+UseConcMarkSweepGC -XX:+UseParNewGC"><param name="image" value="http://www.runescape.com/img/game/splash2.gif"><param name="centerimage" value="true"><param name="separate_jvm" value="true"><param name="boxborder" value="false"><param name="boxbgcolor" value="black"><param name="1" value="false"><param name="25" value="0"><param name="34" value="0"><param name="14" value="31"><param name="29" value="0"><param name="17" value="wwGlrZHF5gJ8wW8HfhfOujindKOAuD9ZZef7rnsbjgA"><param name="18" value="false"><param name="12" value="false"><param name="4" value="1102"><param name="20" value="18716"><param name="6" value="0"><param name="26" value="false"><param name="7" value="NWlsTOAXf/HLG172Sko0S5rmkaoY9yb7"><param name="10" value=""><param name="-1" value="gqM74oPrSY-mQtDoS5pOYA"><param name="15" value="false"><param name="16" value=""><param name="9" value="DAA6C526B37AE38F6C6B5560CFFDB7D9FCF560873E2BDF432CE51F364635C42B9C0CE655B789847BF0480F77536D2145"><param name="31" value="-967523993"><param name="2" value=""><param name="11" value="true"><param name="33" value=""><param name="5" value="0"><param name="0" value="HgemRmgCxHEjA3nirgZyoA"><param name="23" value="true"><param name="28" value=""><param name="35" value="lobby3.runescape.com"><param name="27" value=".runescape.com"><param name="13" value="true,false,0,43,200,18,0,21,354,-15,Verdana,11,0xF4ECE9,candy_bar_middle.gif,candy_bar_back.gif,candy_bar_outline_left.gif,candy_bar_outline_right.gif,candy_bar_outline_top.gif,candy_bar_outline_bottom.gif,loadbar_body_left.gif,loadbar_body_right.gif,loadbar_body_fill.gif,6"><param name="8" value="false"><param name="30" value="0"><param name="24" value="0"><param name="32" value="0"><div class="nojava"><h1>Please Update Java</h1><p>It appears that you do not have Java installed, or your version of Java is out of date. To play this game for free please <a target="_blank" href="http://www.java.com/en/download/index.jsp">click here</a> to download the latest version of Java. Alternatively, <a target="_blank" href="http://www.runescape.com/downloads.ws">click here</a> to get the downloadable version of the game.</p><p>If you have already installed the downloadable version, please look for the <img src="http://www.runescape.com/img/game/rs_icon.gif" alt="RS"> icon on your computer desktop and double-click to play.</p></div></applet>


CODE:

<iframe id="game" src="http://world31.runescape.com/,j0,f214668360795591749" frameborder="0"></iframe>


pacman agrees

Maybe, we could the first code, and create the applet ourselves. Idk, I have no idea how to do this :/

Author:  Nathan4102 [ Sun Apr 07, 2013 11:38 am ]
Post subject:  RE:Custom types and Embed Java in Python

I think im gonna post-pone this project for now, I'd need to learn some HTML and Java it looks like in order to understand how to get runescape in a python client. And even after that, I'd need to figure out how to create and control a virtual mouse and keyboard inside the client...

I've always wanted to make a mario like game... I guess I'll do that next! :p

Author:  Cancer Sol [ Sun Apr 07, 2013 12:17 pm ]
Post subject:  Re: Custom types and Embed Java in Python

Haha, good luck then!
I was just thinking of the same thing, like I have to learn some HTML to understand it first, and maybe some java.
I don't think I'm going to make it for quite awhile Razz

For your free pascal bot, you ran it through a browser right?
Did it have a virtual mouse? And also, can the bot still run if you have a virtual mouse, like will it detect pixels properly?

Author:  Nathan4102 [ Sun Apr 07, 2013 12:20 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Mine just ran out of an IDE into a browser, I had no fancy virtual mouse or client stuff. And bots with virtual mouses do work, powerbot is an example.

Author:  Cancer Sol [ Sun Apr 07, 2013 12:29 pm ]
Post subject:  Re: RE:Custom types and Embed Java in Python

Nathan4102 @ 4/7/2013, 12:20 pm wrote:
Mine just ran out of an IDE into a browser, I had no fancy virtual mouse or client stuff. And bots with virtual mouses do work, powerbot is an example.

But then, isn't powerbot memory-based? That's so complicated, and it can get you banned easier I think >.<

What do you mean by it ran out of an IDE into a browser?
The user would run the script from an ide and it would open their default browser?

Author:  Nathan4102 [ Sun Apr 07, 2013 12:31 pm ]
Post subject:  RE:Custom types and Embed Java in Python

I don't really know much about injection bots :/

And the user would open runescape in a browser, set safe mode, open the IDE, and run the script. The IDE would then minimize and start clicking on the browser.

Author:  Cancer Sol [ Sun Apr 07, 2013 12:33 pm ]
Post subject:  Re: RE:Custom types and Embed Java in Python

Nathan4102 @ 4/7/2013, 12:31 pm wrote:
I don't really know much about injection bots :/

And the user would open runescape in a browser, set safe mode, open the IDE, and run the script. The IDE would then minimize and start clicking on the browser.


Oh, I see. But what about those paid bots you made? Did you just make an .exe for them?
And for safe mode, I'm kinda confused. It's not the safe mode thingy for when you boot your os right?

Author:  Nathan4102 [ Sun Apr 07, 2013 12:35 pm ]
Post subject:  RE:Custom types and Embed Java in Python

I just sold a text file with the code, which isn't really secure since it could easily be leaked, but thats all I could do at the time :p

RS safe mode is different then OS safe mode. RS safe mode is a graphics setting which just sets all settings to minimum. It makes botting a lot easier since less things move around, and everything looks simpler.

Author:  Cancer Sol [ Mon Apr 08, 2013 10:52 pm ]
Post subject:  RE:Custom types and Embed Java in Python

I could've sworn I made a post already.. but,
How much did you sell it for and where?

How does the IDE open a text file?
Maybe I should try that with Code::Blocks to see
if it can do that Razz
But do you think anyone will buy a shitty runescape bot as an exe file?

Author:  Nathan4102 [ Tue Apr 09, 2013 8:25 am ]
Post subject:  RE:Custom types and Embed Java in Python

Prices ranged from $1 - $100 for a copy, and I think any IDE will open a .txt. I don't think anyone would buy a .exe from a guy with no sales, it's kind of sketchy Wink

Author:  Cancer Sol [ Tue Apr 09, 2013 3:45 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Haha, alright. I can't believe it how people would still buy a bot that can't do random events that well xD

Author:  Nathan4102 [ Tue Apr 09, 2013 3:58 pm ]
Post subject:  RE:Custom types and Embed Java in Python

Yeah, that was definetly a downfall. A lot of them worked in places where you can't get randoms, like soul wars.


: