[Help] Sleep Function

Posts 115 of 23 · Page 1 of 2
[Help] Sleep Function[SOLVED]
I have a bit of an issue... I have a sendkeys function that is running WAY to fast.

I just need a little bit of time between the keystrokes(Basically a wait time)

Example:
Code:
        SendKeys.Send("1")
        SendKeys.Send("2")
        SendKeys.Send("3")
        SendKeys.Send("4")
What I kind of want is:
Code:
        SendKeys.Send("1")
Wait 100
        SendKeys.Send("2")
Wait 100
        SendKeys.Send("3")
Wait 100
        SendKeys.Send("4")
Wait 100


So that there is a wait time of 100
What you need is:
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

SendKeys.Send("1")
sleep(100)
SendKeys.Send("2")
sleep(100)
etc. for all of them.
Quote Originally Posted by Shark23 View Post
What you need is:
Code:
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

SendKeys.Send("1")
sleep(100)
SendKeys.Send("2")
sleep(100)
etc. for all of them.
I did some googling, seen this and ignored it... I was reading something else when I ran across this...

Thanks for fast response and the help!

~~Edit



Get an error... Not sure how to solve it...

I know the rule: Long's turn to Integer's.. I tried that, got the same error.

~~Edit 2

Solved already, not sure HOW I just moved the code to a different spot, I must have had it chained together with a different sub.

Sorry for it

~~Edit 3

That part was resolved, but NOWWWWW I'm having a lag issue...When I start the program, it will do the first sendkey and then it will just lag out, eventually closing
Code:
    Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Integer)
    Private Sub farm_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles farm.Tick

        SendKeys.Send("1")
        Sleep(1000)
        SendKeys.Send("2")
        Sleep(1000)
        SendKeys.Send("3")
        Sleep(1000)
        SendKeys.Send("4")
        Sleep(1000)
    End Sub
Quote Originally Posted by Alroundeath View Post


I did some googling, seen this and ignored it... I was reading something else when I ran across this...

Thanks for fast response and the help!



~~Edit



Get an error... Not sure how to solve it...

I know the rule: Long's turn to Integer's.. I tried that, got the same error.
lol... probably put it in the wrong section of the code.....

do you have it under Public Class Form1
Quote Originally Posted by Alroundeath View Post
I have a bit of an issue... I have a sendkeys function that is running WAY to fast.

I just need a little bit of time between the keystrokes(Basically a wait time)

Example:
Code:
        SendKeys.Send("1")
        SendKeys.Send("2")
        SendKeys.Send("3")
        SendKeys.Send("4")
What I kind of want is:
Code:
        SendKeys.Send("1")
Wait 100
        SendKeys.Send("2")
Wait 100
        SendKeys.Send("3")
Wait 100
        SendKeys.Send("4")
Wait 100


So that there is a wait time of 100
If you want to use the w8 function you have to call it. im not giving the code lol (only because i cant find it in my code notepad)

But if u want to use sleep use
Code:
system.threading.thread.sleep(100)
it might be thread.threading i got that off the top of my head
Quote Originally Posted by MvRouC12 View Post
lol... probably put it in the wrong section of the code.....

do you have it under Public Class Form1
Quote Originally Posted by trevor206 View Post
If you want to use the w8 function you have to call it. im not giving the code lol (only because i cant find it in my code notepad)

But if u want to use sleep use
Code:
system.threading.thread.sleep(100)
it might be thread.threading i got that off the top of my head
Both of these issues have been solved already =p

The bottom part of my thread is the only issue at the moment =/
Quote Originally Posted by Alroundeath View Post




Both of these issues have been solved already =p

The bottom part of my thread is the only issue at the moment =/
so the wait time is ur problem?
Quote Originally Posted by trevor206 View Post
so the wait time is ur problem?
No, the fact that it lags out after the very first keystroke.

If you have time to get on TeamViewer, that would be extremely helpful ;o

Please keep in mind, this is my first application ;o
Quote Originally Posted by Alroundeath View Post


No, the fact that it lags out after the very first keystroke.

If you have time to get on TeamViewer, that would be extremely helpful ;o

Please keep in mind, this is my first application ;o
What exactly are u trying to make your program do, might i ask.
CrossFire farming tool. It switches weapons based on keystrokes, 1-2-3-4

Switching weapons prevents the character from timing out due to being idle.
Quote Originally Posted by Alroundeath View Post
CrossFire farming tool. It switches weapons based on keystrokes, 1-2-3-4

Switching weapons prevents the character from timing out due to being idle.
Just asking but why don't you just have it on a timer and set the timers to different times. instead of w8 and sleep.(to me its simpler but idk i never tried to make a "farming tool" for CF.
Quote Originally Posted by trevor206 View Post
Just asking but why don't you just have it on a timer and set the timers to different times. instead of w8 and sleep.(to me its simpler but idk i never tried to make a "farming tool" for CF.
Have each SendKey function on a seperate timer?

Hmm... Sounds like a pretty decent idea. That would be alot of extra timers though

I'll try that and then I'll post again ;o

Actually, I think I'll just make it press 1 button, it doesn't have to necessarily look good, it just has to keep it from idling out.
Quote Originally Posted by Alroundeath View Post


Have each SendKey function on a seperate timer?

Hmm... Sounds like a pretty decent idea. That would be alot of extra timers though

I'll try that and then I'll post again ;o

Actually, I think I'll just make it press 1 button, it doesn't have to necessarily look good, it just has to keep it from idling out.
well no not in theory have the timers run of each other so make 2 timers and when timer 1 stops doing what its doing have timer 2 start. and so on
EX
timer 1
Code:
sendkeys.send w/e 
timer2.start
timer 2
Code:
timer1.stop
sendkeys.send w/e

timer1.start
timer2.stop
im 80% sure this should work because i dont have vb open im just getting this out of my head.
Yeah, that should work. It was lagging out for me too. Wonder what's up with it.
^ That works but there isn't any delay.
Posts 115 of 23 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?