Jump to content

Recommended Posts

Posted

Hi dudes.

I have a problem with my script.

#include <Misc.au3>

If _IsPressed('11') Then
    $i=0
    While $i = 2
        Send("{SPACE down}")
        sleep (300)
        Send("{Space up}")
        $i = $i + 1
    WEnd
EndIf

I want that when I press ctrl, space is pressed twice.

But when I compile my project and launch it, nothing his launched, or maybe it is automaticly and quickly closed by itself.

Do you have any idea why ?

Thanks in advance.

Posted (edited)

@arkane

#include <Misc.au3>
 
 If _IsPressed('11') Then
     $i=0
     While $i <= 2
         Send("{SPACE down}")
         sleep (300)
         Send("{Space up}")
         $i = $i + 1
     WEnd
 EndIf

Cheers, FireFox.

Edited by FireFox
Posted

Hi dudes.

I have a problem with my script.

#include <Misc.au3>

If _IsPressed('11') Then
    $i=0
    While $i = 2
        Send("{SPACE down}")
        sleep (300)
        Send("{Space up}")
        $i = $i + 1
    WEnd
EndIf

I want that when I press ctrl, space is pressed twice.

But when I compile my project and launch it, nothing his launched, or maybe it is automaticly and quickly closed by itself.

Do you have any idea why ?

Thanks in advance.

Well, While i = 2 never happens cause i = 0. Try While i < 2?
Posted (edited)

Because you do not have your script wait until you press control.

It just reads through the script... sees that _Ispressed('11') is not pressed at that split second of time, then it ends.

You need to do a loop..

#include <Misc.au3>
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(100) ; always a good idea so you dont max your cpu
    If _IsPressed('11') Then
        $i = 0
        While $i < 2
            Send("{SPACE down}")
            Sleep(300)
            Send("{Space up}")
            $i = $i + 1
        WEnd
    EndIf
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

[edit] tweaked your other while loop so it would work too[/edit]

Edited by SpookMeister

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Posted (edited)

wow !

what quick answers ! lol !

Thanks for your help, that was a syntax error :)...

But well, it seems to work very slowly !!

I just want to convert this ahk script into an autoit one :

LControl & RAlt::
Loop 2
{
Sendinput {Space down}
sleep 30
Sendinput {Space up}
}
Return

but I'm struggling :lmao:

Edit : In fact, I want to use this for a game which use 60fps.

I would like that on one frame it press space, and just on the next one, it press space again.

Edited by arkane
Posted

what is slow?

The response to pressing CTRL?

The time between spaces?

How long it is taking to do each space?

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Posted

Then tweak it...

#include <Misc.au3>
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(10) ; always a good idea so you dont max your cpu
    If _IsPressed('11') Then
        $i = 0
        While $i = 2
            Send("{SPACE down}")
            Sleep(20) ; 60 FPS means you will have a frame every 16.666666... miliseconds
            Send("{Space up}")
            $i = $i + 1
        WEnd
    EndIf
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Posted (edited)

well, the problem is that it doesn't answer everytime I press control.

Is there any way to set ALTGR key instead of control ?

I tried

#include <Misc.au3>

While 1
    If _IsPressed('!Gr') Then
        $i = 0
        While $i <= 2
            Send("{SPACE down}")
            Sleep(17); 60 FPS means you will have a frame every 16.666666... miliseconds
            Send("{Space up}")
            $i = $i + 1
        WEnd
    EndIf
WEnd

but it doesn't work :/

Edited by arkane
Posted

How about:

#include <Misc.au3>
HotKeySet("{ESC}", "Terminate")

While 1
    Sleep(10) ; always a good idea so you dont max your cpu
    If _IsPressed('11') Then
        $i = 0
        While $i = 2
            Send("{SPACE}")
            Sleep(20)
            Send("{SPACE}")
            $i = $i + 1
        WEnd
    EndIf
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Posted

Try this, and play with the OPT values

#include <Misc.au3>
HotKeySet("{ESC}", "Terminate")
Opt ("SendKeyDelay",15) ; delay between sending keys - default 5
Opt ("SendKeyDownDelay",5) ; how long to hold down a key - default 5

While 1
    Sleep(10) ; always a good idea so you dont max your cpu
    If _IsPressed('11') Then Send ("{SPACE}{SPACE}") ; '11' = a CTRL key
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Posted

FYI, on my machine checking _IsPressed() takes about 5 miliseconds all by itself... YMMV "Your Mileage May Vary"

[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...