Sign in to follow this  
Followers 0
DrLouie

Very Simple Auto It Question.

13 posts in this topic

hi all

i coded a simple script to convert a key to do a "combo"

#Include <Misc.Au3>

While 1
    HotKeySet("f","f")
    HotKeySet("r","r")
    HotKeySet("g","g")
    HotKeySet("t","t")
    hotkeyset("c","c")
    HotKeySet("v","v")
    hotkeyset("b","b")
WEnd



While 1
        Sleep(100)  
WEnd

Func f()
    HotKeySet("f")
    send("{DOWN}")
    sleep(35)
    Send("{LEFT}")
    sleep(35)
    Send("e")
EndFunc

    Func r()
        send("{DOWN}")
        sleep(35)
        Send("{RIGHT}")
        sleep(35)
        Send("e")
    EndFunc
    

    Func g()
        Send("{DOWN}")
        sleep(23)
        Send("{LEFT}")
        sleep(23)
        Send("q")
        sleep(23)
        Send("w")

    EndFunc

    Func t()

        Send("{DOWN}")
        sleep(23)
        Send("{RIGHT}")
        sleep(23)
        Send("q")
        sleep(23)
        Send("w")
    EndFunc
    
        Func c()
        send("{DOWN}")
        sleep(25)
        send("{DOWN}")
        sleep(25)
        send("{UP}")
        sleep(25)
        send("{UP}")
    EndFunc
    
        Func b()
        send("{DOWN}")
        sleep(26)
        Send("{LEFT}")
        sleep(26)
        Send("q")
    EndFunc

    Func v()
        send("{DOWN}")
        sleep(27)
        Send("{RIGHT}")
        sleep(27)
        Send("q")
    EndFunc
    
    
    Func Quit()
        Exit
    EndFunc

its for a game i play, but i have a problem cause when i hit R for example, my game will be a bit laggy cause it loops real fast, like if i hold R it keeps doing : down right E.

how can i edit my code so i can HOLD the R button but it only do the function 1 time. so not looping.

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

You have many while loops without a way to exit the loop. For example, you set your hotsetkeys in a loop. You only need to set them once.

Try this:

#Include <Misc.Au3>

    HotKeySet("f","f")
    HotKeySet("r","r")
    HotKeySet("g","g")
    HotKeySet("t","t")
    hotkeyset("c","c")
    HotKeySet("v","v")
    hotkeyset("b","b")

While 1
        Sleep(100)  
WEnd

Func f()
    HotKeySet("f") ;This releases the hotsetkey. Is this what you intended? if not, remove this line.
    send("{DOWN}")
    sleep(35)
    Send("{LEFT}")
    sleep(35)
    Send("e")
EndFunc

    Func r()
        send("{DOWN}")
        sleep(35)
        Send("{RIGHT}")
        sleep(35)
        Send("e")
    EndFunc
    

    Func g()
        Send("{DOWN}")
        sleep(23)
        Send("{LEFT}")
        sleep(23)
        Send("q")
        sleep(23)
        Send("w")

    EndFunc

    Func t()

        Send("{DOWN}")
        sleep(23)
        Send("{RIGHT}")
        sleep(23)
        Send("q")
        sleep(23)
        Send("w")
    EndFunc
    
        Func c()
        send("{DOWN}")
        sleep(25)
        send("{DOWN}")
        sleep(25)
        send("{UP}")
        sleep(25)
        send("{UP}")
    EndFunc
    
        Func b()
        send("{DOWN}")
        sleep(26)
        Send("{LEFT}")
        sleep(26)
        Send("q")
    EndFunc

    Func v()
        send("{DOWN}")
        sleep(27)
        Send("{RIGHT}")
        sleep(27)
        Send("q")
    EndFunc
    
    
    Func Quit()
        Exit
    EndFunc
Edited by Volly

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Something like this perhaps:

#include<misc.au3>

HotKeySet("r", "r")

While 1
    Sleep(100)
WEnd

Func r()
    HotKeySet("r", "NoBuffer") ; Unbind "r" and this function (Reassign to "NoBuffer" so that we do not send the 'r' key while it is held).
    While _IsPressed(52) ; Waits until the 'r' key is no longer being held, before performing action
        Sleep(10)
    WEnd
    Send("{DOWN}")
    Sleep(35)
    Send("{RIGHT}")
    Sleep(35)
    Send("e")
    HotKeySet("r", "r") ; bind 'r' back with this function
EndFunc   ;==>r

Func NoBuffer()
    Sleep(10)
EndFunc

EDIT: Commented code (I am really bad about that).

Edited by danwilli

Share this post


Link to post
Share on other sites

Welcome to the forums!

how can i edit my code so i can HOLD the R button but it only do the function 1 time. so not looping.

Try this:

#Include <Misc.au3>

...

Func f()
    HotKeySet("f" ,"DoNothing")
    Send("{DOWN}")
    Sleep(35)
    Send("{LEFT}")
    Sleep(35)
    Send("e")
    While _IsPressed("46")
        Sleep(100)
    WEnd
    HotKeySet("f","f")
EndFunc

...

Func DoNothing()
    ; Do Nothing
EndFunc

Of course, you'll need to replace "46" with the scancodes for each key (consult the help file).

Good luck!


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

well now i can press F only one time, and then it doesn't work anymore... and if i restart it it works again.

i wanted to have it like this:

if i press f it does my combo, and then not anymore and if i press it again it will do it again.

cause in my script when i "hold" f too long like or press it too much after each other it will lag me in the game. because it keeps sending down left e

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Welcome to the forums!

Try this:

#Include <Misc.au3>

...

Func f()
    HotKeySet("f" ,"DoNothing")
    Send("{DOWN}")
    Sleep(35)
    Send("{LEFT}")
    Sleep(35)
    Send("e")
    While _IsPressed("46")
        Sleep(100)
    WEnd
    HotKeySet("f","f")
EndFunc

...

Func DoNothing()
    ; Do Nothing
EndFunc

Of course, you'll need to replace "46" with the scancodes for each key (consult the help file).

Good luck!

exactly what i was looking for thanks <3 , where can i find the scan codes? Edited by DrLouie

Share this post


Link to post
Share on other sites

nvm i found key codes , thanks all for your (quick) help lol :]!

Share this post


Link to post
Share on other sites

Almost identical to mine :)

Yeah, I always refresh before posting, but yours didn't show up this time. >_<

In case the OP is wondering, my example will send the "combo" when the key is pressed, and Dan's sends the "combo" when the key is released.

Useful to have and understand both.


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

Yeah, I always refresh before posting, but yours didn't show up this time. :)

In case the OP is wondering, my example will send the "combo" when the key is pressed, and Dan's sends the "combo" when the key is released.

Useful to have and understand both.

yea lol i just started using auto it , but i know there are unlimited things to create with this. im going to study it alot

Share this post


Link to post
Share on other sites

#11 ·  Posted (edited)

Hi all , its working like a charm now, but sometimes suddenly my f key locks, it wont do nothing until i restart script while my r key is still working maybe its with more keys anyone know what the problem is?

now my r key locked after a while i couldnt use it , but my f did those are the 2 i mainly use lol

i dont know what i did wrong , but while im busy it suddenly stops working..

#Include <Misc.Au3>

    HotKeySet("f","f")
    HotKeySet("r","r")
    HotKeySet("g","g")
    HotKeySet("t","t")
    hotkeyset("c","c")
    HotKeySet("v","v")
    hotkeyset("b","b")

While 1
        Sleep(100) 
WEnd

Func f()
    HotKeySet("f" ,"DoNothing")
    Send("{DOWN}")
    Sleep(22)
    Send("{LEFT}")
    Sleep(22)
    Send("e")
    While _IsPressed("46")
        Sleep(22)
    WEnd
    HotKeySet("f","f")
EndFunc



    Func r()
        HotKeySet("r","DoNothing")
        send("{DOWN}")
        sleep(22)
        Send("{RIGHT}")
        sleep(22)
        Send("e")
        While _IsPressed("52")
        Sleep(22)
    WEnd
    HotkeySet("r","r")
EndFunc
   

Func g()
    HotKeySet("g" ,"DoNothing")
    Send("{DOWN}")
    Sleep(22)
    Send("{LEFT}")
    Sleep(22)
    Send("q")
    Sleep(22)
    Send("w")
    While _IsPressed("47")
        Sleep(22)
    WEnd
    HotKeySet("g","g")
EndFunc



    Func t()
        HotKeySet("t","DoNothing")
        send("{DOWN}")
        sleep(22)
        Send("{RIGHT}")
        sleep(22)
        Send("q")
        sleep(22)
        Send("w")
            While _IsPressed("54")
        Sleep(22)
    WEnd
    HotkeySet("t","t")
EndFunc
   
        Func c()
        send("{DOWN}")
        sleep(25)
        send("{DOWN}")
        sleep(25)
        send("{UP}")
        sleep(25)
        send("{UP}")
    EndFunc

Func b()
    HotKeySet("f" ,"DoNothing")
    Send("{DOWN}")
    Sleep(22)
    Send("{LEFT}")
    Sleep(22)
    Send("q")
    While _IsPressed("42")
        Sleep(22)
    WEnd
    HotKeySet("b","b")
EndFunc

    Func v()
        HotKeySet("r","DoNothing")
        send("{DOWN}")
        sleep(22)
        Send("{RIGHT}")
        sleep(22)
        Send("q")
            While _IsPressed("56")
        Sleep(22)
    WEnd
    HotkeySet("v","v")
EndFunc
   
    
    Func DoNothing()
    ; Do Nothing
EndFunc
Edited by DrLouie

Share this post


Link to post
Share on other sites

now my r key locked after a while i couldnt use it , but my f did those are the 2 i mainly use lol

i dont know what i did wrong , but while im busy it suddenly stops working..

Here are the problems...

Func b()

HotKeySet("f" ,"DoNothing")

...

Func v()

HotKeySet("r","DoNothing")


[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

lol im dumb thanks alot =] , im learning lol

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0