There's SendKeys command for WshShell object which imitates pressing keys on keyboard. Is there a command which would imitate scrolling a mouse wheel?
1 Answers
I dont know of powershell command to scroll the mouse wheel, but you can embed a C# class in a powershell script/module and you can use C# to scroll a window.
"Basically", you need to use the Windows api PostMessage
in user32.dll
to send a WM_MOUSEWHEEL
message to the Window handle to make that window scroll. User32 is an "unmanaged" dll (part of Windows) and not a dotnet assembly so it requires special handling.
Have a read of these two links - between them they cover roughly what you would need to know to write a powershell function to fake scrolling the mouse of a window yourself:
Example of using c# to scroll a mouse wheel - using DllImport to import "User32.dll" and calling PostMessage to send the window a WM_MOUSEWHEEL event.
Example of embedding a C# assembly in a powershell script. Using
Add-Type
to create an inline c# assembly. This code is sending keyboard messages not mouse messages - but this is pretty similar to what you want to do.
Advanced warning - these are advanced topics and there are plenty of pitfalls using low level operating system functions. Good luck!

- 2,884
- 1
- 10
- 13