Run Script Again When Press a Button Ahk

  • Members
  • 54 posts
  • Terminal active: Oct 17 2015 12:41 PM
  • Joined: 21 October 2009

I have a pocket-sized script that is non performance as intended.

I wish to restart the entire script if the central is pressed again.
Currently if I press the Space button twice. It runs the entire script which requires some time before information technology allows me to press the Space push Once more.

KeyWait, Infinite, T0.00
SendInput {Infinite Down}
Sleep, 73
SendInput {Space Up}

KeyWait, Infinite
SendInput {j Down}
Slumber, 700
SendInput {j Up}

Earlier letting me press "Space" again.

I would like any infinite button input during this script to restart it.

{ 	 KeyWait, Space, T0.00 	SendInput {Space Downwards} Sleep, 73 SendInput {Infinite Up} Loop 	{ 	 	 if GetKeyState("infinite", "P")  	{ 	 SendInput {Space Down} Sleep, 93 SendInput {Space Upwardly}{south Down} 		Sleep, 73	 		SendInput {s Up}{MButton Upward}     SetTimer,Label1,-20    Slumber, 40    }   		else 		suspension 		 		} 			   KeyWait, Space    	SendInput {j Downward} 		Sleep, 700 		SendInput {j Upwardly} 		 	 }            

[/lawmaking]

  • Dorsum to top

sqlninja01

  • Members
  • 54 posts
  • Last active: Oct 17 2015 12:41 PM
  • Joined: 21 October 2009

I'k trying to have the controller go into a loop if I concur the infinite, and then leave loop on space key-up and ship the "J" key.

Here is some more clarity on my request

1.First Send Infinite (If I apace printing space w/o property it down- no loop)
2.If held Then Go into a loop of pressing space real fast.
3.Press a Buffer Key "J" after executing infinite loop.

I've tried several prefix(s) to no avail. I've read documentation on their meaning, tried again and again, and the * provides the best fit.

Here is one large question:
Why doesn't the ~ prefix doesn't appear to allow me to send an Upwardly control.

Take a await at this code and let me know whats wrong and mayhap this may aid me:

I rewrote the code so you can simply run it in NOTEPAD and actually see the divergence:
In Notepad you lot should see that this when holding the space.

OUTPUT:

a .............................. a ................... a ......................(Space Upward is not working)

(This shows Infinite is being HELD DOWN FOR A LONG Fourth dimension regardless of send input Space Up At that place is no suspension

~space:: Loop     {    if GetKeyState("space", "P")    {           SendInput {infinite Up}       Sleep, 300       SendInput {a Downward}       Sleep,30       SendInput {a Up}    }             else       pause       } Return            

This is more than in line with what I desire:
It displays" a a a a a
Yet the problem that arises in this is that if you press space again. It waits until the entire script is finished, i.east. 300 seconds. You can imagine this causes a problem when trying to evade, when you lot have to wait to press the evade again.

Try pressing space right subsequently releasing space. I demand this to register sometime.
[code=automobile:0]

*infinite::
Loop
{
if GetKeyState("space", "P")
{
SendInput {space Down}
Sleep, 40
SendInput {infinite Up}
Slumber, 300
SendInput {a Down}
Sleep,30
SendInput {a Up}
}
else

  • Dorsum to summit

jethrow

  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

Well, holding space down will keep sending it - similar to a loop. As far as sending "J" when space is released, how about:

space up:: Send, J

  • Back to tiptop

sqlninja01

  • Members
  • 54 posts
  • Last active: Oct 17 2015 12:41 PM
  • Joined: 21 October 2009

Well, property infinite down will proceed sending information technology - similar to a loop. Every bit far as sending "J" when space is released, how near:

space upwards:: Ship, J

Is in that location any way to ignore keystrokes for like 200ms while space is being held? (USING ~ modifier)

Or is there a way to let infinite restart a running script? even mid script?

  • Back to top

jethrow

  • Moderators
  • 2854 posts
  • Last active: May 17 2017 01:57 AM
  • Joined: 24 May 2009

Is there whatever way to ignore keystrokes for like 200ms while space is being held? (USING ~ modifier)

Not sure what you mean past this - particularly "(USING ~ modifier)". I suppose you could brand everyother key a hotkey, and make them all look 200 ms before sending the key if space is pressed.

Or is there a mode to let space restart a running script? fifty-fifty mid script?

You could always use:

space:: Reload

Still, and then property space will simply keep reloading the script.

  • Dorsum to top

sqlninja01

  • Members
  • 54 posts
  • Last active: Oct 17 2015 12:41 PM
  • Joined: 21 October 2009

[quote name="sqlninja01"]Or is there a way to let space restart a running script? fifty-fifty mid script?[/quote]You could always use:

infinite:: Reload

Nevertheless, and so holding space will just keep reloading the script.[/quote]

Ok let me rephrase.
Is there any way to let space restart a running "Hotkey"

  • Back to height

dingleraccamented.blogspot.com

Source: https://www.autohotkey.com/board/topic/48400-how-can-you-break-a-hotkey-code-when-a-button-is-pressed/

0 Response to "Run Script Again When Press a Button Ahk"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel