Jump to content

Recommended Posts

Posted

Heres the errors I get when I try to run this:

C:\Documents and Settings\Administrator\Desktop\New AutoIt v3 Script (2).au3(46,6) : ERROR: syntax error
Func Exit
~~~~~^
C:\Documents and Settings\Administrator\Desktop\New AutoIt v3 Script (2).au3(10,65) : ERROR: _RandLetter(): undefined function.
Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrator\Desktop\New AutoIt v3 Script (2).au3(13,24) : ERROR: exit(): undefined function.
HotKeySet ("^e", "exit")
~~~~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrator\Desktop\New AutoIt v3 Script (2).au3(30,21) : ERROR: _SendKeys(): undefined function.
_SendKeys($hWnd, $sm)
~~~~~~~~~~~~~~~~~~~~^
C:\Documents and Settings\Administrator\Desktop\New AutoIt v3 Script (2).au3 - 4 error(s), 0 warning(s)

Heres the script:

I would love any help!

Thanks,

Sparrow

Posted

; ----------------------------------------------------------------------------
;
; AutoIt Version: 
; Author:        Zappie <sparrowlord@gmail.com>
;
; Script Function: Just a basic Diablo II trade helper.
;
;
; ----------------------------------------------------------------------------
Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")
Dim $sl = IniRead("c:\spam\settings.ini","wait time", "wt","NOT FOUND")

HotKeySet ("^e", "close")



Global Const $VK_OEM_PLUS = 0xBB
Global Const $VK_OEM_MINUS = 0xBD
Global Const $VK_OEM_3 = 0xC0
Global Const $VK_TAB = 0x9
Global Const $VK_ESC = 0x1B
Global Const $VK_F5 = 0x74
Global Const $VK_F12 = 0x7B


Dim $hWnd = WingetHandle("Diablo II")



_SendKeys($hWnd, $sm); using send keys
sleep(900)
_SendKeys($hWnd, "{ENTER}"); sending enter

$i = 0
While $i <= 10
_SendKeys($hWnd, $sm); using send keys
sleep(1000)
_SendKeys($hWnd, "{ENTER}"); sending enter
sleep($sl)
    $i = $i + 1
WEnd




Func Close()
Exit
EndFunc


Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Func _MouseClick($hWnd, $button, $x, $y, $times = 1, $delay = 0)
    Local $ret, $ix
    $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y))
    If $ret[0] = 0 Then
        SetError(-1)
        Return
    EndIf
    $button = StringLower($button)
    If $button = "left" Then
        For $ix = 1 To $times
            $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", _MakeLong($x, $y))
            If $ret[0] = 0 Then
                SetError(-2)
                Return
            Else
                $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
                If $ret[0] = 0 Then
                    SetError(-3)
                    Return
                EndIf
            EndIf
            Sleep($delay)
        Next
    ElseIf $button = "right" Then
        For $ix = 1 To $times
            $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", _MakeLong($x, $y))
            If $ret[0] = 0 Then
                SetError(-4)
                Return
            Else
                $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", _MakeLong($x, $y))
                If $ret[0] = 0 Then
                    SetError(-5)
                    Return
                EndIf
            EndIf
            Sleep($delay)
        Next
    Else
        SetError(-6)
        Return
    EndIf
EndFunc

Func _SendKeys($hWnd, $keys)
    If $hWnd <= 0 Or StringLen($keys) = 0 Then
        SetError(-1)
        Return False
    EndIf
    $keys = StringUpper($keys)
    $keys = StringReplace($keys, "`", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "~", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "-", Chr($VK_OEM_MINUS))
    $keys = StringReplace($keys, "=", Chr($VK_OEM_PLUS))
    $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
    $keys = StringReplace($keys, "{TAB}", Chr(0x9))
    $keys = StringReplace($keys, "{ESC}", Chr($VK_ESC))
    $keys = StringReplace($keys, "{F5}", Chr($VK_F5))
    $keys = StringReplace($keys, "{F12}", Chr($VK_F12))
    $keys = StringReplace($keys, "{SHIFT}", "+")
    Local $i, $ret
    Local $shiftdown = False
    For $i = 1 To StringLen($keys)
        If StringMid($keys, $i, 1) = "+" Then
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
            $shiftdown = True
            Sleep(1)
            ContinueLoop
        Else
            $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
            If IsArray($ret) Then
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
                Sleep(1)
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
            EndIf
        EndIf
        If $shiftdown Then
            Sleep(1)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
            $shiftdown = False
        EndIf
    Next
    Return True
EndFunc 

 
 Func _RandLetter() 
Return Chr(Random(97, 122, 1))
 EndFunc

u can't use the name "exit" for ur own custom functions..

Posted

But now with that script the messages it sends isnt random, I have a ini with a-z but it picks a random one to start with but it doesnt random after the first one.

Posted (edited)

Heres my ini called "messages"

a= Message 1
b= Message 2
c= Message 3
d= Message 4
e= Message 5
f= Message 6
g= Message 7
h= Message 8
i= Message 9
j= Message 10
k= Message 11
l= Message 12
m= Message 13
n= Message 14
o= Message 15
p= Message 16
q= Message 17
r= Message 18
s= Message 19
t= Message 20
u= Message 21
v= Message 22
w= Message 23
x= Message 24
y= Message 25
z= Message 26

And its supposed to say any of those random.

Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")

and heres the _Randletter

Func _RandLetter()
Return Chr(Random(97, 122, 1))
EndFunc

But instead it picks one of those and uses it all the time instead of switching to a new one.

Edited by Sparrowlord
Posted (edited)

Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")

This is only called once... so it will not change at all, $sm = whatever the ini line is throughout the script..

try this...

; ----------------------------------------------------------------------------
;
; AutoIt Version:
; Author:        Zappie <sparrowlord@gmail.com>
;
; Script Function: Just a basic Diablo II trade helper.
;
;
; ----------------------------------------------------------------------------
Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")
Dim $sl = IniRead("c:\spam\settings.ini","wait time", "wt","NOT FOUND")

HotKeySet ("^e", "close")



Global Const $VK_OEM_PLUS = 0xBB
Global Const $VK_OEM_MINUS = 0xBD
Global Const $VK_OEM_3 = 0xC0
Global Const $VK_TAB = 0x9
Global Const $VK_ESC = 0x1B
Global Const $VK_F5 = 0x74
Global Const $VK_F12 = 0x7B


Dim $hWnd = WingetHandle("Diablo II")



_SendKeys($hWnd, $sm); using send keys
sleep(900)
_SendKeys($hWnd, "{ENTER}"); sending enter

$i = 0
While $i <= 10
Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")
_SendKeys($hWnd, $sm); using send keys
sleep(1000)
_SendKeys($hWnd, "{ENTER}"); sending enter
sleep($sl)
    $i = $i + 1
WEnd




Func Close()
Exit
EndFunc


Func _MakeLong($LoWord, $HiWord)
    Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc
Func _MouseClick($hWnd, $button, $x, $y, $times = 1, $delay = 0)
    Local $ret, $ix
    $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x200, "int", 0, "long", _MakeLong($x, $y))
    If $ret[0] = 0 Then
        SetError(-1)
        Return
    EndIf
    $button = StringLower($button)
    If $button = "left" Then
        For $ix = 1 To $times
            $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x201, "int", 1, "long", _MakeLong($x, $y))
            If $ret[0] = 0 Then
                SetError(-2)
                Return
            Else
                $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x202, "int", 0, "long", _MakeLong($x, $y))
                If $ret[0] = 0 Then
                    SetError(-3)
                    Return
                EndIf
            EndIf
            Sleep($delay)
        Next
    ElseIf $button = "right" Then
        For $ix = 1 To $times
            $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x204, "int", 2, "long", _MakeLong($x, $y))
            If $ret[0] = 0 Then
                SetError(-4)
                Return
            Else
                $ret = DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x205, "int", 0, "long", _MakeLong($x, $y))
                If $ret[0] = 0 Then
                    SetError(-5)
                    Return
                EndIf
            EndIf
            Sleep($delay)
        Next
    Else
        SetError(-6)
        Return
    EndIf
EndFunc

Func _SendKeys($hWnd, $keys)
    If $hWnd <= 0 Or StringLen($keys) = 0 Then
        SetError(-1)
        Return False
    EndIf
    $keys = StringUpper($keys)
    $keys = StringReplace($keys, "`", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "~", Chr($VK_OEM_3))
    $keys = StringReplace($keys, "-", Chr($VK_OEM_MINUS))
    $keys = StringReplace($keys, "=", Chr($VK_OEM_PLUS))
    $keys = StringReplace($keys, "{ENTER}", Chr(0xD))
    $keys = StringReplace($keys, "{TAB}", Chr(0x9))
    $keys = StringReplace($keys, "{ESC}", Chr($VK_ESC))
    $keys = StringReplace($keys, "{F5}", Chr($VK_F5))
    $keys = StringReplace($keys, "{F12}", Chr($VK_F12))
    $keys = StringReplace($keys, "{SHIFT}", "+")
    Local $i, $ret
    Local $shiftdown = False
    For $i = 1 To StringLen($keys)
        If StringMid($keys, $i, 1) = "+" Then
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x002A0001)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", 0x10, "long", 0x402A0001)
            $shiftdown = True
            Sleep(1)
            ContinueLoop
        Else
            $ret = DllCall("user32.dll", "int", "MapVirtualKey", "int", Asc(StringMid($keys, $i, 1)), "int", 0)
            If IsArray($ret) Then
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x100, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]))
                Sleep(1)
                DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", Asc(StringMid($keys, $i, 1)), "long", _MakeLong(1, $ret[0]) + 0xC0000000)
            EndIf
        EndIf
        If $shiftdown Then
            Sleep(1)
            DllCall("user32.dll", "int", "PostMessage", "hwnd", $hWnd, "int", 0x101, "int", 0x10, "long", 0xC02A0001)
            $shiftdown = False
        EndIf
    Next
    Return True
EndFunc


Func _RandLetter()
Return Chr(Random(97, 122, 1))
EndFunc

this should work...

*it was'nt tested though*

in the while loop

While $i <= 10
Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")
_SendKeys($hWnd, $sm); using send keys
sleep(1000)
_SendKeys($hWnd, "{ENTER}"); sending enter
sleep($sl)
    $i = $i + 1
WEnd

"Dim $sm = IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")" is called throught the loop, so every time it loops it will pick a different random letter.

Edited by CHRIS95219
  • Moderators
Posted

I'm just curious on why your just not doing this:

IniRead("c:\spam\messages.ini", "messages", Chr(Random(Asc('a'), Asc('z'), 1)), "NOT FOUND")
Instead of this:
IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")
Func _RandLetter()
Return Chr(Random(97, 122, 1))
EndFunc
... That way there is no need for a function really :)

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.

Posted

I'm just curious on why your just not doing this:

IniRead("c:\spam\messages.ini", "messages", Chr(Random(Asc('a'), Asc('z'), 1)), "NOT FOUND")
Instead of this:
IniRead("c:\spam\messages.ini","messages",_RandLetter(),"NOT FOUND")
Func _RandLetter()
Return Chr(Random(97, 122, 1))
EndFunc
... That way there is no need for a function really :)
i was wondering the same thing....
Posted (edited)

Use this

Func _RandLetter()
Local $rndletter = Chr(Random(97, 122, 1))
$sm = IniRead("c:\spam\messages.ini","messages",$rndletter, "NOT FOUND")
Return $rndletter

Just replace your _Randletter function with that.

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!

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...