Jump to content


Photo

When you press space it sends space quickly


  • Please log in to reply
9 replies to this topic

#1 iurimattos

iurimattos
  • Members
  • 6 posts

Posted 16 July 2012 - 02:39 AM

Hello, I'm trying to make a program that does the following:

When I press the "Space" it sends "space" several times
and when I stop pressing the "Space" it stops

I managed to do but is not the way I want

x::
if (spacepressed)
Loop 9999{
  Send, {space up}
  Send, {space down}
}
else
!spacepressed                                                                     

sorry my bad english. ;s

#2 dylan904

dylan904
  • Members
  • 706 posts

Posted 16 July 2012 - 03:14 AM

You should google AutoHotkey While-Loop.
Here your code is much more efficient like so.

If you insist on using x alongside the use of space to initiate the sequence, then you would use this...
x & Space::
While GetKeyState("Space", "P")
{
	Send {Space}
	Sleep, 80
}
Return

Otherwise, try this out...
$Space::
While GetKeyState("Space", "P")
{
	Send {Space}
	Sleep, 80
}
Return


#3 MasterFocus

MasterFocus
  • Moderators
  • 4132 posts

Posted 16 July 2012 - 05:09 AM

Related: :arrow: The definitive autofire thread!

#4 iurimattos

iurimattos
  • Members
  • 6 posts

Posted 19 July 2012 - 09:03 PM

I tried and did not work. I need to space key is sent repeatedly.
something like this:

$Space::
While GetKeyState("Space", "P")
{
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
	Send {Space}
        ... repeatedly
}
Return   

Another thing, I can not use the space as a variable "$Space" for the space it is impossible to be pressed.

#5 dylan904

dylan904
  • Members
  • 706 posts

Posted 19 July 2012 - 09:16 PM

Did you even try the code i pasted?
While is a loop. So as long as you are holding space down, it sends the Space key 12.5 times per second.

#6 iurimattos

iurimattos
  • Members
  • 6 posts

Posted 19 July 2012 - 10:39 PM

Did you even try the code i pasted?
While is a loop. So as long as you are holding space down, it sends the Space key 12.5 times per second.


to send space is necessary send space in two ways do not know.

Send, {space up}
Send, {space down}

Only works well and your code did not work

I made a code that works:
Pause
Loop{
  Send, {space up}
  Send, {space down}
  sleep 10
}
F8::Pause

but I can not do the following modification:
when I press space active function
when I not press space stop function
understand?

#7 Ohnitiel

Ohnitiel
  • Members
  • 664 posts

Posted 20 July 2012 - 12:19 AM

dylan904 code works fine... Probably the game that is not accepting the virtual input. Try with the other send methods as well with controlsend.

#8 dylan904

dylan904
  • Members
  • 706 posts

Posted 20 July 2012 - 01:15 AM

If only the physical keys work for you, you could try this out...
$Space::

While GetKeyState("Space", "P")

{

   Send {Space Up}

   Sleep, 40

   Send {Space Down}

   Sleep 40

}

Return


#9 iurimattos

iurimattos
  • Members
  • 6 posts

Posted 02 August 2012 - 02:52 AM

If only the physical keys work for you, you could try this out...

$Space::
While GetKeyState("Space", "P")
{
   Send {Space Up}
   Sleep, 40
   Send {Space Down}
   Sleep 40
}
Return



this code works good. Just one detail:
When I stop pressing the spacebar the script should be paused.
is possible?

#10 dylan904

dylan904
  • Members
  • 706 posts

Posted 02 August 2012 - 06:20 PM

$Space::

Pause, Off

While GetKeyState("Space", "P")

{

   Send {Space Up}

   Sleep, 40

   Send {Space Down}

   Sleep 40

}

Pause, On

Return