• Log in or sign up for an account here: https://www.sythe.org/login

keypress problems

  • Thread starter Thread starter Reximus
  • Start date Start date
R

Reximus

Guest
keypress problems
trying to make a programthat will press up down left and right for random intervals at random intervals

the random interval isnt the problem but holding down the keys for a random time is

only way i know of sending the keys is by using sendkeys
but this doesnt work in random intervals

i tried something like this but it doesnt work:

for num = 1 to rnd ' this is my random number
sendkeys.send("{UP"}
next num

this doesnt have the desired effect
so i was wondering if its possible to use keypress
done some googling and found nothing
can anyone point me in the right direction?
 
keypress problems
very handy for noticing if the button is manually pressed but i want my program to press the button and hold it down, the reference did show me Sendinput but thats just the same effect as sendkeys
(instead of pressing and holding it just presses multiple times)
 
keypress problems
may i ask what this is for?

instead of the program pressing the button you can make a timer that does the same thing the button would do if pressed. so for the timer you can write whatever you would like to happen inside of the timer. lets use a simple messagebox for example, so first you would add a timer and in the timer add the code

Code:
messagebox.show("test")
timer1.interval = textbox1.text * 1000

so the interval of the timer will depend on what number you set for the textbox otherwise if you don't want to use a textbox just put in a number.

then for this next step you can use either a button or getasynckeystate.

for a button all you would do is this, see below:

button1:
Code:
timer1.enabled = true

button2 code:
Code:
timer1.enabled = false

now if you wanted to use getasynckeystate you would first need to declare the getasynckeystate function, see below:

Code:
Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short

you can then make another timer to start up at as the form loads by using the formload property and adding this code, see below:

Code:
timer2.enabled = true

then for the code of timer2 you can say this, see below:

Code:
if getasynckeystate(keys.F1) then
timer1.enabled = true

keep in mind that timer1 is told to open up a messagebox every second.
now to turn off timer one we will go back to the timer2 code and add this, see below:

Code:
if getasynckeystate(keys.F1) then
timer1.enabled = false

if i didn't answer your question maybe try rephrasing it or telling me what you plan on making and i might be able to help you out a little better.
 
keypress problems
ok if you play runescape im trying to make it automatically move the camera for x amount of time in a certain direction (to stop you auto logging out)

getasynckeystate is of no use as that only tells me if i have pressed the button

i need something that will press (and hold) the button down
sending the left key multiple times doesnt work

sending a keydown or something would be great but i cant seem to find anything that is capable of that
 
keypress problems
by using the keydown property of a button you can use sendkeys

Code:
button1_keydown
sendkeys.send = keys.enter
end sub

something like that, i just recently reinstalled windows and haven't had a chance to install visual basic. once i do i'll see what i can do to help you out a little more by maybe making an example project.
 
Runescape Gamblingrunescape gambling
Back
Top