Mr. Wagner ?

G

Guest

how can i set up vb.net to interact with a game i'm playing online ? the game
is a java applet. i'm trying to write a program using a winform to assist me
with this game.i tried using sendkeys but wouldn't work.i need to have the
program automatically click a button for me in the game every few seconds or
so.how would i do this ? api call or method from class library ?what class
would handle the mouse? thanks for any help with this.
 
A

alejandro lapeyre

Maybe a win32 mouse hook may help you.

Or you may devise a device controlled by the serial or paralell port
(preferably the first, because you can program it with .NET) to knock the
key or button.

With the mouse hooks you may modify and mouse events and (i think) simulate
mouse click events. But I dont know if the mouse hooks work if that game is
using DirectX.

:)
Alejandro Lapeyre
 
H

Herfried K. Wagner [MVP]

alejandro lapeyre said:
With the mouse hooks you may modify and mouse events and (i think)
simulate mouse click events. But I dont know if the mouse hooks work if
that game is using DirectX.

I doubt that a Java applet will use DirectX. P/invoke on 'SendInput'
('keybd_event', 'mouse_event') could be used to "interact" with the applet
programmatically, but I doubt that this would lead to a stable solution.
 
G

Guest

say that i keep the mouse cursor over the button that i want to have
clicked.is there a way to program the mouse to perform a click at the
coordinates where the cursor is resting after a few seconds or so and be able
to do this over and over again? i would put start and stop buttons on my
winform to handle this.thanks.
 
N

Nak

Hi aam,
say that i keep the mouse cursor over the button that i want to have
clicked.is there a way to program the mouse to perform a click at the
coordinates where the cursor is resting after a few seconds or so and be
able
to do this over and over again? i would put start and stop buttons on my
winform to handle this.thanks.

There is almost always a way to do something. Maybe you might need to
look for or create a C DLL that is capable of performing mouse actions, as
technically the directX games still use windows. Maybe there is one already
available? And shouldn't it work via sending windows messages??

Nick.
 
G

Guest

i don't believe the game uses directX. also, what is a "C" dll ? i'm not too
familiar with Windows API, could you recommend a good book on the subject ?
thanks.
 
H

Herfried K. Wagner [MVP]

Nak said:
Woo, so your gonna post even more help then? faster than ever huh?

My old computer had 350 MHz, my new computer has 3.0 GHz. So, I hope I'll
have much more freetime in future (and I won't spend this additional time on
writing newsgroup posts!).
 
H

Herfried K. Wagner [MVP]

aam said:
say that i keep the mouse cursor over the button that i want to have
clicked.is there a way to program the mouse to perform a click at the
coordinates where the cursor is resting after a few seconds or so and be
able
to do this over and over again?

Yes, using 'mouse_event'. As I already said:

| P/invoke on 'SendInput' ('keybd_event', 'mouse_event')
| could be used to "interact" with the applet programmatically

Perform a Google Search on these functions and take a look at their
documentation :).
 
N

Nak

Hi Herfried,
My old computer had 350 MHz, my new computer has 3.0 GHz. So, I hope I'll
have much more freetime in future (and I won't spend this additional time
on writing newsgroup posts!).

Cool, it must seem like a completely different world!

So your gonna spend your extra time downloading "poontang"? ;-) j/k

Nice spec PC BTW, I bet that hard drives fast!

Nick.
 
N

Nak

Hi there,
i don't believe the game uses directX. also, what is a "C" dll ?

A "C" Dll would be a DLL written in the C language. As C is much lower
level than .NET you can do lots more things, but it does require allot more
effort. I was thinking that maybe there was a DLL knocking around somehwere
that enables control over the mouse, and as it is something that should have
been around for quite a long time I would have presumed "C" to be the
language of choice.

But as Herfried said you can actually do this using "mouse_event" API.

http://www.mentalis.org/apilist/mouse_event.shtml

The declare on this page would have to be modified to work in VB.NET so
maybe look up "mouse_event VB.NET" on Google, your sure to find something.
could you recommend a good book on the subject ?

A good book on C? I would recommend just looking on the net for basic
"Hello world" tutorials first. I'm not sure if your aware of this but C is
one of the most common languages, programs are written for many systems
using the language.

http://www.cs.cf.ac.uk/Dave/C/node4.html#SECTION00400000000000000000

It's a good language to learn and a valuable skill to have. You're not
going to be able to use VB.NET to write low level code and never will, as
that's what .NET is all about. But then again you might never have the need
to anyway!

http://www.autohotkey.com/

^ You might want to check that out, I found it after doing a quick
search on Google.

Nick.
 
G

Guest

thanks nick for your help. is that c++ or c sharp ?i thought that with vb.net
win api calls were no longer necessary because of the better functionality
of the .net class libraries ?also, i have a program similar to the one that
you referenced that i downloaded a long time ago. i'm basically trying to
figure out how it works so i can write my own. thanks again.
 
G

Guest

thanks herfried for your help. i will read up on this.i never imagined a
simple program like this would be so hard to figure out how to write !!
 
N

Nak

Hi amm,
thanks nick for your help. is that c++ or c sharp ?

Nerither, "C", "C++" is the successor to C. The following URL will tell
you a little about the history of "C++"

http://www.hitmill.com/programming/cpp/cppHistory.asp

C# on the other hand requires the .NET Framework and as such will only
run on the system it is designed for. Although several companies are making
cross platform versions of the .NET Framework, such as the Mono project.
i thought that with vb.net
win api calls were no longer necessary because of the better
functionality
of the .net class libraries ?also, i have a program similar to the one
that
you referenced that i downloaded a long time ago. i'm basically trying to
figure out how it works so i can write my own. thanks again.

.NET is probably the highest level platform you will find, it's designed
to provide a common interace for all languages that utilise the framework.
There are *lots* of things you cannot do with a .NET application and there
are allot of downsides to using .NET in the first place, such as

* Framework deployment (Huge and confusing)
* Framework detection
* Extremely unsecure code unless using an obfuscator (which costs
money)
* Restrictive development suites (At the moment there aren't many
available and those that are at a production level are relatively expensive,
SharpDevelop is the only free IDE available and still has a way to go yet)

I knew a programmer once that stated that he could use any programming
language there is because he could develop in assembler, which is about as
low-level as it gets. Saying this it meant that he had an *extremely* good
understanding of the way the computer hardware worked, a level of
understanding that you would just not get from learning solely high level
languages.

The lower level you go the less the program has the be transformed in
order for the processor to actually be able to understand it, therefor low
level code is also extremely fast, but has so disadvantages, such as
security and safety, hardware can actually be *damaged* if you don't know
what your doing.

I think if you are learning how to program you should start with "C",
then go to "C++", then go to VB.NET or C# (C# would be the logical choice
but I prefer VB.NET ;-) ). You don't have to have a huge understanding of
these languages but it does help you to understand what is actually
happening with your code, being able to make software is all very well but
being able to explain what is actually happening is another.

Anyway, it's just my opinion on programming, and you never know when you
will need the extra knowledge. Ultimately I think the best way to learn is
by example, download examples, rip them apart and make your own versions (as
you said you are doing at the moment). But good luck in whatever you choose
to do! :)

Nick.
 
C

Cor Ligthert

Nick,
The lower level you go the less the program has the be transformed in
order for the processor to actually be able to understand it, therefor low
level code is also extremely fast,

This is in my opinion a mythe and low level programming is not difficult
however time consuming.

To give you an example, and than I hope that you see what I mean why it is a
mythe

In past there where computers which had an accumulator of 8 bits (there
where much larger as well, however this one is good for the sample).

What had to be done
Add decimal 3 did mean that you first had to translate it to the bit value
11. When you had done that, you could add 11 to the accumulator let us think
that this was already holding 01111111. That would give an overflow that you
had to catch and to add to the next accumulator.

You see a lot of work, and therefore there where made procedures. And more
procedures. They became in hardware and in software. The software ones are
in my opinion nothing more than a low level Intermidiate Code.

The only point with Net is that by instance the API has now an extra level
above it what is the Net Intermidiate.

However it does not mean that that is slower. It is fast enough, to say as
an famous English car builder tells about the horsepower of his engines.

I hope this gives some ideas, when you knew this already, than forget it.

Cor
 
N

Nak

Hi aam,

The following is an example of a "C" program that will move the cursor
around and then click the start button. It's hard coded to a screensize of
1280 x 1024 so you might need to adjust it. I wont post the binary in here
to prevent being moaned at...

--------------

#include <Windows.h>
#include <Winuser.h>

int main()
{
int cbuttons;
int dwExtraInfo;

printf("Moving to top left...\n");
SetCursorPos(0, 0);

sleep(2000);

printf("Moving to top right...\n");
SetCursorPos(1280, 0);

sleep(2000);

printf("Moving to bottom right...\n");
SetCursorPos(1280, 1024);

sleep(2000);

printf("Moving to start button...\n");
SetCursorPos(10, 1014);

sleep(2000);

printf("Clicking start button...\n");
mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, cbuttons, dwExtraInfo);
mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, cbuttons, dwExtraInfo);

printf("Press any key to exit.\n");
getch();

return(0);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top