sreekanthrcs62 Posted February 21, 2014 Share Posted February 21, 2014 (edited) #include <MsgBoxConstants.au3> Example() Func Example() Run("notepad.exe a.txt") WinWait("a.txt - Notepad") WinSetState("a.txt - Notepad","", @SW_HIDE) Sleep(1000) Local $value = ControlSend("a.txt - Notepad", "", "Edit1", "^a") Sleep(2000) MsgBox($MB_SYSTEMMODAL, "AutoIt Example", $value) Sleep(1000) Local $value2 = ControlSend("a.txt - Notepad", "", "Edit1", "^c") Sleep(2000) MsgBox($MB_SYSTEMMODAL, "AutoIt Example", $value2) Sleep(1000) Run("notepad.exe") WinWait("Untitled - Notepad") WinSetState("Untitled - Notepad","", @SW_HIDE) Sleep(2000) Local $value3 = ControlSend("Untitled - Notepad", "", "Edit1", "^v") Sleep(1000) MsgBox($MB_SYSTEMMODAL, "AutoIt Example", $value3) Sleep(1000) WinSetState("Untitled - Notepad","", @SW_SHOW) EndFunc I tried to execute the above code with having"@SW_HIDE" values in the Run command. Applications are hidden but the controlSend commands are not working fine. After removing the "@SW_HIDE" values in the Run command, controlsend command works, but the application window is not hidden. I tried checking the flags returned from controlsend command. Flag Values are showing 1, I assume it is fine. Please Could you help me to fix this problem. Thanks in advance. Edited February 24, 2014 by sreekanthrcs62 Link to comment Share on other sites More sharing options...
FireFox Posted February 21, 2014 Share Posted February 21, 2014 Hi, Welcome to the autoit forum First of all, can you edit your post and use >autoit code tags to post your code because here we will have to remove all the line numbers Br, FireFox. Link to comment Share on other sites More sharing options...
reb Posted February 21, 2014 Share Posted February 21, 2014 (edited) AutoIt Code Tags are much better to use and read. because here we will have to remove all the line numbers Out of curiosity I tried to copy the code in the first post and the numbers did not copy. Pasted into SciTe correctly. Just my observation Win7 64 firefox 27.0.1 REB Edited February 21, 2014 by reb MEASURE TWICE - CUT ONCE Link to comment Share on other sites More sharing options...
FireFox Posted February 21, 2014 Share Posted February 21, 2014 My bad, it was just a remark I did not test it. Link to comment Share on other sites More sharing options...
FireFox Posted February 21, 2014 Share Posted February 21, 2014 The ControlSend function appears not to be working when the window is not active, in this case of the edit control. Br, FireFox. Link to comment Share on other sites More sharing options...
FireFox Posted February 22, 2014 Share Posted February 22, 2014 (edited) After a few trys using some WinAPI function to reproduce the ControlSend command, the window must be active to send the keystrokes (here I'm using _WinAPI_SetForegroundWindow). #include <WinAPISys.au3> Example() Func Example() Run("notepad.exe a.txt", "", @SW_HIDE) Local $hNotepad = WinWait("[TITLE:a.txt; CLASS:Notepad]") _WinAPI_SetForegroundWindow($hNotepad) ControlSend($hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "^a") ;the following lines does not change anything for your information ;~ ControlSend($hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "^c") ;~ ControlSend($hNotepad, "", "[CLASS:Edit; INSTANCE:1]", "^v") WinSetState($hNotepad, "", @SW_SHOW) EndFunc ;==>Example _ Br, FireFox. Edited February 22, 2014 by FireFox Link to comment Share on other sites More sharing options...
AdamUL Posted February 22, 2014 Share Posted February 22, 2014 (edited) From the Help file for ControlSend. The control might first need to be given focus with the ControlFocus() command, specially when referencing an controlID created by the script itself. This also applies to GUIs not created by the script itself. As a rule of thumb, I always use ControlFocus before "Control" commands. This should work for you. #include <MsgBoxConstants.au3> Example() Func Example() Run("notepad.exe a.txt","", @SW_HIDE) WinWait("a.txt - Notepad") WinSetState("a.txt - Notepad","", @SW_HIDE) Sleep(1000) ControlFocus("a.txt - Notepad", "", "Edit1") Local $value = ControlSend("a.txt - Notepad", "", "Edit1", "^a") Sleep(2000) MsgBox($MB_SYSTEMMODAL, "AutoIt Example", $value) Sleep(1000) ControlFocus("a.txt - Notepad", "", "Edit1") Local $value2 = ControlSend("a.txt - Notepad", "", "Edit1", "^c") Sleep(2000) MsgBox($MB_SYSTEMMODAL, "AutoIt Example", $value2) Sleep(1000) Run("notepad.exe","", @SW_HIDE) WinWait("Untitled - Notepad") WinSetState("Untitled - Notepad","", @SW_HIDE) Sleep(2000) ControlFocus("Untitled - Notepad", "", "Edit1") Local $value3 = ControlSend("Untitled - Notepad", "", "Edit1", "^v") Sleep(1000) MsgBox($MB_SYSTEMMODAL, "AutoIt Example", $value3) Sleep(1000) WinSetState("Untitled - Notepad","", @SW_SHOW) WinSetState("a.txt - Notepad","", @SW_SHOW) EndFunc Adam Edited February 23, 2014 by AdamUL Fubarable 1 Link to comment Share on other sites More sharing options...
FireFox Posted February 22, 2014 Share Posted February 22, 2014 Nice shot Link to comment Share on other sites More sharing options...
AdamUL Posted February 23, 2014 Share Posted February 23, 2014 Thanks, As soon as I seen this thread, and your replay, I figured that it was a control focus issue. Adam Link to comment Share on other sites More sharing options...
sreekanthrcs62 Posted February 24, 2014 Author Share Posted February 24, 2014 Thanks to all It worked. Link to comment Share on other sites More sharing options...
sreekanthrcs62 Posted February 24, 2014 Author Share Posted February 24, 2014 Methods you mentioned are working for the installed software e.g Notepad in the machine. For software(.exe) file which can run without installation in the machine this methods of using @SW_HIDE doesn't work. Below mentioned code doesn't hide the window for some *****.exe. Run("****.exe a.txt","", @SW_HIDE) WinWait("a.txt - Notepad") WinSetState("a.txt - Notepad","", @SW_HIDE) Could you Please suggest some alternative. Thanks in advance. Link to comment Share on other sites More sharing options...
BrewManNH Posted February 24, 2014 Share Posted February 24, 2014 Perhaps if you explained what software you're trying to run hidden that would help us help you. Just saying some software doesn't run hidden isn't much to go on. BTW, some software will resist your attempts to run it hidden, it all depends on what the program does or how it was written. If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag GudeHow to ask questions the smart way! I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from. Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays. - ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script. - Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label. - _FileGetProperty - Retrieve the properties of a file - SciTE Toolbar - A toolbar demo for use with the SciTE editor - GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI. - Latin Square password generator Link to comment Share on other sites More sharing options...
sreekanthrcs62 Posted February 26, 2014 Author Share Posted February 26, 2014 The softwares are TextAnalysisTool and SequenceDiagramEditor. Link to comment Share on other sites More sharing options...
Bert Posted February 26, 2014 Share Posted February 26, 2014 Maybe the installer supports command line switches. also,(for other folks) look here for info on the applications: http://blogs.msdn.com/b/delay/archive/2013/05/20/64-bits-ought-to-be-enough-for-everybody-textanalysistool-net-update-for-net-2-0-and-64-bit-enables-the-analysis-of-larger-files.aspx http://sdedit.sourceforge.net/ The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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