qwertylol Posted February 22, 2007 Posted February 22, 2007 An example of autoit from the installation package: Run("notepad.exe") WinWaitActive("Untitled - Notepad") Send("This is some text.") WinClose("Untitled - Notepad") WinWaitActive("Notepad", "The text in the Untitled file has changed") Send("!n") Well, suppose I want to "send" to specific processes using specificly PID, how do I do that ?
Shevilie Posted February 22, 2007 Posted February 22, 2007 Well I dont know if you can send to PID, but you can send to a window with ControlSend Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
qwertylol Posted February 22, 2007 Author Posted February 22, 2007 Shevilie said: Well I dont know if you can send to PID, but you can send to a window with ControlSendI am reading the help document for this functioncan you explain to me, what is "The text of the window to access."and "The title of the window to access."?
qwertylol Posted February 22, 2007 Author Posted February 22, 2007 well, the problem is that if I do this: ControlSend ( "Untitled", "text", 3456, "string" ) 3456 being the correct PID for notepad.exe, and the definition of the function being ControlSend ( "title", "text", controlID, "string" [, flag] ) it acutally doesn't find the correct process to send keystrokes to. Also, the example conflicts with the definition ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window") It doesn't use PID at all.
Moderators SmOke_N Posted February 22, 2007 Moderators Posted February 22, 2007 (edited) qwertylol said: well, the problem is that if I do this: ControlSend ( "Untitled", "text", 3456, "string" ) 3456 being the correct PID for notepad.exe, and the definition of the function being ControlSend ( "title", "text", controlID, "string" [, flag] ) it acutally doesn't find the correct process to send keystrokes to. Also, the example conflicts with the definition ControlSend("Untitled", "", "Edit1", "This is a line of text in the notepad window") It doesn't use PID at all.What do you think you are sending to the "Process"? Looks to me that you're trying to send something to the process window not the process itself. If this is the case... Then look at making a function to do what you want... $var = WinList() For/Next Loop If WinGetProcess() = PID and $var[n][0] = Window Title Then ControlSend($var[n][1], etc...) This will make sure that the specific processes window (even if it has the same name as another process window) is sent the information you want to send to that specific process window. Edited February 22, 2007 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.
qwertylol Posted February 22, 2007 Author Posted February 22, 2007 SmOke_N said: What do you think you are sending to the "Process"? Looks to me that you're trying to send something to the process window not the process itself. If this is the case... Then look at making a function to do what you want... $var = WinList() For/Next Loop If WinGetProcess() = PID and $var[n][0] = Window Title Then ControlSend($var[n][1], etc...) This will make sure that the specific processes window (even if it has the same name as another process window) is sent the information you want to send to that specific process window. yeah, actually, this person describes what I need better: http://www.autoitscript.com/forum/index.ph...hl=controlfocus "I need to send keystrokes and mouseclicks to more than one processes without focusing them"
Moderators SmOke_N Posted February 22, 2007 Moderators Posted February 22, 2007 qwertylol said: yeah, actually, this person describes what I need better:http://www.autoitscript.com/forum/index.ph...hl=controlfocus"I need to send keystrokes and mouseclicks to more than one processes without focusing them"ControlSend() they even gave you the answer.Again... you keep using the word process, I think you are confusing everyone when you actually mean window... why would anyone send a keystroke (Other than a hotkey) to a process? 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.
qwertylol Posted February 22, 2007 Author Posted February 22, 2007 Ok, this is the definition from the help file ControlSend ( "title", "text", controlID, "string" [, flag] ) The Control ID is the internal numeric identifier that windows gives to each control. It is generally the best method of identifying controls. In addition to the AutoIt Window Info Tool, other applications such as screenreaders for the blind and Microsoft tools/APIs may allow you to get this Control ID. I used this to get that PID dim $list $list = ProcessList() $a_counter = 0 Do $a_counter = $a_counter + 1 Until $list[$a_counter][0] = "notepad.exe" MsgBox (1, "PiD", $list[$a_counter][1] ) So then I expect this to send "string" to it ControlSend ( "Untitled", "text", 3456, "string" ) but it dosen't work out. What went wrong ?
Moderators SmOke_N Posted February 22, 2007 Moderators Posted February 22, 2007 Well, you haven't given a real example... but you expect help (3456 is a made up control id), so without seeing what you actually did, how do you expect to get help? _CtrlSendExeWin('notepad.exe', 'Untitled', '', 3456, 'string') Func _CtrlSendExeWin($sExe, $sWinTitle, $sCtrlText, $nCtrlID, $sSendText, $nFlag = 0) Local $iPID = ProcessExists($sExe) Local $aWL = WinList() For $iCC = 1 To $aWL[0][0] If WinGetProcess($aWL[$iCC][1]) = $iPID And _ StringInStr($aWL[$iCC][0], $sWinTitle) Then Return ControlSend($aWL[$iCC][1], $sCtrlText, $nCtrlID, $sSendText, $nFlag) EndIf Next Return SetError(1, 0, '') EndFunc 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.
qwertylol Posted February 22, 2007 Author Posted February 22, 2007 Ok this is what I did: I started a notepad and then ran this dim $list $list = ProcessList() $a_counter = 0 Do $a_counter = $a_counter + 1 Until $list[$a_counter][0] = "notepad.exe" MsgBox (1, "PiD", $list[$a_counter][1] ) From that MsgBox I read 3456 ( it really did happen to be that ! ) but of course it can be any number. And then, according to this ControlSend ( "title", "text", controlID, "string" [, flag] ) If I run this one while that same notepad is still around: ControlSend ( "Untitled", "text", 3456, "string" ) string should appear in the window of untitled - notepad. I am not showing complete chunk of code because I am write separate pieces separately and am still learning
Moderators SmOke_N Posted February 22, 2007 Moderators Posted February 22, 2007 3456 is the PID not the ControlID, you must use the Window Info Tool provided with AutoIt (AutoInfo.exe) to obtain the ControlID of the control on the window you want to send to. Using the PID won't work. 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.
qwertylol Posted February 22, 2007 Author Posted February 22, 2007 SmOke_N said: 3456 is the PID not the ControlID, you must use the Window Info Tool provided with AutoIt (AutoInfo.exe) to obtain the ControlID of the control on the window you want to send to. Using the PID won't work.Ok. Well, I have to use PID, because I need to send keystrokes and mouse events to 2 instances of the same app
Shevilie Posted February 22, 2007 Posted February 22, 2007 Well get the two different handles... WinGetHandle.. or let the script start the programs Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Moderators SmOke_N Posted February 22, 2007 Moderators Posted February 22, 2007 qwertylol said: Ok. Well, I have to use PID, because I need to send keystrokes and mouse events to 2 instances of the same appI think you need to either explain in GREAT detail on what you are attempting.... or learn the difference between PID = Process ID and a window handle.Have you even bothered to do what I said with the window info tool and the little udf I provided, or are you just being stubborn thinking you know what your talking about (which you might, but obviously you aren't explaining it well enough because this thread hasn't been solved yet). 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.
qwertylol Posted February 23, 2007 Author Posted February 23, 2007 how do i get two difference handles ? $handle = WinGetHandle("Notepad") controlSend($handle, "", "Notepad", "bCdEbCdEbCdEbCdE" ) MsgBox (1, "PiD", $handle) this wont get me two handles even if i have two notepads open
Moderators SmOke_N Posted February 23, 2007 Moderators Posted February 23, 2007 qwertylol said: how do i get two difference handles ?$handle = WinGetHandle("Notepad")controlSend($handle, "", "Notepad", "bCdEbCdEbCdEbCdE" )MsgBox (1, "PiD", $handle)this wont get me two handles even if i have two notepads openLook at the function I posted with WinList()... you can mod it with ProcessList() as well, if you have 2 notepad windows open, you have 2 executables running .Maybe if you would like to actually show what in the heck you are working on... you could/would have your issues solved quite easily . 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.
qwertylol Posted February 23, 2007 Author Posted February 23, 2007 SmOke_N said: Look at the function I posted with WinList()... you can mod it with ProcessList() as well, if you have 2 notepad windows open, you have 2 executables running .Maybe if you would like to actually show what in the heck you are working on... you could/would have your issues solved quite easily .Yes, winlist works !How do I send mouse events to a handle ? Controlsend only does keyboard events.
qwertylol Posted February 23, 2007 Author Posted February 23, 2007 qwertylol said: Yes, winlist works !How do I send mouse events to a handle ? Controlsend only does keyboard events.I am trying to do a converstaion emulator: you know, two windows of msn talking to each other.
Moderators SmOke_N Posted February 23, 2007 Moderators Posted February 23, 2007 qwertylol said: Yes, winlist works ! How do I send mouse events to a handle ? Controlsend only does keyboard events.Theres is this nifty tool ... ShellExecute(@ProgramFilesDir & _Convert('5C4175746F4974335C4175746F4974332E63686D')) MsgBox(64, 'Info', _Convert('436F6E74726F6C') & StringRight('MouseClick', 5)) Func _Convert($sString) Return BinaryString('0x' & $sString) EndFunc 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.
Shevilie Posted February 23, 2007 Posted February 23, 2007 HAHAHA had to run the script - love the tool Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now