zeffy Posted December 27, 2010 Posted December 27, 2010 I'm trying to translate this some constants, and some more constants into Autoit, but I don't really know that much about structs and pointers..This is what I have so far, some of it works, but a lot of it is probably broken/needs to be re-written.expandcollapse popup#include <WindowsConstants.au3> #include <SendMessage.au3> #include <ProcessConstants.au3> #include <WinAPI.au3> #include <Memory.au3> Global Const $PLAYER_STATUS_CLOSED = -1 Global Const $PLAYER_STATUS_STOPPED = 0 Global Const $PLAYER_STATUS_PAUSED = 1 Global Const $PLAYER_STATUS_PLAYING = 2 Global Const $WM_WA_IPC = $WM_USER Global Const $IPC_GETVERSION = 0 Global Const $IPC_ISPLAYING = 104 Global Const $IPC_GETOUTPUTTIME = 105 Global Const $IPC_GETLISTPOS = 125 Global Const $IPC_GETPLAYLISTFILE = 211 Func get_winamp_info() $hWnd = WinGetHandle("[CLASS:Winamp v1.x]") If WinExists($hWnd) Then $version = Int(_SendMessage($hWnd, $WM_WA_IPC, 1, $IPC_GETVERSION)) ConsoleWrite("Winamp version " & $version) $processId = WinGetProcess($hWnd) $hProcess = _WinAPI_OpenProcess($PROCESS_ALL_ACCESS, 0, $processId) If @error Then ConsoleWrite("Failed to open winamp process") EndIf $playing = Int(_SendMessage($hWnd, $WM_WA_IPC, 1, $IPC_ISPLAYING)) Switch $playing Case 0 $status = $PLAYER_STATUS_STOPPED Case 2 $status = $PLAYER_STATUS_PLAYING Case 3 $status = $PLAYER_STATUS_PAUSED EndSwitch $position = Int(_SendMessage($hWnd, $WM_WA_IPC, 0, $IPC_GETLISTPOS)) $address = _SendMessage($hWnd, $WM_WA_IPC, $position, $IPC_GETPLAYLISTFILE) If Int($address) > 1 And $version <> 8345 Then $wfilename = DllStructCreate("char[512]") _WinAPI_ReadProcessMemory($hProcess, $address, $wfilename, 512, 0) winamp_get_w($wfilename, ;... Else ConsoleWrite("Failed to find winamp window. Assuming player is off") EndIf EndFunc ;==>get_winamp_info Func winamp_get_w($filename, $key, $dest) $winamp_info = _MemVirtualAllocEx($hProcess, 0, 4096, $MEM_COMMIT, $PAGE_READWRITE) If @error Then ConsoleWrite("VirtualAllocEx in winamp process failed") Return False EndIf $winamp_filename = $winamp_info + 1024 $winamp_key = $winamp_info + 2048 $winamp_value = $winamp_info + 3072 ;...I'm not asking anyone to re-write my code, I just need a push in the right direction. But if you feel led to, please do
zeffy Posted December 27, 2010 Author Posted December 27, 2010 Yeah, I found that first, actually, but it is far from complete and doesn't have most of the IPC commands I need.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now