Code: Select all
PostMessage, 0x111, 18816, 0, , Windows Media Player ; to decrease vol
PostMessage, 0x111, 18815, 0, , Windows Media Player ; to encrease vol
It worked in My PC but not well. I don't know how to make better ?
Anyone can help me code for show Volume in Window Media player ?
Sometime address is 0x****D934, sometime is 0x****D904, sometime is 0x****D94C, etc...
Code: Select all
WMPMusic:
Loop,
{
Process,exist,wmplayer.exe
If ErrorLevel
{
WinGet,VarPID,PID,%WMP%
IniWrite,%VarPID%,%Fileini%,WMP,PID
Sleep,500
ToolTip,Searching,900,0,20
Loop,10
{
PostMessage,0x111,18815,0,,%WMP% ;to increase vol
Sleep,10
}
IniRead,Temp,%Fileini%,WMP,Temp
Loop,
{
AmLuong := ReadMemory(Temp,"wmplayer.exe")
If (AmLuong = 100)
{
Loop,
{
AmLuong := ReadMemory4B(Temp,"wmplayer.exe")
If (AmLuong = 100)
{
SetFormat,Integer,H
Temp := Temp
IniWrite,%Temp%,%Fileini%,WMP,ADDR
SetFormat,Integer,D
Break
}
Temp += 0x10000
}
Break
}
Temp += 0x10000
}
ToolTip,,,,20
Break
}
Sleep,100
}
Return
That script very basic )
and 2 hotkeys for change volume
Code: Select all
$+^WheelUp::
IniRead,LoadPID,%Fileini%,WMP,PID
If (LoadPID = "")
{
GoSub,WMPMusic
}
Else
{
Process,Exist,%LoadPID%
If !ErrorLevel
{
GoSub,WMPMusic
}
}
PostMessage,0x111,18815,0,,%WMP% ;to decrease vol
IniRead,ADDR,%Fileini%,WMP,ADDR
AmLuong := ReadMemory(ADDR,"wmplayer.exe")
ToolTip,WMP[%LoadPID%]:%AmLuong%,900,0,20
SetTimer,CCTT,-250
IfWinNotActive,%WinBnS%
{
Send,{WheelUp}
}
Return
$+^WheelDown::
IniRead,LoadPID,%Fileini%,WMP,PID
If (LoadPID = "")
{
GoSub,WMPMusic
}
Else
{
Process,Exist,%LoadPID%
If !ErrorLevel
{
GoSub,WMPMusic
}
}
PostMessage,0x111,18816,0,,%WMP% ;to decrease vol
IniRead,ADDR,%Fileini%,WMP,ADDR
AmLuong := ReadMemory(ADDR,"wmplayer.exe")
ToolTip,WMP[%LoadPID%]:%AmLuong%,900,0,20
SetTimer,CCTT,-250
IfWinNotActive,%WinBnS%
{
Send,{WheelDown}
}
Return
CCTT:
ToolTip,,,,20
Return
Code: Select all
ReadMemory(MADDRESS,PROGRAM)
{
Process, wait, %PROGRAM%, 0.1
pid = %ErrorLevel%
VarSetCapacity(MVALUE,4)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS, "Str", MVALUE, "Uint",4, "Uint *",0)
result := *(&MVALUE)
return result
}
ReadMemory4B(MADDRESS,PROGRAM)
{
Process, wait, %PROGRAM%, 0.1
pid = %ErrorLevel%
VarSetCapacity(MVALUE,4)
ProcessHandle := DllCall("OpenProcess", "Int", 24, "Char", 0, "UInt", pid, "UInt")
DllCall("ReadProcessMemory", "UInt", ProcessHandle, "UInt", MADDRESS, "Str", MVALUE, "Uint",4, "Uint *",0)
Loop,4
result += *(&MVALUE + A_Index-1) << 8*(A_Index-1)
return result
}