Jump to content

Recommended Posts

Posted (edited)

Im trying to do a simple script that sends a controlsend to a PROCESS, instead of a window title.

This doesnt work:

$process = WinGetProcess("Atlantica.exe")

ControlSend($process,"","","x")

This works:

ControlSend("Atlantica Online","","","x")

What am i doing wrong? How do i simply send a command to Atlantica.exe?

Edited by woodyfly
Posted

WinGetProcess

--------------------------------------------------------------------------------

Retrieves the Process ID (PID) associated with a window.

[font="Impact"]Never fear, I is here.[/font]

Posted

You need to specify a title or a window handle. So you need to find a window that belongs to Atlantica.exe. This is not so simple because a process can have more than one window, hidden or not.

PsaltyDS wrote this. I modified it just now to return only a window handle:

; -------------------------------------------------------
; Function:  _ProcessGetWin
; Purpose:  Return window handle on the Window owned by a process (if any)
; Syntax:  _ProcessGetWin($iPID)
;   Where:  $iPID = integer process ID
; Returns:  On success returns window handle:
;   If $iPID does not exist, returns 0 and @error = 1
; Notes:  Not every process has a window, indicated by an empty array and 
;   @error = 0, and not every window has a title
;   to see if a window existed for the process.
; Author:  PsaltyDS at www.autoitscript.com/forum modified by Manadar to return just window handle
; -------------------------------------------------------
Func _ProcessGetWin($iPID)
    Local $avWinList = WinList(), $avRET[2]
    For $n = 1 To $avWinList[0][0]
        If WinGetProcess($avWinList[$n][1]) = $iPID Then 
            Return $avWinList[$n][1]
        EndIf
    Next
    Return SetError(1,0,0)
EndFunc   ;==>_ProcessGetWin

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
  • Recently Browsing   0 members

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