c# - 如何使用 sendmessage 和 c# 增加第三方应用程序中轨迹栏/ slider 的值(value)?

标签 c# winapi slider sendmessage

嗨, 我希望增加和减少第三方应用程序中 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/

相关文章:

c# - Entity Framework 更新未保存

c# - 通用局部 View : how to set a generic class as model?

c# - 如何以编程方式与 winlogon 交互?

c# - 将窗口解除 Hook 到其原始状态

c# - 如果我在毫秒内调用太多,为什么 Socket over Tcp 不发送?

c# - 禁用表单的透明度

c++ - 在 Windows 中使用 UTF8 字符串打开文件名

wpf - MVVM 中的绑定(bind) slider 值

android - 单击侧滑菜单中的项目时打开 Webview

jquery - 使用 CSS 动画 slider