Jump to content

controlsend()


Recommended Posts

ok so i want to send a key to a game without having it selected aka i could have it minimized but it would still h it the buttons.

i figure window get handle and control send should work but everything ive tried doesnt work.

[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

Are you sure wingethandle() is getting the handle correctly? Also, you don't need a handle to the window to use controlsend. You can just use the title if you want. Make sure you're calling it correctly too. I think if you leave the text and controlID arguments blank it should work, assuming you have the right access to the window.

Controlsend is kind of picky though, you may have to set the "raw" flag, depending on which keys you're sending...

My Code:- _TocLib - UDF for TOC protocol (The simplified one used by 3rd party AIM/ICQ clients)

Link to comment
Share on other sites

  • Moderators

ControlSend() was fixed in the Beta 3.2.3.0, what version are you currently using?

http://www.autoitscript.com/autoit3/files/beta/autoit/

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

This is the code I used for a simple "left click down + left click up" I needed for a util I am writing using AutoIT. It was written before I knew much about AutoIT (still dont know lots =>) and I think there are constants defined for many window messages someplace I am using constants below.

;================================== 
; Script Name: WinClick
; Author: Kal In Ex 
; Version: 1.0
; AutoIt3 Version: 1.71
; Revision Date: March 12, 2007
; Public Release: March 12, 2007
; Purpose: send mouse click to a window using windows mouse messages
; Copyright: 2007 Kal In Ex
;================================== 

Func WinClick($hWnd, $x, $y); similar to EUO command "click x y f" (can not specify other parameters yet)
    _SendMessage($hWnd, 0x0201, 1, $x + BitShift($y, -16)); 0x0201 = WM_LBUTTONDOWN
    _SendMessage($hWnd, 0x0202, 0, $x + BitShift($y, -16)); 0x0202 = WM_LBUTTONUP
EndFunc

Sending text was a bit more difficult and if you want to use extended key codes using ALT or CONTROL I do not believe there is a work around (window must have focus its a windows limitation). These are the routines I use for text tho just need the windows handle...

;================================== 
; Script Name: WinSendText
; Author: Kal In Ex 
; Version: 1.0
; AutoIt3 Version: 1.71
; Revision Date: March 12, 2007
; Public Release: March 12, 2007
; Purpose: send text to a window using WM_CHAR message
; Copyright: 2007 Kal In Ex
;==================================

Func WinSendText($hWnd, $String)
    Local $Index
    Local $Length = StringLen($String)
    For $Index = 1 To $Length Step 1
        _SendMessage($hWnd, 0x0102, Asc(StringMid($String, $Index)), 0); 0x0102 = WM_CHAR
    Next
EndFunc
Link to comment
Share on other sites

  • Moderators

You've gotten your WinClick() to work in all the windows you have used it for? (Reminds me of MouseClickPlus()).

Edited by SmOke_N

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

  • Moderators

I only use it with 1 game program called Ultima Online

I had always wondered since VB users seem to use that _SendMessage() option a lot, why it rarely ever worked for me. I had always meant to test out the SendInput API function that some swear by, but I couldn't see how to make it Hwnd specific at the time.

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...