Jump to content

_SendMessage


Recommended Posts

I'm not entirely sure how this function works but ive been trying to figure out how to send a key to a window with it all i found was this code for clicking the mouse in a window:

Func CtrlMouse($WindowName, $WindowText , $ControlID, $X_Coord, $Y_Coord)
    If WinExists($WindowName) Then
   ;mouse down
        DllCall("user32.dll", "int", "SendMessage", "hwnd",  ControlGetHandle ( $WindowName, $WindowText, $ControlID ), "int",   0x0201, "int",   BitOR (0x0001, 0x0008), "long",  _MakeLong($X_Coord, $Y_Coord))
   ;mouse up
        DllCall("user32.dll", "int", "SendMessage", "hwnd",  ControlGetHandle ( $WindowName, $WindowText, $ControlID ), "int",   0x0202, "int", 0x0001, "long",  _MakeLong($X_Coord, $Y_Coord))
    Else
        SetError(1)
    EndIf
EndFunc 

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

So does anyone know how to send keys instead of a mouse click?

[quote name='PsaltyDS' post='635433' date='Jan 27 2009, 07:04 AM']Larry is a mass murderer?! It's always the quiet, clean cut, bald guys... [/quote]

Link to comment
Share on other sites

  • Moderators

I'm not entirely sure how this function works but ive been trying to figure out how to send a key to a window with it all i found was this code for clicking the mouse in a window:

Func CtrlMouse($WindowName, $WindowText , $ControlID, $X_Coord, $Y_Coord)
    If WinExists($WindowName) Then
  ;mouse down
        DllCall("user32.dll", "int", "SendMessage", "hwnd",  ControlGetHandle ( $WindowName, $WindowText, $ControlID ), "int",   0x0201, "int",   BitOR (0x0001, 0x0008), "long",  _MakeLong($X_Coord, $Y_Coord))
  ;mouse up
        DllCall("user32.dll", "int", "SendMessage", "hwnd",  ControlGetHandle ( $WindowName, $WindowText, $ControlID ), "int",   0x0202, "int", 0x0001, "long",  _MakeLong($X_Coord, $Y_Coord))
    Else
        SetError(1)
    EndIf
EndFunc 

Func _MakeLong($LoWord,$HiWord)
  Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc

So does anyone know how to send keys instead of a mouse click?

ControlSend()

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...