Click here to Skip to main content
15,888,454 members
Home / Discussions / C#
   

C#

 
AnswerRe: BEGINNER NEEDS HELP Pin
OriginalGriff30-Dec-16 21:03
mveOriginalGriff30-Dec-16 21:03 
QuestionWorking Between Visual Studio and Visual Studio Code Pin
TheOnlyRealTodd30-Dec-16 18:17
professionalTheOnlyRealTodd30-Dec-16 18:17 
AnswerRe: Working Between Visual Studio and Visual Studio Code Pin
Gerry Schmitz31-Dec-16 7:35
mveGerry Schmitz31-Dec-16 7:35 
QuestionLocationChanged to set windowstate=Maximized Pin
Member 830292029-Dec-16 11:51
professionalMember 830292029-Dec-16 11:51 
AnswerRe: LocationChanged to set windowstate=Maximized Pin
Midi_Mick30-Dec-16 2:25
professionalMidi_Mick30-Dec-16 2:25 
AnswerRe: LocationChanged to set windowstate=Maximized Pin
Alan N30-Dec-16 3:49
Alan N30-Dec-16 3:49 
GeneralRe: LocationChanged to set windowstate=Maximized Pin
Member 83029203-Jan-17 6:56
professionalMember 83029203-Jan-17 6:56 
QuestionSimulate Desktop Mouse Scroll (Via C++ PInvoke) Pin
Imagiv29-Dec-16 10:22
Imagiv29-Dec-16 10:22 
I am attempting to simulate a mouse scroll on the desktop screen (Windows 10) and use the following:

C#
SendMessage
(
    GetDesktopWindow(), 
    WM_MOUSEWHEEL, 
    MakeWParam
    (
        LowWord((uint)MK_CONTROL),         
        HighWord
        (
            (uint)System.Windows.Forms.SystemInformation.MouseWheelScrollDelta
        )
    ), 
    MakeLParam(0, 0)
);

const int WM_MOUSEWHEEL = 0x020A;

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

[DllImport("user32.dll", SetLastError = false)]
static extern IntPtr GetDesktopWindow();

public static ushort LowWord(uint val)
{
    return (ushort)val;
}

public static ushort HighWord(uint val)
{
    return (ushort)(val >> 16);
}

private int MakeLParam(int p, int p_2)
{
    return ((p_2 << 16) | (p & 0xFFFF));
}

public static uint MakeWParam(ushort low, ushort high)
{
    return ((uint)high << 16) | (uint)low;
}


I get stuck because I do not know what to replace MK_CONTROL constant with, which is used to create a "low word." I've searched far and wide, but can't find anything as it relates to WM_MOUSEWHEEL.

I got the algorithm itself from this page, but it's all in C++...

Ultimately, I found this article, but it does not suggest it is a constant of any kind or how to use it with SendMessage method.
AnswerRe: Simulate Desktop Mouse Scroll (Via C++ PInvoke) Pin
Gerry Schmitz29-Dec-16 11:13
mveGerry Schmitz29-Dec-16 11:13 
QuestionUnderstanding DbContext Class Pin
Liagapi29-Dec-16 7:00
Liagapi29-Dec-16 7:00 
AnswerRe: Understanding DbContext Class Pin
Dave Kreskowiak29-Dec-16 9:42
mveDave Kreskowiak29-Dec-16 9:42 
AnswerRe: Understanding DbContext Class Pin
John C Rayan30-Dec-16 3:21
professionalJohn C Rayan30-Dec-16 3:21 
GeneralRe: Understanding DbContext Class Pin
Liagapi30-Dec-16 5:58
Liagapi30-Dec-16 5:58 
GeneralRe: Understanding DbContext Class Pin
Jon McKee30-Dec-16 16:18
professionalJon McKee30-Dec-16 16:18 
QuestionSplit Particular Digit using C# Pin
nick70329-Dec-16 2:44
nick70329-Dec-16 2:44 
AnswerRe: Split Particular Digit using C# Pin
Pete O'Hanlon29-Dec-16 2:50
mvePete O'Hanlon29-Dec-16 2:50 
QuestionRe: Split Particular Digit using C# Pin
Peter Leow29-Dec-16 3:33
professionalPeter Leow29-Dec-16 3:33 
AnswerRe: Split Particular Digit using C# Pin
Gerry Schmitz29-Dec-16 10:49
mveGerry Schmitz29-Dec-16 10:49 
GeneralRe: Split Particular Digit using C# Pin
nick70330-Dec-16 1:48
nick70330-Dec-16 1:48 
QuestionIdle Time Pin
AnjanaPrasanth27-Dec-16 21:02
AnjanaPrasanth27-Dec-16 21:02 
AnswerRe: Idle Time Pin
OriginalGriff27-Dec-16 21:32
mveOriginalGriff27-Dec-16 21:32 
QuestionRe: Idle Time Pin
Eddy Vluggen28-Dec-16 1:35
professionalEddy Vluggen28-Dec-16 1:35 
AnswerRe: Idle Time Pin
Gerry Schmitz28-Dec-16 6:09
mveGerry Schmitz28-Dec-16 6:09 
AnswerRe: Idle Time Pin
Dave Kreskowiak28-Dec-16 6:35
mveDave Kreskowiak28-Dec-16 6:35 
GeneralRe: Idle Time Pin
Gerry Schmitz29-Dec-16 10:22
mveGerry Schmitz29-Dec-16 10:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.