Jump to content

How to get a process´ ID (PID)


Recommended Posts

hey

im pretty new to writing scripts with auto it, and i need to know how to get a process id....

i already used search, and other common things.

i know the WinGetProcess command, but for some reason it isnt workin

here is an example what actually should work i think but it doesnt

$pid = WinGetProcess ( "Untitled - Notepad" )

ControlSend ( "Untitled - Notepad", "", $pid, "i just dont get it" )

this is just a short example

thx in advance

edit: btw, i want the script to simulate keystrokes in a window, even when its minimized/hidden

Edited by Muffin
Link to comment
Share on other sites

I think you neede a CONTROL ID, not a Process-ID. :D

Instaed of ControlId, you could use ClassNameNN, too

You get it with Au3Info Tool :D

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

Use the CLASSNmeNN, this shouldn't change use "[CLASSNN:ClassnameNNFromAu3Info]"

ControlSend("Unbenannt - Editor","","[CLASSNN:Edit1]","TESTSTTGSHF")
ControlSend ( "Untitled - Notepad","","[CLASSNN:Edit1]","TESTSTTGSHF"

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

nah, okay ty :D

i have one more issue

the autoitwindowinfo programm doesnt show the id, classname and this stuff (from control tab) if i want to get control datas from a game i play called silkroad online.

its just empty then :D

Link to comment
Share on other sites

Tr, if it works, when you let ClassNameNN empty :)

ControlSend("GAME","","","TESTSTTGSHF")

*GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes

Link to comment
Share on other sites

ok.. I rewrote it to fit your game and removed infos about mine so there might be some typos but it should help you a lot :

#include <GUIConstants.au3>
#include <Misc.au3>
#Include <WinAPI.au3>

Opt("GUIOnEventMode", 1)
Opt("WinTitleMatchMode", 2)
$mainwindow = GUICreate("SILK Window Select", 250, 120,0,100)
GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked")
GUICtrlCreateLabel("Select SILK client to activate.", 5, 5)
$selectcharA = GUICtrlCreateButton("Character A",160 , 30, 80)
$selectcharB = GUICtrlCreateButton("Character B",160 , 70, 80)
$startbot = GUICtrlCreateButton("Start bot", 30, 90, 80)
$mylist = GuiCtrlCreateList("", 1, 30, 140, 60)
GUICtrlSetOnEvent($mylist, "ActivateSelected")
GUICtrlSetOnEvent($selectcharA, "CHARAButton")
GUICtrlSetOnEvent($selectcharA, "CHARBButton")
GUICtrlSetOnEvent($startbot, "StartBot")
GUICtrlSetState($startbot, $GUI_DISABLE)
WinSetOnTop("WinSelect", "", 1)
$var = WinList("SILK")
$charAselect = 0
$charBselect = 0
Global $charAhandle, $charBhandle
Global $activehandle

For $i = 1 to $var[0][0]
If $var[$i][0] <> "" AND IsVisible($var[$i][1]) and $var[$i][0] <> "WinSelect" Then
GUICtrlSetData($mylist,$var[$i][0]&" "&$var[$i][1])
EndIf
Next

GUISetState(@SW_SHOW)

While 1
    Sleep(1000)
    If ($charAselect OR $charBselect ) AND GUICtrlGetState($startbot) <> 80 Then 
        GUICtrlSetState($startbot, $GUI_ENABLE)
    EndIf
WEnd

Func ActivateSelected()
    If GUICtrlRead($mylist) <> "" Then
        $silkhandle = StringTrimLeft(GUICtrlRead($mylist), 12)
        WinActivate(HWnd($silkhandle))  
        $activehandle = HWnd($silkhandle)
    Else
        MsgBox(4096, "Error", "Please select a SILK client!")
    EndIf
EndFunc

Func CHARAButton()
    GUICtrlSetState($selectcharA, $GUI_HIDE)
    $charAhandle = WinGetHandle($activehandle)
    $charAselect = 1
EndFunc

Func CHARBButton()
    GUICtrlSetState($selectcharB, $GUI_HIDE)
    $charBhandle = WinGetHandle($activehandle)
    $charBselect = 1
EndFunc

Func startbot()
    MsgBox(0,"","Starting bot...",3)
;~  ----
;~ write your bot here
;~ ---
EndFunc

Func CLOSEClicked()
Exit
EndFunc

Func IsVisible($handle)
    If BitAnd( WinGetState($handle), 2 ) Then 
        Return 1
    Else
        Return 0
    EndIf
EndFunc

Func QuitIt()
    Exit
EndFunc

*cough* no I'm not a botter ! ... ^^" .. or .. am I ?

Edited by MikeP
Link to comment
Share on other sites

ya but the problem is i have the game opened more than once, and i want to send the keys to a certain client/window

Open the helpfile and read about "Controls" specifically INSTANCE.
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...