Jump to content

Larry's Use of Bandwidth


LarryDalooza
 Share

Recommended Posts

Very nice, works great.

I wish I could figure out how to properly use & call the DllCallBack function. Piccaso, perhaps if you have any free time to create a short tutorial with very simple examples for people who aren't familiar with this (aka for noobs like me <_< ).

Thanks,

Kurt

Edited by _Kurt

Awaiting Diablo III..

Link to comment
Share on other sites

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Thanks larry for this wonderful example, unfortunately i could have used it some time ago, but amybe i rewrite my radio player for wow.

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

@All

Must be great but I don' see anything happening.

I open Notepad, type something and wait ........

regards

ptrex

Does this work for you?

#include <DllCallBack.au3>

Global Const $WH_KEYBOARD_LL = 13
Global $hHook, $pStub_KeyProc
Global $pStub_KeyProc = _DllCallBack ("_KeyProc","int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll","hwnd","GetModuleHandle","ptr",0)
Global $hHook = DllCall("user32.dll","hwnd","SetWindowsHookEx","int", _
            $WH_KEYBOARD_LL,"ptr",$pStub_KeyProc,"hwnd",$hmod[0],"dword",0)
Global $buffer = ""

MsgBox(4096,"","Type anything anywhere and it will appear in the top left corner of the screen.")


While 1
    Sleep(10)
WEnd

Func EvaluateKey($keycode)
    If (($keycode > 22) And ($keycode < 91)) _
        Or (($keycode > 47) And ($keycode < 58)) Then
        $buffer &= Chr($keycode)
        ToolTip($buffer,0,0)
    ElseIf ($keycode > 159) And ($keycode < 164) Then
        Return
    EndIf
EndFunc

Func _KeyProc($nCode, $wParam, $lParam)
    Local $ret,$KEYHOOKSTRUCT
    If $nCode < 0 Then
        $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                        "int",$nCode,"ptr",$wParam,"ptr",$lParam)
        Return $ret[0]
    EndIf
    If $wparam = 256 Then
        $KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr",$lParam)
        EvaluateKey(DllStructGetData($KEYHOOKSTRUCT,1))
    EndIf
    $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                    "int",$nCode,"ptr",$wParam,"ptr",$lParam)
    Return $ret[0]
EndFunc

Func OnAutoItExit()
    DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0])
EndFunc
Link to comment
Share on other sites

have created a little example application for it, needs some cleanup and more easy code, a lot of error handling, but works <_<

it listens to your keyboard for free definable texts and runs a function for example a sreaming radio client. :)

wonderful for "World of Warcraft" due to the fact that you can control this "addon" like a normal one through the chat window :P

the commands are:

/radio on

/radio off

/radio play

/radio pause

/radio stop

/radio vol 0-100

/radio exit

the stream as been compiled in but can easily be changed in the source code.

you just need the ampx_install.exe which comes from Nullsoft as activex replacement of Winamp :D

download here: http://pdl.stream.aol.com/downloads/aol/unagi/ampx_en_dl.cab

extract the ampx.exe out of it and name it ampx_install.exe to be able to recompile the recompile the script.

its needs this file cause it has a build in install routine on foreign machines which do not support this activex :lol:

feel free to enhance the code.

but for me watching the eyes of my collegues thinking my notepad plays radio streams was an amazeing feeling :)

#include <DllCallBack.au3>
#include <string.au3>

Global $url = "http://scfire-nyk-aa04.stream.aol.com:80/stream/1018" 
Global $track[1]
$track[0] = "Kein Titel verfügbar." 

#region shortcuts
Global Const $RADIO_ON = "7RADIO ON" 
Global Const $RADIO_OFF = "7RADIO OFF" 
Global Const $RADIO_PLAY = "7RADIO PLAY" 
Global Const $RADIO_PLAY_CLIP = "7RADIO PLAY CLIP" 
Global Const $RADIO_PAUSE = "7RADIO PAUSE" 
Global Const $RADIO_VOLUME = "7RADIO VOL" 
Global Const $RADIO_EXIT = "7RADIO EXIT" 
#endregion shortcuts

#region constants
Global Const $WINAMPX_EVENT_FILE_END = 1
Global Const $WINAMPX_EVENT_TRACK_CHANGED = 2
Global Const $WINAMPX_EVENT_LAUNCH_URL = 3
Global Const $WINAMPX_EVENT_TRACK_INFO_CHANGED = 4
Global Const $WINAMPX_EVENT_VIDEO_WND_REQUESTED = 5
Global Const $WINAMPX_EVENT_VIDEO_WND_SIZE_CHANGED = 6
Global Const $WINAMPX_EVENT_VIDEO_WND_DONE = 7
Global Const $WINAMPX_EVENT_HWND_READY = 8
Global Const $WINAMPX_EVENT_NO_SOUNDCARD_AVL = 100
Global Const $WINAMPX_EVENT_NO_PLUGINS_AVL = 101
Global Const $WINAMPX_EVENT_CANT_PLAY_FILE = 102
Global Const $WINAMPX_EVENT_WMA_FILE_EXPIRED = 103
Global Const $WINAMPX_EVENT_FILE_NOT_FOUND = 104
Global Const $WINAMPX_EVENT_PLAYLIST_NO_FILES_PRESENT = 105
Global Const $WINAMPX_EVENT_PLAYLIST_EMPTY = 106
Global Const $WINAMPX_EVENT_REAL_ENGINE_MISSING = 107
Global Const $WINAMPX_EVENT_CORRUPT_FILE = 108
Global Const $WINAMPX_EVENT_UNSUPPORTED_FORMAT = 109
Global Const $WINAMPX_EVENT_QUICKTIME_ENGINE_MISSING = 110
Global Const $WINAMPX_EVENT_REAL_ENGINE_ERROR = 111
Global Const $WINAMPX_EVENT_FILE_SYSTEM_CHANGE = 112
Global Const $WINAMPX_STATUS_INIT_WININET = 200
Global Const $WINAMPX_STATUS_OPENING_URL = 201
Global Const $WINAMPX_STATUS_HTTP_ERROR = 202
Global Const $WINAMPX_STATUS_DOWNLOADING_URL = 203
Global Const $WINAMPX_STATUS_URL_DOWNLOADED = 204
Global Const $WINAMPX_STATUS_CANNOT_CREATE_TEMP_FILE = 205
Global Const $WINAMPX_STATUS_CANNOT_OPEN_URL = 206
Global Const $WINAMPX_STATUS_CONNECTION_LOST = 207
Global Const $WINAMPX_STATUS_PREBUFFERING = 208
Global Const $WINAMPX_STATUS_RESYNC = 209
Global Const $WINAMPX_STATUS_BROADCAST_INTERRUPT = 210
Global Const $WINAMPX_STATUS_BROADCAST_TERMINATE = 211
Global Const $WINAMPX_STATUS_DOLBY_ERROR = 212
Global Const $WINAMPX_STATUS_TRANSFER_RATE = 213
Global Const $WINAMPX_STATUS_STREAM_BEGIN = 214
Global Const $WINAMPX_STATUS_LENGTH_CHANGE = 215
Global Const $WINAMPX_STATUS_VIDEO_KEYPRESS = 216
Global Const $WINAMPX_STATUS_VIDEO_SYSKEYPRESS = 217
Global Const $WINAMPX_STATUS_SERVER_RESTART = 218
Global Const $WINAMPX_STATUS_SERVER_CRASH = 219
Global Const $WINAMPX_STATUS_ERROR_KILLING_THREAD = 220
Global Const $WINAMPX_STATUS_ADVANCED_PARSE_ERROR = 221
Global Const $WINAMPX_STATUS_SERVER_SWAPPED = 222
Global Const $STATUS_STOPED = 0
Global Const $STATUS_PLAYING = 1
Global Const $STATUS_PAUSED = 2
Global Const $STATUS_BUFFERING = 3

Global Const $WH_KEYBOARD_LL = 13
Global $hHook, $pStub_KeyProc
Global $pStub_KeyProc = _DllCallBack ("_KeyProc", "int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll", "hwnd", "GetModuleHandle", "ptr", 0)
Global $hHook = DllCall("user32.dll", "hwnd", "SetWindowsHookEx", "int", $WH_KEYBOARD_LL, "ptr", $pStub_KeyProc, "hwnd", $hmod[0], "dword", 0)
Global $buffer = "", $record = 0
#endregion

#region install ampx and create object
$oAMPX = ObjCreate("WinAmpX.IWinAmpActiveX.2")
If Not IsObj($oAMPX) Then
    Beep(6000, 1000)
    FileInstall("ampx_install.exe", "ampx_install.exe", 1)
    RunWait("ampx_install.exe", @ScriptDir)
    If @Compiled Then FileDelete("ampx_install.exe")
    $timeout = 10
    While Not IsObj($oAMPX)
        $oAMPX = ObjCreate("WinAmpX.IWinAmpActiveX.2")
        Sleep(1000)
        $timeout -= 1
        If Not $timeout Then no_object()
    WEnd
EndIf

$EventObject = ObjEvent($oAMPX, "AMPXEvent_")
If @error Then MsgBox(0, "Taddy Radio", "Titelinformationen konnten nicht ausgelesen werden, " & @CRLF & "Da das Winamp Event Modul nicht registriert werden konnte.")

Func no_object()
    MsgBox(0, "Taddy Radio", "Anwendung konnte nicht gestartet werden da AmpX nicht installiert werden konnte.")
    Exit
EndFunc   ;==>no_object
#endregion

#region main LOOP
While 1
    Sleep(10)
WEnd
#endregion main LOOP

#region key hooks
Func EvaluateKey($keycode)
    If (($keycode = 13) And ($record = 0)) Then
        Beep(5000, 10)
        $record = 1
        $buffer = ""
    ElseIf (($keycode = 13) And ($record = 1)) Then
        Beep(3000, 10)
        $record = 0
;~      ToolTip($buffer, 0, 0) ; debugging
        Switch $buffer
            Case $RADIO_ON
                For $s = 1000 To 5000 Step 1000
                    Beep($s, 1)
                Next
                radio_on()
            Case $RADIO_OFF
                For $s = 5000 To 1000 Step - 1000
                    Beep($s, 1)
                Next
                radio_off()
            Case $RADIO_PLAY
                For $s = 1000 To 5000 Step 1000
                    Beep($s, 1)
                Next
                radio_play()
            Case $RADIO_PAUSE
                For $s = 5000 To 1000 Step - 1000
                    Beep($s, 1)
                Next
                radio_pause()
            Case $RADIO_PLAY_CLIP
                For $s = 1000 To 5000 Step 1000
                    Beep($s, 1)
                Next
                radio_play_clip()
            Case $RADIO_EXIT
                For $s = 100 To 10 Step - 1
                    Beep($s, 1)
                Next
                radio_exit()
        EndSwitch
        If ((StringLeft($buffer, (StringLen($RADIO_VOLUME) + 1)) = $RADIO_VOLUME & " ") And (StringLen($buffer) > (StringLen($RADIO_VOLUME) + 1)) And (StringLen($buffer) < (StringLen($RADIO_VOLUME) + 5))) Then
            If Not StringRegExp(StringRight($buffer, StringLen($buffer) - (StringLen($RADIO_VOLUME) + 1)), "[^0-9]") Then
                If (StringRight($buffer, StringLen($buffer) - (StringLen($RADIO_VOLUME) + 1)) >= 0) And (StringRight($buffer, StringLen($buffer) - (StringLen($RADIO_VOLUME) + 1)) <= 100) Then
                    radio_vol(StringRight($buffer, StringLen($buffer) - (StringLen($RADIO_VOLUME) + 1)))
                EndIf
            EndIf
        EndIf
    EndIf
    
    If ((($keycode > 64) And ($keycode < 91)) Or (($keycode > 46) And ($keycode < 58)) Or ($keycode = 32) And $record) Then
        $buffer &= Chr($keycode)
    ElseIf ($keycode > 159) And ($keycode < 164) Then
        Return
    ElseIf ($keycode = 8) Then
        $buffer = StringTrimRight($buffer, 1)
    EndIf
EndFunc   ;==>EvaluateKey

Func _KeyProc($nCode, $wParam, $lParam)
    Local $ret, $KEYHOOKSTRUCT
    If $nCode < 0 Then
        $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook[0], "int", $nCode, "ptr", $wParam, "ptr", $lParam)
        Return $ret[0]
    EndIf
    If $wParam = 256 Then
        $KEYHOOKSTRUCT = DllStructCreate("dword;dword;dword;dword;ptr", $lParam)
        EvaluateKey(DllStructGetData($KEYHOOKSTRUCT, 1))
    EndIf
    $ret = DllCall("user32.dll", "long", "CallNextHookEx", "hwnd", $hHook[0], _
            "int", $nCode, "ptr", $wParam, "ptr", $lParam)
    Return $ret[0]
EndFunc   ;==>_KeyProc

Func OnAutoItExit()
    DllCall("user32.dll", "int", "UnhookWindowsHookEx", "hwnd", $hHook[0])
EndFunc   ;==>OnAutoItExit
#endregion key hooks

#region radio functions
Func radio_on()
    $oAMPX.AppendFileToPlaylist ($url);
    $oAMPX.Repeat = 1
    radio_vol(30)
    radio_play()
EndFunc   ;==>radio_on

Func radio_off()
    $oAMPX.Stop ()
EndFunc   ;==>radio_off

Func radio_pause()
    $oAMPX.pause ()
EndFunc   ;==>radio_pause

Func radio_play()
    $oAMPX.Play ()
EndFunc   ;==>radio_play

Func radio_vol($volume)
    $oAMPX.Volume = 2.55 * $volume
EndFunc   ;==>radio_vol

Func radio_exit()
    radio_off()
    $oAMPX = 0
    Exit
EndFunc   ;==>radio_exit
#endregion radio functions

#region radio events
Func AMPXEvent_WinampMetaData($s, $n)
    $track = _StringBetween($s, "StreamTitle='", "';")
    If @error Then
        $track[0] = "Kein Titel verfügbar." 
    EndIf
    TraySetToolTip($track[0])
    ConsoleWrite("Title: " & $track[0] & @CRLF)
EndFunc   ;==>AMPXEvent_WinampMetaData

#endregion radio events

#region clip get stream url

Func radio_play_clip()
    $clip = ClipGet()
    If (StringInStr($clip, "http://") And (Not StringInStr($clip, @CRLF))) Then
        $url = $clip
        radio_off()
        radio_on()
    EndIf
EndFunc   ;==>radio_play_clip

Best regards,

JR

Edited by JRSmile
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

can not modify above post without crashing autoit code.....

will add features like:

play stream url from clipboard

announce title information <_<

$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

can not modify above post without crashing autoit code.....

will add features like:

play stream url from clipboard

announce title information <_<

This is known BUG in AutoIt code tag editor (on this forum).

When I need edit my post containing autoit code tags I use FireFox and Full edit (no quick edit) then it's OK.

In Opera/IE AutoIt code is mangled.

BTW: nice code example

EDIT: spell correction

Edited by Zedna
Link to comment
Share on other sites

Ummmmmm just curious and I'm stupid for posting this but couldn't some little noob come a long and turn this into a keylogger :-/

Did you not read all the crap posted in this topic yesterday? Suggest you read it, and leave it alone.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

Mouse Gesture... this is for me to link to ... try not to gum up this thread too much.

#include <DllCallBack.au3>

SplashTextOn("","Getsures are:" & @LF & _
            "Left - Up - Right" & @LF & _
            "Right - Down - Left" & @LF & _
            "The letter Z" & @LF & _
            "Up - Down ... to exit",200,200,-1,-1,1)

;Global Const $WH_KEYBOARD_LL = 13
Global Const $WH_MOUSE_LL = 14

Global $timer = TimerInit()

Global $hHook
Global $pStub_MouseProc = _DllCallBack ("_MouseProc","int;ptr;ptr")
Global $hmod = DllCall("kernel32.dll","hwnd","GetModuleHandle","ptr",0)
Global $hHook = DllCall("user32.dll","hwnd","SetWindowsHookEx","int", _
            $WH_MOUSE_LL,"ptr",$pStub_MouseProc,"hwnd",$hmod[0],"dword",0)

Global $last = "0",$last1 = 0,$last2 = 0, $last3 = 0
Global $gesture = ""
Global $xy = MouseGetPos()

While 1
    Sleep(3)
WEnd


Func Gesture()
    ;ToolTip($gesture)   ; DEBUG
    Switch $gesture
        Case "425" ; Left, Up, Right - Hard edge C
            ToolTip("Left, Up, Right")
            $gesture = ""
            $timer = TimerInit()
        Case "574" ; Right, Down, Left
            ToolTip("Right, Down, Left")
            $gesture = ""
            $timer = TimerInit()
        Case "27" ; Up, Down - Hard edge C
            ToolTip("Up, Down ... Exits")
            $gesture = ""
            $timer = TimerInit()
            Exit
        Case "565" ; Z
            ToolTip("The Letter ""Z""")
            $gesture = ""
            $timer = TimerInit()
    EndSwitch
EndFunc


Func EvaluatePoint($x,$y)
    Local $direction
    
    If TimerDiff($timer) > 1500 Then
        $timer = TimerInit()
        $gesture = ""
        $last1 = 0
        $last2 = 0
        $last3 = 0
        $last = "0"
    EndIf
    
    If $x < ($xy[0] - 30) Then
        If $y < ($xy[1] - 15) Then
            $direction = 1
        ElseIf $y > ($xy[1] + 16) Then
            $direction = 6
        Else
            $direction = 4
        EndIf
    ElseIf $x > ($xy[0] + 30) Then
        If $y < ($xy[1] - 16) Then
            $direction = 3
        ElseIf $y > ($xy[1] + 16) Then
            $direction = 8
        Else
            $direction = 5
        EndIf
    ElseIf $y < ($xy[1] - 30) Then
        If $x < ($xy[0] - 16) Then
            $direction = 1
        ElseIf $x > ($xy[0] + 16) Then
            $direction = 3
        Else
            $direction = 2
        EndIf
    ElseIf $y > ($xy[1] + 30) Then
        If $x < ($xy[0] - 16) Then
            $direction = 6
        ElseIf $x > ($xy[0] + 16) Then
            $direction = 8
        Else
            $direction = 7
        EndIf
    Else
        Return
    EndIf
    
    If $last1 = 0 Then
        $last1 = $direction
        Return
    ElseIf $last2 = 0 Then
        $last2 = $direction
        Return
    Else 
        $last3 = $last1 & $last2 & $direction
        ;ToolTip($last3)   ; DEBUG
        $direction = EvaluateDirection()
        $last1 = 0
        $last2 = 0
        $last3 = 0
    EndIf
    
    If Not ($direction == $last) Then
        $last = $direction
        $gesture &= $direction
        If StringLen($gesture) = 2 Then $timer = TimerInit()
        Gesture()
    EndIf
    
    $xy[0] = $x
    $xy[1] = $y
EndFunc

Func EvaluateDirection()
    Local $n = 1
    While StringLen($last3) And $n < 10
        $last3 = StringReplace($last3,String($n),"")
        If @extended > 1 Then Return $n
        $n += 1
    WEnd
EndFunc

Func _MouseProc($nCode, $wParam, $lParam)
    Local $ret,$MOUSEHOOKSTRUCT
    If $nCode < 0 Then
        $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                        "int",$nCode,"ptr",$wParam,"ptr",$lParam)
        Return $ret[0]
    EndIf
    If $wparam = 512 Then
        $MOUSEHOOKSTRUCT = DllStructCreate("int;int;dword;dword;dword;ptr",$lParam)
        EvaluatePoint(DllStructGetData($MOUSEHOOKSTRUCT,1), _
                        DllStructGetData($MOUSEHOOKSTRUCT,2))
    EndIf
    $ret = DllCall("user32.dll","long","CallNextHookEx","hwnd",$hHook[0], _
                    "int",$nCode,"ptr",$wParam,"ptr",$lParam)
    Return $ret[0]
EndFunc

Func OnAutoItExit()
    DllCall("user32.dll","int","UnhookWindowsHookEx","hwnd",$hHook[0])
    _DllCallBack_Free ($pStub_MouseProc)
    Sleep(2000)
EndFunc

Lar

Edited by LarryDalooza

f_mrcleansmalm_77ce002.jpgAutoIt has helped make me wealthy

Link to comment
Share on other sites

ok sorry, just dont want autoit to get a bad name like C++ and all that other crap

Lol Ashley, AutoIt is programmed in C++ <_< (and other crap like this) Edited by Gif
Link to comment
Share on other sites

  • 2 weeks later...

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