topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Thursday April 18, 2024, 9:28 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - HwapX [ switch to compact view ]

Pages: [1]
1
You are right about the tooltip, i changed the wrong place.

But the shortcut are correctly, see:
Screenshot_1.png

Try manually deleting it and recreating.

New version with the tooltip fixed: https://github.com/H...ityAdjuster/releases

2
I was traveling last week.
I made the necessary adjustments today.

https://github.com/H...ityAdjuster/releases

3
Maybe Audio Priority Adjuster would be a better name for it. The repository name should be audiopriorityadjuster or aap if you end up using the name that I suggested.
I renamed the repository to AudioPriorityAdjuster, the dc prefix is just to mark that the project is from DonationCoder. Soon I will push the changes that rename the project and executable as well.

1. It turns out that Windows 10 already does what I want. I will use this though to make sure that the audio switches properly.
That was what i observed on my test machine. Anyway I hope the program is useful in some way.

2. Please add the options for having it be minimized to system tray when ran and running on boot in the system tray.
Sure! i just need to find a  way to register the program to be run on startup with Administrative rights, the "common" way wont work if UAC is enabled.

3. I take it that it is monitoring for connections and disconnections, which it then modifies the registry accordingly?
It is monitoring for device changes using the following API, basically it register program to be notified of device changes.
And when the program starts or receive an notification it check the priority list and uses this undocumented API to set the default audio device.


Edit

Done, the new version can be found at releases page on Github https://github.com/H...ityAdjuster/releases

4
Sure, the name of the repository is an acronym for Donation Coder Auto Default Audio Device, but I was pretty sleepy when I created it and named the executable Auto Default Audio Device Switcher. Anyway, if you have a better name suggestion, I can change the name of the repository.

About the repository description, I intend to write a better readme, but that's for next weekend, if I have some spare time.

5
I'm having some problems pushing the code to Github, but if you want you can test the attached executable.



Edit

Published the source code at https://github.com/H...udioPriorityAdjuster

6
Alright, tomorrow I think I'll have something for you to try out.

What do you think about the "priority list"? Does it solves your problem?

7
I'm working on a prototype, but it uses a priority list, sets the default device to the first one connected, and updates it when connecting a new one or disconnecting.



Edit

I've done some experiments and reading the Windows documentation it seems that what you want is almost the default behavior.
https://learn.micros...roperty-in-windows-7

Here I set my speaker as default device, I plugged in my headphone and set it as default, when I remove my headphone Windows sets the speaker as default and when I plug in my headphone it sets it as default

8
Post New Requests Here / Re: Request - file path collector program
« on: September 18, 2021, 09:00 AM »
I know this is an old topic and it's already "resolved", but as the creator requested some features and I'm on vacation and very bored, I made a new version.

PathCollector.png

Features
  • Log paths to selected file
  • Drag and drop
  • Send to integration
  • Clipboard monitoring(log copied file/directories paths)
  • Filter paths by files, directories or both
  • Option to skip duplicates
  • Option to recurse directories path
  • Option to truncate output file every time the program is open
  • Option to set window always on top
  • Option to minimize to tray
  • Option to start with windows

Source and download can be found at https://github.com/HwapX/dcPathCollector

9
Please post some sample data and the expected command to be run.

10
I attached another version that not rely on rundll32, it has your own bootstrap and create an icon at systray, can be closed with double click on icon.

Due how Windows work two distinct versions are need one for 32 bits and another for 64 bits applications.

It was only tested under Windows XP 32 bits, because due my limited ram its the only Windows vm that i can run.

11
Just a proof of concept, this will add an check option "Remember Size/Pos" to Window system menu.

#include <stdio.h>
#include <windows.h>

#define MENU_SEPARATOR_POS 5
#define MENU_SEPARATOR_ID 0x0D10
#define MENU_REMEMBER_ID 0x0C10
#define MENU_REMEMBER_POS 6
#define MENU_REMEMBER_CAPTION "Remember Size/Pos"

#define INFO_FORMAT "x%dy%dw%dh%dm%d"

char *iniPath = NULL;

void WriteData(HWND hwnd, BOOL save) {
char filePath[MAX_PATH];

if(GetModuleFileName(NULL, filePath, MAX_PATH)) {
RECT rect;
char cls[MAX_PATH];
char value[MAX_PATH];
BOOL max = GetWindowLong(hwnd, GWL_STYLE) & WS_MAXIMIZE;
GetWindowRect(hwnd, &rect);
GetClassName(hwnd, cls, MAX_PATH);

sprintf(value, INFO_FORMAT, (int)rect.left, (int)rect.top, (int)(rect.right - rect.left), (int)(rect.bottom - rect.top), max ? 1 : 0);

WritePrivateProfileString(filePath, save ? cls : NULL, value, iniPath);
}
}

BOOL ReadData(HWND hwnd, int *iX, int *iY, int *iW, int *iH, BOOL *bMax) {
char filePath[MAX_PATH];

if(GetModuleFileName(NULL, filePath, MAX_PATH)) {
char value[MAX_PATH];
char cls[MAX_PATH];

GetClassName(hwnd, cls, MAX_PATH);

if(GetPrivateProfileString(filePath, cls, "", value, MAX_PATH, iniPath) && value[0] != '\0') {
sscanf(value, INFO_FORMAT, iX, iY, iW, iH, bMax);
return TRUE;
}
}

return FALSE;
}

__declspec(dllexport) LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam) {
if(nCode == HCBT_CREATEWND) {
CBT_CREATEWND *cbt = (CBT_CREATEWND*)lParam;
HMENU hm = GetSystemMenu((HWND)wParam, FALSE);

if(hm != NULL) {
BOOL max = FALSE;
UINT flags = ReadData((HWND)wParam, &cbt->lpcs->x, &cbt->lpcs->y, &cbt->lpcs->cx, &cbt->lpcs->cy, &max) ? MF_CHECKED : MF_UNCHECKED;

if(max)
cbt->lpcs->style = cbt->lpcs->style | WS_MAXIMIZE;

InsertMenu(hm, MENU_SEPARATOR_POS, MF_BYPOSITION | MF_SEPARATOR, MENU_SEPARATOR_ID, NULL);
InsertMenu(hm, MENU_REMEMBER_POS, MF_BYPOSITION | flags, MENU_REMEMBER_ID, MENU_REMEMBER_CAPTION);
}
} else if(nCode == HCBT_DESTROYWND/*nCode == HCBT_MOVESIZE || nCode == HCBT_MINMAX*/) {
HMENU hm = GetSystemMenu((HWND)wParam, FALSE);

if(hm != NULL)
WriteData((HWND)wParam, GetMenuState(hm, MENU_REMEMBER_ID, MF_BYCOMMAND) & MF_CHECKED);
}

return CallNextHookEx(NULL, nCode, wParam, lParam);
}

BOOL dup = FALSE;
__declspec(dllexport) LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam) {
MSG *msg = (MSG*)lParam;
    if(msg->message == WM_SYSCOMMAND && msg->wParam == MENU_REMEMBER_ID) {
        if(!dup) {
            HMENU hm = GetSystemMenu(msg->hwnd, FALSE);

            UINT flags = GetMenuState(hm, MENU_REMEMBER_ID, MF_BYCOMMAND) & MF_CHECKED ? MF_UNCHECKED : MF_CHECKED;
            ModifyMenu(hm, MENU_REMEMBER_ID, MF_BYCOMMAND | flags, MENU_REMEMBER_ID, MENU_REMEMBER_CAPTION);
        }
        dup = !dup;
}

return CallNextHookEx(NULL, nCode, wParam, lParam);
}

__declspec(dllexport) int Hook() {
HHOOK cbtHook = NULL;
HHOOK wndHook = NULL;

HINSTANCE hDll = GetModuleHandle("spr.dll");
HOOKPROC proc;

if(hDll == NULL)
return -1;

proc = (HOOKPROC)GetProcAddress(hDll, "CBTProc");
cbtHook = SetWindowsHookEx(WH_CBT, proc, hDll, 0);

if(cbtHook == NULL)
return -2;

proc = (HOOKPROC)GetProcAddress(hDll, "GetMsgProc");
wndHook = SetWindowsHookEx(WH_GETMESSAGE, proc, hDll, 0);

if(wndHook == NULL)
return -3;

    Sleep(INFINITE);

UnhookWindowsHookEx(cbtHook);
UnhookWindowsHookEx(wndHook);

return 1;
}

__declspec(dllexport) void CALLBACK Load(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) {
Hook();
}

BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
if(fdwReason == DLL_PROCESS_ATTACH) {
int size;
iniPath = malloc(MAX_PATH);
size = GetModuleFileName(hinstDLL, iniPath, MAX_PATH);
iniPath[size - 3] = 'i';
iniPath[size - 2] = 'n';
iniPath[size - 1] = 'i';
} else if(fdwReason == DLL_PROCESS_DETACH) {
free(iniPath);
}

return TRUE;
}

Compile with
gcc -shared -o spr.dll main.c -Wl,-- kill-at -s -Os

Run with
rundll32 spr.dll,Load
After that, new windows will have the option added and load their size/positions.

To disable, just kill the process. A side effect is that the existing windows will not have the menu removed, this is no big deal, as the option simply does nothing.

Be warned that the code has not been fully tested and can cause problems or unwanted side effects.

Pages: [1]