Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

why does function AccSetRunningUtilityState will still reduce all sounds including this window? #171

Open
jiandanfs opened this issue Jun 28, 2024 · 0 comments

Comments

@jiandanfs
Copy link

import koffi from 'koffi'
const oleacc = koffi.load('oleacc.dll');
const user32 = koffi.load('user32.dll');

const DWORD = koffi.alias('DWORD', 'uint32_t');
const HANDLE = koffi.pointer(koffi.opaque('HANDLE'));
const HWND = koffi.alias('HWND', HANDLE);
const ANRUS_PRIORITY_AUDIO_ACTIVE = 0x0000004;
const ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK = 0x0000008;

const getHwnd = user32.func('HWND __stdcall GetForegroundWindow()');
const voiceChange = oleacc.func('int __stdcall AccSetRunningUtilityState(HWND hwndApp, DWORD dwUtilityStateMask, DWORD dwUtilityState)');

const hwnd = getHwnd();

ipcMain.on('voice-down', () => {
    voiceChange (hwnd, ANRUS_PRIORITY_AUDIO_ACTIVE | ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK, ANRUS_PRIORITY_AUDIO_ACTIVE | ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK)
  })
ipcMain.on('voice-up', () => {
    voiceChange(hwnd, ANRUS_PRIORITY_AUDIO_ACTIVE | ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK, ANRUS_PRIORITY_AUDIO_ACTIVE_NODUCK)
  })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant