Jump to content

Can someone tell me what I'm doing wrong?


Zamp
 Share

Recommended Posts

I'm trying to make a program that will help me be lazy in a game I play. I want it so I can press up and let go, then it will hold down up for by itself.

Here is what I have right now:

Global $up
Global $down
HotKeySet("{UP}", "moveup")
HotKeySet("{DOWN}", "movedown")
HotKeySet("{ESC}", "Terminate")

;;;; Body of program would go here;;;;
While 1
    Sleep(100)
WEnd
;;;;;;;;

Func moveup()
    $up = NOT $up
    While $up
        Send("{UP}")
    WEnd
EndFunc

Func movedown()
    $down = NOT $down
    While $down
        Send("{DOWN}")
    WEnd
EndFunc

Func Terminate()
    Exit 0
EndFunc

Nothing happens when I press up or down, my guy doesn't even move. I changed the {UP} and {DOWN} to stuff like a and other random letters, and it will just spam those in notepad; but I can't get it to move the cursor up or anything. I've tried a lot of stuff like Send("a{UP}") and sometimes it works, sometimes it doesn't.

Link to comment
Share on other sites

There are at least two problems in your code.

__________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *

Link to comment
Share on other sites

  • Moderators

Global $bUpKey, $bDownKey
HotKeySet("{UP}", "_MoveUp")
HotKeySet("{DOWN}", "_MoveDown")
HotKeySet("{ESC}", "_Terminate")

;;;; Body of program would go here;;;;
While 1
    Sleep(10000000)
WEnd
;;;;;;;;

Func _Terminate()
    Exit
EndFunc

Func _MoveUp()
    If $bDownKey Then _MoveDown()
    $bUpKey = Not $bUpKey
    HotKeySet('{UP}')
    While $bUpKey
        Sleep(10)
        Send('{UP}')
    WEnd
    If Not $bUpKey Then HotKeySet('{UP}', '_MoveUp')
EndFunc

Func _MoveDown()
    If $bUpKey Then _MoveUp()
    $bDownKey = Not $bDownKey
    HotKeySet('{DOWN}')
    While $bDownKey
        Sleep(10)
        Send('{DOWN}')
    WEnd
    If Not $bDownKey Then HotKeySet('{DOWN}', '_MoveDown')
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...