auto mouse click

G

Guest

hi, im trying to figure out how i can program the mouse to automatically
click on a button of a web page that i'm viewing.i do not have control over
the page.i would also like to set up an adjustable timer with it where the
mouse can be set to click every so many seconds (1-10).i'm having trouble
figuring out how to do and code this.thanks for any help.
 
H

Herfried K. Wagner [MVP]

aam said:
hi, im trying to figure out how i can program the mouse to automatically
click on a button of a web page that i'm viewing.

Please stay in the original thread in future.
 
L

Lucas Tam

hi, im trying to figure out how i can program the mouse to
automatically click on a button of a web page that i'm viewing.i do
not have control over the page.i would also like to set up an
adjustable timer with it where the mouse can be set to click every so
many seconds (1-10).i'm having trouble figuring out how to do and code
this.thanks for any help.

Take a look at Microsoft' Web Browser Control:

http://msdn.microsoft.com/library/default.asp?
url=/workshop/browser/prog_browser_node_entry.asp

Or possibly you can use SendKeys... or Windows API's SendMessage command.
 
G

Guest

basically what i am trying to do is create a program that will play a slot
machine game automatically by having the mouse click the button on the slot
machine to spin the reels.and i would like to set up a timer so i can set the
amount of seconds before each click. it's for a free online slot machine
game.thanks.
 
S

Scott Swigart

Fun. Ok.

Say, for example, that you want to play this one:

http://www.freeslots.com/Slot508.htm?a=1

I made a little app with a timer and button, and the following code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Timer1.Enabled = True
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
SendKeys.Send("{ENTER}")
End Sub

Fire this up. Then switch over to the web slot machine, and click the
buttons to get it going the first time. (Play 9 lines, spin reels)

Then click the button on your app, and it will start sending the Enter key
to whatever the active window is. Switch back over to the web browser, and
just wait. You're VB app will start hitting enter on the "spin reels"
button.
 
G

Guest

thanks scott but i tried the code and ran it on the site you linked and it
wouldn't work.it wouldn't send the keypress and i coded it right and followed
the instructions.thanks for your help.
 
L

Lucas Tam

thanks scott but i tried the code and ran it on the site you linked
and it wouldn't work.it wouldn't send the keypress and i coded it
right and followed the instructions.thanks for your help.

Does the applet you're trying to send the key to take the Enter key as a
spin button?

Basically Send Keys is a bad choice... because the input requirements are
quite strict or else the keys would be ignored (as you saw).
 
C

Cor Ligthert

Aam,

Be so kind as Herfried wrote already to stay in the same thread. I was
already expecting you where talking about a webpage however was not sure,
so tell that forever next time when you visit this newsgroup. Default here
is a winform.

Beneath I give you a sample how you can do you problem (I don't know if
there are better ones, it is just a sample).

\\\Neets a label on a webform
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Label1.Text = ("1")
Else
Label1.Text = (CInt(Label1.Text) + 1).ToString
End If
Dim scriptString As String = "<script language=JavaScript>" & _
"setTimeout(""" & _
Page.GetPostBackEventReference(Me) & _
""",1000)</script>"
Page.RegisterStartupScript("setPBTimer", scriptString)
End Sub
///

I hope this helps a little bit?

Cor
 
G

Guest

thank you cor for the help.i will try this out.what does the line \\\needs a
label on a webform do ?also, where do you enter this code in at ? under the
button1 click procedure or at the top of the windows forms designer page?
thanks.
 
C

Cor Ligthert

Aam,

There is no button click, the setTimeout in that javascript does the
automatic send back every second in this case. That 1000 means one second.

To do this sample, you create a new aspnet project, drag a label on your
form and click right and choose "view code".

Than delete the load event what there is, and paste this code in.

This is a sample to show you how you let that post back fire. Know that the
load event will forever fire on a postback, whatever control or procedure
like this did that. Maybe you need something to know that it is this
javascript which did the postback. However try this first to get an idea
about webhandling and client and serverside.

I hope this helps?

Cor
 
G

Guest

thanks cor i will try this. do you need to have IIS and frontpage 2000 server
extensions installed to create this asp project ?
 
G

Guest

thanks cor. what i meant was is there a way to write this program as a
windows app instead of an asp.net web app ?
 
C

Cor Ligthert

Aam,
thanks cor. what i meant was is there a way to write this program as a
windows app instead of an asp.net web app ?

I don't know why not?

Or do you mean on the internet for not known customers?

Cor
 
G

Guest

cor, i would like to create this program as a win app instead of an asp app
if possible. how would i use your code example in a win app? thanks.
 
C

Cor Ligthert

Aam,

You give me to few information to answer you, every program that can be done
as webform can be done as winform, with the exception that it cannot be used
on the world wide web for unknown clients.

This is not for in the oposite direction. Not every winform application is
to create as a webform.

Mostly it is easier to make it as a windows form (win app).

However as I said I have to few information to give more concrete answers.
My first question is do you Visual Studio Net or (the mini version Visual
Basic Net).

I hope this gives an idea.

Cor
 
G

Guest

cor, i use visual basic.net 2003. i'm new and i'm trying to teach myself. i
wanted to create a windows app that would play a web-based slot machine game
automatically by simulating a mouse click on the button to spin the reels of
the slot machine for me. i want to set up a timer so i can choose the amount
of seconds between each mouse click.i thought it would be a fun program to
try and write.i will have 3 buttons on my winform. a button to stop, a button
to start the automatic clicking, and maybe a radio button where you can
choose to have it click once every 1,5 or 10 seconds.this program is alot
harder than i thought.i tried using sendkeys already but the game won't
recognize the"enter" key for the button.like i said i want to create a win
app to play this web-based free slot machine game. i do not have IIS or
frontpage 2000 server extensions installed. thanks for all the help cor.
 

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