Sign in to follow this  
Followers 0
saiya3

Need help on this...

6 posts in this topic

Hi,

I'm quite new on this scripting stuff, and had been using/playing with? Autoit for a few days now.

Now I've stumbled upon a new problem which gives me a headache. Here is the script I'm working on now,

#include <Misc.au3>
Global $Running = 0, $Pos, $PixelColor, $key, $dll
HotKeySet("^p", "_ToggleRun")
$dll = DllOpen("user32.dll")

While 1
    $key = _UseLastPressed()
    If $Running Then
        If $PixelColor <> PixelGetColor($Pos[0], $Pos[1]) Then
            Send("{" & $key & "}")
            Sleep(10); Wait
        EndIf
    EndIf
WEnd

Func _ToggleRun()
    $Running = Not $Running
    If $Running Then
        $Pos = MouseGetPos()
        $PixelColor = PixelGetColor($Pos[0], $Pos[1])
    EndIf
EndFunc   ;==>_ToggleRun

Func _UseLastPressed()
    While $Running
        If _IsPressed("20", $dll) Then
            $key = "Space"
        ElseIf _IsPressed("31", $dll) Then
            $key = "1"
        ElseIf _IsPressed("32", $dll) Then
            $key = "2"
        ElseIf _IsPressed("33", $dll) Then
            $key = "3"
        ElseIf _IsPressed("60", $dll) Then
            $key = "Numpad0"
        EndIf
    WEnd
EndFunc   ;==>_UseLastPressed

Well, I do think my func for the _uselastpressed is flawed or something, but I'm not sure which part is wrong or something is missing. What I want to do with the script is quite simple.

1. get color from specific coord.

2. if color changes, then send "space" as the default key (still working on it- need help here if possible)

3. if while running, other key are pressed, which is key 1/2/3/Numpad0, space key should be replaced by the corresponding key, and continue to do so until another key is pressed to change it.

Now, the problem I'm having is how to code the Send($key).I've tried with example as in the above script( Send("{" & $key & "}")), changing the flag, and others, but it wont send what I want. The key returned was always 0, or nothing at all, or the exact $key/$.

This is where I believe the _UseLastPressed func of mine is faulty, but I dont know what is wrong with it( yes, I've toyed with it too many times already, but for a total noob like me it will soon make my head explode).

Any help, critics, pointers whatsoever is very welcomed. Meanwhile, I've gotta read the helpfile over and over again, as well as looking for more example scripts to try as much as I could.

Heaps of thanks in advance.

Share this post


Link to post
Share on other sites



Is this a B@t for W@rld o$ W$craft? :)

As your handle is reported in wowarmory.com

Share this post


Link to post
Share on other sites

Sorry, but this is not meant for WOW or anything yet.

And I dont play WOW, though I do play Warcraft3. Just testing Autoit functions and still trying to learn more.

:)

Share this post


Link to post
Share on other sites

You are missing a return statement in the UseLastPressed. Understand scope and do Local $key = -1 at the top of the function and return $key at the end.

You may have other issues than that but you have $key = _UseLastPressed() and UseLastPressed() has no return statement, you have issues.


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

Share this post


Link to post
Share on other sites

Hi,

Thank you very much bo8ster for the reply. Well, anyway I'm dumping this thread bcoz I've just realized that I'm trying to run before even begin learning to walk properly... :) . I've read the helpfile and several other examples on this forum and had found my mistakes.

And also I made this thread while being sleepy and angry doesn't help me learning at all. I need more sleep !lol

Anyway I really appreciate your help. Thanks again, now I can continue playing Autoit scripts and pretending to be a coder, heh! Wish me luck, and next time if I stumble upon another problem (I'll make sure it's a real one by then), I'll be sure to post it.... :)

thread solved/dumped.

Share this post


Link to post
Share on other sites

No probs mate, thats how I learnt. There are some tuts in my sig where you can learn heaps too. (Brett F's Learning To Script with AutoIt V3 and Valuater's AutoIt 1-2-3, Class... is now in Session)

Good luck i'm sure you will be a jet in no time and if you have any issues just post here :)


Post your code because code says more then your words can. SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y. Use Opt("MustDeclareVars", 1)[topic="84960"]Brett F's Learning To Script with AutoIt V3[/topic][topic="21048"]Valuater's AutoIt 1-2-3, Class... is now in Session[/topic]Contribution: [topic="87994"]Get SVN Rev Number[/topic], [topic="93527"]Control Handle under mouse[/topic], [topic="91966"]A Presentation using AutoIt[/topic], [topic="112756"]Log ConsoleWrite output in Scite[/topic]

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