gte Posted May 7, 2009 Share Posted May 7, 2009 I saw this post, but it's not helpinghttp://www.autoitscript.com/forum/index.ph...l=active+windowI'm writing a keep alive script, and I want it to do this in the background, and if I'm typing, to not let the characters I'm typing interfere with the characters it sends? I can post my script, but none of you will have the software that I'm using, so I'm not sure how much help it will be.Any ideas on how to send commands to a specific window that is not in focus, does not have a controlid and that I don't want to be in focus, or to interrupt when I'm using my mouse or keyboard for other programs? HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Andreik Posted May 7, 2009 Share Posted May 7, 2009 Run this and then just open a new notepad and try to write what you want but in first notepad will be write "TEST" by 1000 times, without any problem. #include <String.au3> AutoItSetOption("WinTitleMatchMode",2) Run("notepad.exe") WinWait("Notepad") WinSetState("Notepad","",@SW_MINIMIZE) ControlSend("Notepad","","Edit1",_StringRepeat("TEST",1000)) When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Zedna Posted May 7, 2009 Share Posted May 7, 2009 You can also send messages to target window/control by _SendMessage() Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
gte Posted May 7, 2009 Author Share Posted May 7, 2009 (edited) Thanks! EDIT Here is what my code looks like, when I use @sw_minimize, it makes it fail func caprskeepalive() if ProcessExists('scguiw32.exe') then Sleep (5000) Else $caprsusername = @UserName AutoItSetOption("WinTitleMatchMode",2) Run(@ComSpec & " /c " & 'scguiw32.exe -express:caprs.ad.domain.com.1111', "C:\Progra~1\Peregrine\ServiceCenter\RUN\", @SW_HIDE) WinWait("ServiceCenter - [Login]") WinSetState("ServiceCenter - [Login]","",@SW_MINIMIZE) ControlSend("ServiceCenter - [Login]","","",$caprsusername) Sleep(500) controlsend('Service Center - [Login]', '', '', "{enter}"); enter one sleep (1000) Run this and then just open a new notepad and try to write what you want but in first notepad will be write "TEST" by 1000 times, without any problem. #include <String.au3> AutoItSetOption("WinTitleMatchMode",2) Run("notepad.exe") WinWait("Notepad") WinSetState("Notepad","",@SW_MINIMIZE) ControlSend("Notepad","","Edit1",_StringRepeat("TEST",1000)) Edited May 7, 2009 by gte HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
gte Posted May 7, 2009 Author Share Posted May 7, 2009 (edited) Maximize seems to work, so maybe it needs an onfocus command or something? Or a get control id each time it opens and then assign that? Edited May 7, 2009 by gte HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
gte Posted May 7, 2009 Author Share Posted May 7, 2009 Can you help me with doing that, I'm looking at the help file for _SendMessage() and having a hard time making sense of itYou can also send messages to target window/control by _SendMessage() HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
gte Posted May 7, 2009 Author Share Posted May 7, 2009 It seems like this would work? In some form? Am I understanding this correctly when I see that it sends characters to a window at a machine level and not at the keyboard input device level? #Include <WinAPI.au3> #Include <Misc.au3> $dll = DllOpen("user32.dll") Local $h_my_script = WinGetHandle(@ScriptName) while 1 $focused_window = winGetTitle("[ACTIVE]") $hWnd = WinGetHandle($focused_window) sleep(100) If _IsPressed("0D", $dll) Then;if you press [enter] if $h_my_script <> $hWnd Then _WinAPI_SetFocus($hWnd) Send("Today's time/date is") EndIf EndIf _WinAPI_SetFocus($h_my_script) WEnd HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Zedna Posted May 7, 2009 Share Posted May 7, 2009 Can you help me with doing that, I'm looking at the help file for _SendMessage() and having a hard time making sense of itYou must use Winspector to see what messages are used when you manipulate with control.Then you can try to send these messages to that control by _SendMessage() from AutoIt. Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
gte Posted May 8, 2009 Author Share Posted May 8, 2009 Do you think I'll be able to send commands at a machine level with this, instead of emulating the keyboard at an input level? I'm guessing I can do that with user32.dll, but I have no experience with that and would have to do a lot of reading.I really thought the post that Andreik made was going to work, but that doesn't work with my application You must use Winspector to see what messages are used when you manipulate with control.Then you can try to send these messages to that control by _SendMessage() from AutoIt. HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
gte Posted May 8, 2009 Author Share Posted May 8, 2009 Is there an indepth tutorial on the _sendmessage command and user32.dll? HP OpenView ServiceCenter keep alive scriptRemote Desktop Login Script Link to comment Share on other sites More sharing options...
Zedna Posted May 8, 2009 Share Posted May 8, 2009 (edited) Is there an indepth tutorial on the _sendmessage command and user32.dll?I think NO.You must understand some system underlying facts.Sorry but if you don't have experiences don't expect you will find solution quickly.Here is reference for SendMessage on MSDNhttp://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx Edited May 8, 2009 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search Link to comment Share on other sites More sharing options...
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