Jump to content

Fairly simple question


Tobei
 Share

Recommended Posts

Edited to update revised code as attatched... please bear with my ugly n00b code, i've rewritten it to be a bit more "friendly"... The problem is with F3... As soon as I hit F3, it just sends /w *Miuka to the chat bar and crashes saying:

companion.au3 (20) : ==> Unknown function name.: HotKeySet ( $i, PerformWhisper($i) )

I've debugged it (by putting little msgbox things in various points) and I know that it is going through the entire For loop in both functions, it just won't allow me to choose 1 or 2, it simply gushes output from hotkey 1.

Any assistance would be very much appreciated.

;Press F1 to sit down.
;Press F2 to open the friends list.
;Press F3, 1 to /w *Miuka 
;Press F3, 2 to /w *sevenix 
;Press CTRL + c to exit this script

#include <Array.au3>
Dim $friends, $i
$friends = _ArrayCreate ( "*Miuka", "*sevenix" )
HotKeySet ( "{F1}", "QuickSit" )
HotKeySet ( "{F2}", "OpenFriends" )
Hotkeyset ( "{F3}", "QuickSelectFriend")
HotKeySet ( "^c", "terminate" )

while 1
    sleep ( 0x7FFFFFFF )
wend

Func QuickSelectFriend()
    For $i = 0 to $friends[0] +1
        HotKeySet ( $i, PerformWhisper($i) )
    Next
EndFunc

Func PerformWhisper(ByRef $i)
    send ( "{ENTER} /w " & $friends[$i] & " " )
    For $i = 0 to $friends[0] +1
        HotKeySet ( $i )
    Next
EndFunc

Func OpenFriends()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 735, 485, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    resetvars()
EndFunc

Func QuickSit()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 30, 475, 1, 0 )
    sleep ( 25 )
    MouseClick ( "left", 105, 410, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    resetvars()
EndFunc

Func resetvars()
    $mouseposition = ""
EndFunc

Func terminate()
    exit 0
EndFunc
Edited by Tobei
Link to comment
Share on other sites

You seem pretty sharp for just 1 post here...

anyway... sometimes people make things more complicated than need-be

you were not utilizing all of the "hotkeysets".. just sending... thus

this is less complicated and does what you wanted

;Press F1 to sit down.
;Press F2 to open the friends list.
;Press F3, 1 to /w *Miuka 
;Press F3, 2 to /w *sevenix 
;Press CTRL + c to exit this script

#include <Array.au3>
Dim $friends, $i
$allfreinds = 2
$friends = _ArrayCreate ( "null", "*Miuka", "*sevenix" )
HotKeySet ( "{F1}", "QuickSit" )
HotKeySet ( "{F2}", "OpenFriends" )
Hotkeyset ( "{F3}", "PerformWhisper")
HotKeySet ( "^c", "terminate" )

while 1
    sleep ( 0x7FFFFFFF )
wend

Func PerformWhisper()
    For $i = 1 to $allfreinds
        Send ( "{ENTER} /w " & $friends[$i] & " " )
    Next
EndFunc

Func OpenFriends()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 735, 485, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    $mouseposition = ""
EndFunc

Func QuickSit()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 30, 475, 1, 0 )
    sleep ( 25 )
    MouseClick ( "left", 105, 410, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    $mouseposition = ""
EndFunc

Func terminate()
    exit 0
EndFunc

8)

NEWHeader1.png

Link to comment
Share on other sites

This should work:

Global $f
$nof = 5;number of friends
HotKeySet("{F3}","sendpm")
HotKeySet("^c","terminate")

while 1
    sleep(1000)
wend

Func sendpm()
    For $i = 1 To $nof
        HotKeySet($i,"friend" & $i)
    Next
    Do
        Sleep(100)
    Until $f <> ""
    Send("{ENTER}/w *" & $f & " ")
    For $i = 1 To $nof
        HotKeySet($i)
    Next
EndFunc

Func friend1()
    $f = "friend4f"
EndFunc
Func friend2()
    $f = "friend2"
EndFunc
Func friend3()
    $f = "friend3"
EndFunc
Func friend4()
    $f = "friend4"
EndFunc
Func friend5()
    $f = "friend5"
EndFunc

Func terminate()
    exit 0
EndFunc

As stated in the helpfile under hotkeyset:

The called function can not be given parameters. They will be ignored.

You can't have sumthing like setuser(31) in the hotkeyset, only setuser (without parameters) works.

I didn't add the stuff you added in your new message,just add it yourself!

Link to comment
Share on other sites

You seem pretty sharp for just 1 post here...

anyway... sometimes people make things more complicated than need-be

you were not utilizing all of the "hotkeysets".. just sending... thus

this is less complicated and does what you wanted

;Press F1 to sit down.
;Press F2 to open the friends list.
;Press F3, 1 to /w *Miuka 
;Press F3, 2 to /w *sevenix 
;Press CTRL + c to exit this script

#include <Array.au3>
Dim $friends, $i
$allfreinds = 2
$friends = _ArrayCreate ( "null", "*Miuka", "*sevenix" )
HotKeySet ( "{F1}", "QuickSit" )
HotKeySet ( "{F2}", "OpenFriends" )
Hotkeyset ( "{F3}", "PerformWhisper")
HotKeySet ( "^c", "terminate" )

while 1
    sleep ( 0x7FFFFFFF )
wend

Func PerformWhisper()
    For $i = 1 to $allfreinds
        Send ( "{ENTER} /w " & $friends[$i] & " " )
    Next
EndFunc

Func OpenFriends()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 735, 485, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    $mouseposition = ""
EndFunc

Func QuickSit()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 30, 475, 1, 0 )
    sleep ( 25 )
    MouseClick ( "left", 105, 410, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    $mouseposition = ""
EndFunc

Func terminate()
    exit 0
EndFunc

8)

Thanks, yea I have a tendancy to make things a little more complex then they need be... But the idea behind this was to Press F3, then be able to select between 1, 2, 3 etc... however many friends are in the array, and thus, whispering them, while only actually taking up F3, as the #'d hotkeys would be removed after one was called. The way you have it laid out it would just always send a blank line to all of the friends in the list except the last one, which would remain in the chat bar.

My Thought Process:

Press F3:

Setup hotkeys for each entry in $friendslist array

Loop until one is called.

Present the send text and remove the hotkeys.

end loop

end F3 function.

... I'll plug away at it a little more, maybe i'll stumble upon a workable and modular solution.

The whole reason I'm going through all this trouble is to not be forced to have to take up a seperate permanent hotkey for each friend on the list. This way i could varitably go up to 36 friends (1-0, a-z) and all I'd ever have to add is the names into the array, instead of having to write up a new hotkey and function...

Again, all feedback is welcomed, and appreciated B)

Link to comment
Share on other sites

I understand what you want.... but its kind of hard since you can't have arguments with hotkeyset (which kinda sux!)...

will think about it!

BTW, the helpfile says:

Arrays up to 21 elements are supported.

So 36 friends?!? B)

Felix

Edited by Felix N.
Link to comment
Share on other sites

Func sendpm()

    For $i = 1 To $nof

        HotKeySet($i,"friend" & $i)

    Next

    Do

Sleep(100)

Until $f <> ""

    Send("{ENTER}/w *" & $f & " ")

    For $i = 1 To $nof

        HotKeySet($i)

    Next

EndFunc

I think this is my problem right here Felix! O.o *Opens sCiTe in a hurry*

I wasn't giving my script any time to "wait" for input from the hotkeys, it simply moved on after declaring them logically. I think a simple return should do the trick (throw it back into the main loop.)

Will post my results B)

Link to comment
Share on other sites

looking at this....its close

;Press F1 to sit down.
;Press F2 to open the friends list.
;Press F3, 1 to /w *Miuka 
;Press F3, 2 to /w *sevenix 
; up to 10- friends pressing keys 0 through 9
;Press CTRL + c to exit this script

#include <Misc.au3>
Dim $friends, $Paused

; for testing
notepad()


$friends = StringSplit( "*Valuater,*Miuka,*sevenix,*fred,*ron,*doug,*debbie,*frank,*Tobei,*sue", "," )
HotKeySet ( "{F1}", "QuickSit" )
HotKeySet ( "{F2}", "OpenFriends" )
Hotkeyset ( "{F3}", "QuickSelectFriend")
HotKeySet ( "^c", "terminate" )

while 1
    sleep ( 0x7FFFFFFF )
wend

Func QuickSelectFriend()
    $Paused = NOT $Paused
    While $Paused
        
        For $x = 30 to $friends[0] + 30 
            If _IsPressed($x) Then
                Send ( "{ENTER} /w " & $friends[$x-30] & " " )
            EndIf
        Sleep(1)
        Next
    WEnd
EndFunc

Func OpenFriends()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 735, 485, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    $mouseposition = ""
EndFunc

Func QuickSit()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 30, 475, 1, 0 )
    sleep ( 25 )
    MouseClick ( "left", 105, 410, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    $mouseposition = ""
EndFunc

Func terminate()
    exit 0
EndFunc

Func notepad()
    Run("Notepad.exe")
    WinWaitActive("")
EndFunc

i think it adds the number in the test... but maybe not in your send box

give it a try

8)

NEWHeader1.png

Link to comment
Share on other sites

Nifty! Thanks for the inspiration guys :)

The code is longer than moses' beard would be B)

But it works like a charm, and its easy to update. :graduated:

Just what I wanted!! :o

Now I can finally get my mind off this hurdle.

Attatched my present "Dofus Companion"

;Tobei's Dofus companion v1.06
;
;Designed to assist in a few little things, more to come surely.
;Resolution must be at default (yes that ugly 800 x 600 junk)
;
;Props goin out to: Valuater and Felix N. on the AutoIt Forums.
;-----------------------------------------------------------------
;Press F1 to /sit
;Press F2 to open the friends list.
;Press F3, 1 to whisper friend #1
;Press F3, 2 to whisper friend #2, etc...
;Press CTRL + c to exit this script
;
;-----------------------------------------------------------------
;Rev up the settings & variables.
#include <Array.au3>
WinWaitActive ( "Dofus" )
Dim $friends, $i, $var, $buf, $numtolett
$friends = _ArrayCreate ( "null", "*Miuka", "*sevenix" )
$numtolett = _ArrayCreate ( "null", "a", "b", "c", "d", "e", "f", "g", "h", "i", "j" )
;
;Setup the general hotkeys.
HotKeySet ( "{F1}", "QuickSit" )
HotKeySet ( "{F2}", "OpenFriends" )
Hotkeyset ( "{F3}", "QuickSelectFriend")
HotKeySet ( "^c", "terminate" )
;
;Main loop
while 1
    sleep ( 0x7FFFFFFF )                ;Long pause = less lag.
wend
;
;The quick whisper (F3) function.
Func QuickSelectFriend()
    For $i = 0 to ubound($friends) -1
        if $i >= 0 AND $i < 10 Then
            $var = $i
        elseif $i = 10 Then
            $var = "0"
        Else
            MsgBox (0, "Error with Dofus_Companion.au3", "QuickSelectFriends array may only hold 10 names at this time." )
            for $i = 0 to ubound($friends) - 1
                hotkeyset ( $i )
            Next
            return
        EndIf
        HotKeySet ( $var, "PerformWhisper" & $NumToLett[$var] )
    Next
    Return;Send "flow" back to main loop to await user input.
EndFunc
;
;Some redundancy for safety sake.
Func PerformWhispernull()
    Return
EndFunc
;
;One function per friend on the list, max of 10.
Func PerformWhispera()
    send ( "{ENTER}/w " & $friends[1] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperb()
    send ( "{ENTER}/w " & $friends[2] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperc()
    send ( "{ENTER}/w " & $friends[3] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperd()
    send ( "{ENTER}/w " & $friends[4] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhispere()
    send ( "{ENTER}/w " & $friends[5] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperf()
    send ( "{ENTER}/w " & $friends[6] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperg()
    send ( "{ENTER}/w " & $friends[7] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperh()
    send ( "{ENTER}/w " & $friends[8] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperi()
    send ( "{ENTER}/w " & $friends[9] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
Func PerformWhisperj()
    send ( "{ENTER}/w " & $friends[0] & " " )
    For $i = 0 to ubound($friends) - 1
        HotKeySet ( $i )
    Next
    return;Send "flow" back to main loop as its finished its purpose.
EndFunc
;
;Quick-key to open your in-game friends list.
Func OpenFriends()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 735, 485, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    resetvars()
EndFunc
;
;Quick-key to sit down.
Func QuickSit()
    $mouseposition = MouseGetPos()
    MouseClick ( "left", 30, 475, 1, 0 )
    sleep ( 25 )
    MouseClick ( "left", 105, 410, 1, 0 )
    MouseMove ( $mouseposition[0], $mouseposition[1], 0 )
    resetvars()
EndFunc
;
;Reset the mouse position.
;Function may have future uses.
Func resetvars()
    $mouseposition = ""
EndFunc
;
;Terminate upon CTRL + c
Func terminate()
    exit 0
EndFunc
;
;FIN

Edited by Tobei
Link to comment
Share on other sites

function names have to be all letters don't they?

I don't know... i have always used letters, but you can test one of your functions with numbers if you want

also... if this does work... you can expand it to the number/letters/F-keys.. etc

just check out _IsPressed() in help

good luck

8)

NEWHeader1.png

Link to comment
Share on other sites

I understand what you want.... but its kind of hard since you can't have arguments with hotkeyset (which kinda sux!)...

You can take advantage of the @HotkeyPressed macro to determine which hotkey was last used. Multiple hotkeys can then point to one function and still perform unique functionality.

This would greatly reduce the number of functions required in your script:

Func PerformWhisperA()
Func PerformWhisperB()
Func PerformWhisperC()
Func PerformWhisperD()
Func PerformWhisperE()
Func PerformWhisperF()
Func PerformWhisperG()
Func PerformWhisperH()
Func PerformWhisperI()
Func PerformWhisperJ()
Link to comment
Share on other sites

To bad this doesn't work:

$friends = StringSplit( "*Valuater,*Miuka,*sevenix,*fred,*ron,*doug,*debbie,*frank,*Tobei,*sue", "," )
HotKeySet("{F3}","sendpm")

MsgBox(0,"Lol",$friends[0])

For $i = 1 To $friends[0]
    $functionname = "friend" & $i
    Func $functionname
        $friend = $friends[$i]
    EndFunc
Next

While 1
    Sleep(100)
WEnd

Func sendpm()
    For $i = 1 To $friends[0]
        HotKeySet($i,"friend" & $i)
    Next
    Do
        Sleep(100)
    Until $friend <> ""
    Send("{ENTER}/w " & $friend & " ")
    For $i = 1 To $friends[0]
        HotKeySet($i)
    Next
EndFunc

For that we would need something like

NewFunc functionname(arguments)
...
EndNewFunc

that creates a new function without seeing it as a function?!?! You understand what i mean? ^^

Felix N.

Link to comment
Share on other sites

Thanks Lxp however nowhere in my helpfile can i find an entry for @HotKeyPressed, and my sCiTe editor doesn't know it either... Am I running the newest version?

Currently Installed:

Version: 3.1.1.0

Date: August 7th, 2005

Edited by Tobei
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...