嗨, 我希望增加和减少第三方应用程序中 slider /轨迹栏的值。是否可以使用 sendMessage() 执行相同的操作。我已经拿到了 slider 的 handle 。有人可以帮忙吗? 谢谢。
最佳答案
首先像这样定义SendMessage函数
[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);
然后像这样更新 slider 位置
uint TBM_GETPOS = 0x0400;
uint TBM_SETPOS = 0x0405;
IntPtr hWnd = ...
IntPtr pos = SendMessage(hWnd, TBM_GETPOS, 0, 0);
SendMessage(hWnd, TBM_SETPOS, 1, pos.ToInt32() + 1);
使用获取最大和最小可用位置
uint TBM_GETRANGEMAX = 0x0402;
uint TBM_GETRANGEMIN = 0x0401;
IntPtr max = SendMessage(hWnd, TBM_GETRANGEMAX, 0, 0);
IntPtr min = SendMessage(hWnd, TBM_GETRANGEMIN, 0, 0);
关于c# - 如何使用 sendmessage 和 c# 增加第三方应用程序中轨迹栏/ slider 的值(value)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4717725/