Вверх ↑
Ответов: 783
Рейтинг: 168
#1: 2022-08-04 19:52:31 ЛС | профиль | цитата
Пример того, как можно управлять ползунком громкости (то, что показал Леонид).
Предупреждаю. если в пути к будут русские буквы, то программа работать не будет.

Add(MainForm,2953706,175,140)
{
Height=160
Point(onClose)
link(onCreate,15404514:doEvent1,[])
link(onClose,16754451:doConsoleTerminate,[(235,167)(235,174)])
}
Add(WinExec,16754451,392,140)
{
FileName="powershell"
Param="-NoExit"
Mode=0
Point(onConsoleResult)
Point(onConsoleError)
Point(doConsoleExec)
Point(doConsoleInput)
Point(doConsoleTerminate)
}
Add(FormatStr,4865384,280,161)
{
Mask="Add-Type -TypeDefinition @'\r\nusing System.Runtime.InteropServices;\r\n[Guid("5CDF2C82-841E-4546-9722-0CF74078229A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\r\ninterface IAudioEndpointVolume {\r\n // f(), g(), ... are unused COM method slots. Define these if you care\r\n int f(); int g(); int h(); int i();\r\n int SetMasterVolumeLevelScalar(float fLevel, System.Guid pguidEventContext);\r\n int j();\r\n int GetMasterVolumeLevelScalar(out float pfLevel);\r\n int k(); int l(); int m(); int n();\r\n int SetMute([MarshalAs(UnmanagedType.Bool)] bool bMute, System.Guid pguidEventContext);\r\n int GetMute(out bool pbMute);\r\n}\r\n[Guid("D666063F-1587-4E43-81F1-B948E807363F"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\r\ninterface IMMDevice {\r\n int Activate(ref System.Guid id, int clsCtx, int activationParams, out IAudioEndpointVolume aev);\r\n}\r\n[Guid("A95664D2-9614-4F35-A746-DE8DB63617E6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]\r\ninterface IMMDeviceEnumerator {\r\n int f(); // Unused\r\n int GetDefaultAudioEndpoint(int dataFlow, int role, out IMMDevice endpoint);\r\n}\r\n[ComImport, Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")] class MMDeviceEnumeratorComObject { }\r\npublic class Audio {\r\n static IAudioEndpointVolume Vol() {\r\n var enumerator = new MMDeviceEnumeratorComObject() as IMMDeviceEnumerator;\r\n IMMDevice dev = null;\r\n Marshal.ThrowExceptionForHR(enumerator.GetDefaultAudioEndpoint(/*eRender*/ 0, /*eMultimedia*/ 1, out dev));\r\n IAudioEndpointVolume epv = null;\r\n var epvid = typeof(IAudioEndpointVolume).GUID;\r\n Marshal.ThrowExceptionForHR(dev.Activate(ref epvid, /*CLSCTX_ALL*/ 23, 0, out epv));\r\n return epv;\r\n }\r\n public static float Volume {\r\n get {float v = -1; Marshal.ThrowExceptionForHR(Vol().GetMasterVolumeLevelScalar(out v)); return v;}\r\n set {Marshal.ThrowExceptionForHR(Vol().SetMasterVolumeLevelScalar(value, System.Guid.Empty));}\r\n }\r\n public static bool Mute {\r\n get { bool mute; Marshal.ThrowExceptionForHR(Vol().GetMute(out mute)); return mute; }\r\n set { Marshal.ThrowExceptionForHR(Vol().SetMute(value, System.Guid.Empty)); }\r\n }\r\n}\r\n'@ \r\n\r\n"
link(onFString,15996612:doWork2,[])
}
Add(Hub,15404514,245,154)
{
link(onEvent1,16754451:doConsoleExec,[])
link(onEvent2,4865384:doString,[])
}
Add(FormatStr,15775164,280,210)
{
DataCount=1
Mask="[Audio]::Volume = %1\r\n"
link(onFString,15996612:doWork3,[(354,216)])
}
Add(HubEx,15996612,350,161)
{
link(onEvent,16754451:doConsoleInput,[])
}
Add(ScrollBar,15830206,119,210)
{
Left=25
Top=50
Width=310
Max=100
Page=10
Position=100
link(onPosition,2432806:doText,[])
}
Add(Math,13696707,231,210)
{
OpType=3
Op2=100
link(onResult,15775164:doString,[])
}
Add(Edit,2432806,175,210)
{
Left=160
Top=80
Text=""
DataType=2
link(onChange,13696707:doOperation,[])
}

карма: 15

0