min*_*ang 26 c++ windows winapi
我想知道任何类型的API或解决方法(例如,脚本或注册表)将Windows任务栏移动(或调整大小)到另一个位置,包括另一个监视器(如果是双监视器).当然,我们可以使用鼠标移动任务栏,但我想通过程序或某种自动方式移动任务栏.
我试图找到Win32 API,但似乎没有人做这个工作.
编辑:我对许多人的意见感到惊讶.让我解释为什么我想要它.在我的工作场所,我使用的是双显示器(分辨率不同),任务栏放在左侧显示器上,而主显示器是正确的显示器.但是,我经常通过远程桌面连接到我的工作场所计算机.远程连接后,任务栏位置被切换.这就是为什么我想制作一个可以保存/恢复任务栏位置的简单程序.每天我都要重新安排我的任务栏.而已.我只是希望它为我.
我在Windows 7上也有此需求.以下是使用autohotkey脚本执行此操作的方法:
; This script will try to drag and move the taskbar to where the *current* mouse
; cursor is
; 0x111: WM_COMMAND, 424: lock/unlock taskbar, http://www.codeproject.com/KB/miscctrl/Taskbar_Manipulation.aspx
RegRead, TaskbarLocked, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced, TaskbarSizeMove
If TaskbarLocked = 0
SendMessage 0x111, 424, , , ahk_class Shell_TrayWnd
WinActivate ahk_class Shell_TrayWnd
MouseGetPos targetX, targetY
ControlGetPos x, y, w, h, MSTaskListWClass1, ahk_class Shell_TrayWnd
MouseMove x+1, y+1
MouseClickDrag Left, x+1, y+1, targetX, targetY, 10
; often after dragging the taskbar to left or right side of a monitor, even though
; there are enough room to show two columns of icons, it will only show one column,
; it seems showing or hiding an icon will fix this
Menu, Tray, NoIcon
Menu, Tray, Icon
; lock the taskbar if it was previously locked
If TaskbarLocked = 0
SendMessage 0x111, 424, , , ahk_class Shell_TrayWnd
Run Code Online (Sandbox Code Playgroud)
我在Windows 7上使用经典窗口主题测试了这个.要使用此功能,请指定一个热键来调用此脚本,然后将鼠标光标定位到要将任务栏拖动到的位置,然后按热键.
任务栏是一个窗口.使用SetWindowPos()移动它.另请参见SHAppBarMessage()和ABM_WINDOWPOSCHANGED.
虽然任务栏可能很特殊,但Windows可能不喜欢你移动它.任务栏的Shell appbar API实现中有很多特殊情况.
要移动到另一个监视器,请将EnumDisplayMonitors()与GetMonitorInfo()一起使用.某些监视器可能具有负坐标.
据我所知,Vista 及更高版本会忽略任何尝试移动任务栏的程序。旧方法是 ABM_SETPOS + MoveWindow,这在任务栏上不再起作用。我知道仍然有效的唯一方法是模拟鼠标移动(单击-移动-释放)。我读过有关该方法的内容,但我自己从未这样做过。
| 归档时间: |
|
| 查看次数: |
5838 次 |
| 最近记录: |