Suhotro Posted December 19, 2012 Share Posted December 19, 2012 Hi All,I have an AutoIT executable file. My requirement is I’ll run it once and it will create 2 separate AutoIT executable files and execute them one by one.Is it possible ?The context it I need to handle pop ups for my applications. I have created 2 AutoIT executable files for the same (one will handle pop up by creating a process and other will take care of application) – as long as I have 2 files in my system my code is working fine.Now my requirement got change and I need to shift only one executable file to a different system where I need to execute my entire code.Thanks in advance !!Suhotro Bhattacharyya Link to comment Share on other sites More sharing options...
guinness Posted December 19, 2012 Share Posted December 19, 2012 I'm not really following your issue. Could you re-clarify? Maybe post some code to show what you mean perhaps? UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
Exit Posted December 19, 2012 Share Posted December 19, 2012 This might help. expandcollapse popupHotKeySet("{esc}", "_ESC") Func _ESC() Exit EndFunc ;==>_ESC OnAutoItExitRegister("_Exit") Func _Exit() __SingleScript() MsgBox(262144," ","Bye, bye",2) EndFunc ;==>_Exit If $CmdLine[0] > 0 Then If $CmdLine[1] = "Childprocess" Then Exit Childprocess() EndIf EndIf __SingleScript() ShellExecute(@ScriptFullPath, "Childprocess") ; here foolows your application code MsgBox(262144," ","Press ESC to Exit",2) $i = 0 While Sleep(1000) ; never ending loop $i += 1 MsgBox(262144, "My Messagebox", $i, 0) WEnd Exit ; here foolows your popup code Func Childprocess() While 1 If WinExists("My Messagebox") Then Beep(2000,100) Sleep(1000) WinKill("[last]") EndIf WEnd EndFunc ;==>Childprocess Func __SingleScript() Local $OI, $O = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2"), $CI = $O.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x30) For $OI In $CI If $OI.ProcessId = @AutoItPID Then ContinueLoop If $OI.Name = StringTrimRight(@ScriptName, 4) & ".EXE" Or ($OI.Name = "AutoIt3.exe" And StringInStr($OI.CommandLine, StringTrimRight(@ScriptName, 4) & ".au3")) Then ProcessClose($OI.ProcessId) Next EndFunc ;==>__SingleScript App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Suhotro Posted December 19, 2012 Author Share Posted December 19, 2012 well, initially in autoIt wrapper , say the name of the wrapper is "Wrapper.exe", the code is something like belowFileInstall, First.exe, tmpFirst.exeFileInstall, Second.exe, tmpSecond.exeRunWait, tmpFirst.exeRunWait, tmpSecond.exeHence is I have both the file present in the system (First.exe and Second.exe) my Wrapper.exe is running absolutely fine.Now the problem is I need to shift Only One executable file from one system to another here if I shift only wrapper.exe then my code is not working because it is searching for “First.exe” and “Second.exe”.I was under impression that after compiling “Wrapper.Au3” – automatically “First.exe” and “Second.exe” will be associated with “Wrapper.exe” but that is not the case.Please help !! Link to comment Share on other sites More sharing options...
Exit Posted December 19, 2012 Share Posted December 19, 2012 (edited) Perhaps it is an issue with different architecture of source and target system, one x64 and other x86. Did you tried running Frist.exe and Second.exe on the destination system without a wrapper? Are Frist.exe and Second.exe compiled Autoit scripts? Edited December 19, 2012 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Suhotro Posted December 19, 2012 Author Share Posted December 19, 2012 (edited) Thanks Exit !! Yes first and second both are compliled AutoIt scripts. There is no difference in the source and destination systems only thing is we have a restriction of moving only one file not two / more. However I need to have 2 file to create 2 separate process because one will be pop up handler and another is normal application code. Otherwise my script is not able to handle pop up efficiently ....most of the time script is getting paused. Edited December 19, 2012 by Suhotro Link to comment Share on other sites More sharing options...
Exit Posted December 19, 2012 Share Posted December 19, 2012 Then look on my code. It makes two processes. One application process and one childprocess to handle popups. In my sample, the applicationprocess is a messagebox. Normally, the script pauses on a messagebox popup. But the childprocess running as a separate tread/process kills the messagebox popup. Just give it a try. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Suhotro Posted December 19, 2012 Author Share Posted December 19, 2012 Sorry Exit !!! I have tested it its not working !!! Please suggest something else Thanks for your time !!! Link to comment Share on other sites More sharing options...
Developers Jos Posted December 19, 2012 Developers Share Posted December 19, 2012 Do you want to include your first.exe and second.exe in the Wrapper.exe so it can be copied to other Computers and ran by simply running wrapper.exe? If so, look at FileInstall() Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Exit Posted December 19, 2012 Share Posted December 19, 2012 (edited) I have tested it its not working !!! A bit unspecific. Just run this code unmodified. expandcollapse popupIf $CmdLine[0] > 0 And $CmdLine[1] = "Childprocess" Then Exit Childprocess() __SingleScript() ; cleanup older tasks with the same name ShellExecute(@ScriptFullPath, "Childprocess") ; call the second procerss aka Second.exe ; here follows your application code setup OnAutoItExitRegister("_Exit") Func _Exit() __SingleScript() ; kill the second process aka Second.exe MsgBox(262144, " ", "Bye, bye", 2) EndFunc ;==>_Exit HotKeySet("{ESC}", "_ESC") Func _ESC() Exit EndFunc ;==>_ESC ; here follows your application code aka First.exe MsgBox(262144, "Application code", "Application code running. Press OK to continue.", 0) For $i = 1 To 9999999999 Sleep(500) MsgBox(262144, "My Messagebox", $i & @LF & @LF & @LF & "Press ESC to Exit" & @LF & @LF & "(OK will be pressed by Childprocess)", 0) Next Exit ; here follows your popup code aka Second.exe Func Childprocess() MsgBox(262144, "Popup code", "Popup code running. Press OK to continue.", 0) While Sleep(100) If WinExists("My Messagebox") Then Beep(3000, 30) Sleep(1000) If Not ControlClick("My Messagebox", "", "Button1") Then MsgBox(262144, "Popup code", "Controlclick failed", 0) EndIf WEnd EndFunc ;==>Childprocess ; Func __SingleScript() Local $OI, $O = ObjGet("winmgmts:" & @ComputerName & "rootCIMV2"), $CI = $O.ExecQuery("SELECT * FROM Win32_Process", "WQL", 0x30) For $OI In $CI If $OI.ProcessId = @AutoItPID Then ContinueLoop If $OI.Name = StringTrimRight(@ScriptName, 4) & ".EXE" Or ($OI.Name = "AutoIt3.exe" And StringInStr($OI.CommandLine, StringTrimRight(@ScriptName, 4) & ".au3")) Then ProcessClose($OI.ProcessId) Next EndFunc ;==>__SingleScript and tell me if a messagebox with a counter appears/disappears. Or what error happens. Edited December 20, 2012 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Suhotro Posted December 20, 2012 Author Share Posted December 20, 2012 Thanks agin Exit !! I ran the code and its not working. Your child process is not clicking OK. Let me be specific now such that you understand the problem more clearly:The context of wrapper came to my mind because in my application pop up is not being handled properly (some times it is being handled some times it is not).Main problem is whenever I am selecting a value in my application - which is basically a drop down, it fires onchange event and a pop up is comming.Because of this my autoIT script is getting paused.I tried ControlSend, ControlClick but as my script is getting paused that line is not getting executed and hence that pop up is not being handled properly.I have used AutoIT Window Info to get the proper information of pop up windows. This is a normal internet explorer pop up.Then I thought to use AutoIt wrapper becuase my first process - POPUPHandler.exe will create a pop up handler which will be running first and then my application code will run as a separate process ApplicationCode.exe hence whenever that pop up will appear then it will be taken care by first process POPUPHandler.exe as at that time second process - ApplicationCode.exe is kind of paused.To make the wrapper I have used following code:FileInstall("D:Test ScriptsPOPUPHandler.exe","D:Test Scripts ",1) FileInstall("D:Test ScriptsApplicationCode.exe", "D:Test Scripts",1)Run("D:Test ScriptsPOPUPHandler.exe","",@SW_HIDE) ;This is actually an infinite loop this will be closed by ApplicationCode.exeRun("D:Test ScriptsApplicationCode.exe","",@SW_SHOW)So far it was working fine becuase in my system I have all the 3 files present now my requirment is I need to move just only one file in a different system where I'll not have other 2 files - this is the place where I got stuck.Please see if we can do anything here or not.Thanks a lot for your time. Link to comment Share on other sites More sharing options...
Exit Posted December 20, 2012 Share Posted December 20, 2012 I have no explanation why the code is not running on your system. I would ask other readers of this thread to run the sample and give feedback. Thanks. Using my solution would avoid having 3 scripts. All in one would be better. Did you check the return value of your fileinstall() ? I assume that it failed since you gave no destination filename. The following RUN statements will only run on the source system since there are the original files. You should Fileinstall() in a temp directory and use different filenames. Then it will fail on the source system also. Test it with the compiled version of the wrapper, otherwise fileinstall() will use sourcefiles. See the helpfile for fileinstall(). App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Suhotro Posted December 21, 2012 Author Share Posted December 21, 2012 Thanks Exit !! I have modified your code little bit as per requirement and exectuing that exe, its working fine. a big thank you for giving the idea / code of creating 2 separate processes using AutoIT is really excellent !!! 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