Dolce Posted June 13, 2014 Share Posted June 13, 2014 Hi Friends I'm the new guy here, but i worked a lot of years with C# Now i've spent a lot of time to find out, how i can start my file.exe dynamically. I need to execute a exe file with variable. See the example below My goal is to read from a text file, the file path information and text Information. Subsequently, this information will be passed which will then be processed with AutoIT further into variables. My Idea was the following: Without Variable: Run("P:\MyProgram.Net\Prog\MyProgram.v4.exe START SHOW:Test") ; it Works fine, the Application will be starded This examples doesn't works: $MyPath = StringRegExp(FileRead("txt.txt"),"MyPath\s=\s(.*)",1) Run($MyPath) or Run('"' & $MyPath & '"') I tryed this Situation also for filling up my TextBox ControlSend("Test ReadingForm", "", "", "0100000205201>922141000000019411006181604+ 010045256>{ENTER}") ; It works!!! This examples doesn't works: $ESR = StringRegExp(FileRead("txt.txt"),"ESR\s=\s(.*)",1) ControlSend("Test ReadingForm", "", "", $ESR) or ControlSend("Test ReadingForm", "", "", StringFormat(StringRegExp(FileRead("txt.txt"),"ESR\s=\s(.*)",1))) Does anyone have an idea what's wrong with my Code? Kind regards Dolce Link to comment Share on other sites More sharing options...
Danp2 Posted June 13, 2014 Share Posted June 13, 2014 Sounds like your StringRegExp isn't producing the desired results. Try adding a ConsoleWrite or MsgBox call so that you can see the results. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 (edited) Thank you for the quick reply No, the MessageBox shows me the desired result-but can run () does not perform this. My assumption was that I might have to format the variable. Can it be? How would you automate this process? Edited June 13, 2014 by Dolce Link to comment Share on other sites More sharing options...
Exit Posted June 13, 2014 Share Posted June 13, 2014 (edited) Welcome to the forum. Please put some debugging code in your script.e-g:#AutoIt3Wrapper_Run_Debug_Mode=y $TXT = FileRead("txt.txt") ConsoleWrite(@LF & "TXT: >" & $TXT & "<" & @LF) $ESR = StringRegExp($TXT, "ESR\s=\s(.*)", 1) ConsoleWrite(@LF & "ESR: >" & $ESR & "<" & @LF) $RC=ControlSend("Test ReadingForm", "", "", $ESR) ConsoleWrite(@LF & "RC: >" & $RC & "<" & @LF)And show us the console output.Perhaps, there are some special characters who require 'masking'. Edited June 13, 2014 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Danp2 Posted June 13, 2014 Share Posted June 13, 2014 These should produce the same result: Run("P:\MyProgram.Net\Prog\MyProgram.v4.exe START SHOW:Test") $myvar = "P:\MyProgram.Net\Prog\MyProgram.v4.exe START SHOW:Test" Run($myvar) so I still say there's something incorrect with either the text file contents or your StringRegExp. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 This change does not generate an output in my consoles Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 (edited) That's the Contents of my txt.txt: ID = 23123 ProffixPath ="C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren" ESR = 0100000205201>922141000000019411006181604+ 010049999> New: ProffixPath ="P:\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren" And that's my Scripting code: expandcollapse popup#include <Constants.au3> ; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win9x/NT ; Author: Jonathan Bennett (jon at autoitscript dot com) ; ; Script Function: ; Plays with the calculator. ; $result = StringRegExp(FileRead("txt.txt"),"ID\s=\s(.*)",1) $ProffixPath = StringRegExp(FileRead("txt.txt"),"ProffixPath\s=\s(.*)",1) $ESR = StringRegExp(FileRead("txt.txt"),"ESR\s=\s(.*)",1) $TXT = FileRead("txt.txt") ConsoleWrite(@LF & "TXT: >" & $TXT & "<" & @LF) $ESR = StringRegExp($TXT, "ESR\s=\s(.*)", 1) ConsoleWrite(@LF & "ESR: >" & $ESR & "<" & @LF) $RC=ControlSend("Test ReadingForm", "", "", $ESR) ConsoleWrite(@LF & "RC: >" & $RC & "<" & @LF) ; Prompt the user to run the script - use a Yes/No prompt with the flag parameter set at 4 (see the help file for more details) Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Click proffix Button", "This script will clicked the Proffix Button neu. Do you want to run it?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $iAnswer = 7 Then MsgBox($MB_SYSTEMMODAL, "AutoIt", "OK. Bye!") Exit EndIf ; Run the Proffix V4 ;Run("C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.NET.exe") ;Run("C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.NET.exe START SHOW:pxKreditoren") ;Run("C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren") ;Run("P:\Proffix.Net\Prog\PROFFIX.NET.exe START SHOW:pxKreditoren") ;Run("P:\Proffix.Net\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren") ;Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Proffix V4 started", "Proffix V4 is Starting now") Run($ProffixPath) ; Wait if the application has load the form WinWaitActive("Zubler & Partner AG - PROFFIX Kreditorenbuchhaltung") ;Press HotKey CTRL+N Send("^{n}") Sleep(2000) ; Wait if the application has load the form WinWaitActive("Buchen Kreditorenbuchhaltung") ;Press HotKey CTRL+E Send("^{e}") Sleep(2000) WinWaitActive("Einzahlungsschein einlesen") ;ControlSend("Einzahlungsschein einlesen", "", "", "0100000205201>922141000000019411006181604+ 010045256>{ENTER}") ControlSend("Einzahlungsschein einlesen", "", "", StringFormat(StringRegExp(FileRead("txt.txt"),"ESR\s=\s(.*)",1))) ; Finished! Edited June 13, 2014 by Dolce Link to comment Share on other sites More sharing options...
Exit Posted June 13, 2014 Share Posted June 13, 2014 did you run it in SciTE4AutoIt ? F5 in the editor? please show us your complete code. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 (edited) >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3" /UserParams +>13:54:06 Starting AutoIt3Wrapper v.2.2.0.3 SciTE v.3.4.1.0 Keyboard:00000807 OS:WIN_2008R2/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0407) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.12.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3 +>13:54:06 AU3Check ended.rc:0 >Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop TXT: >ID = 23123 ProffixPath ="C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren" ESR = 0100000205201>922141000000019411006181604+ 010049999>< ESR: >< RC: >0< Edited June 13, 2014 by Dolce Link to comment Share on other sites More sharing options...
Exit Posted June 13, 2014 Share Posted June 13, 2014 @Dolceplease put the following line as first line in the script.#AutoIt3Wrapper_Run_Debug_Mode=yRun the code by F5 and show us the console output of SciTE. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Exit Posted June 13, 2014 Share Posted June 13, 2014 (edited) >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3" /UserParams +>13:54:06 Starting AutoIt3Wrapper v.2.2.0.3 SciTE v.3.4.1.0 Keyboard:00000807 OS:WIN_2008R2/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0407) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.12.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3 +>13:54:06 AU3Check ended.rc:0 >Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop TXT: >ID = 23123 ProffixPath ="C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren" ESR = 0100000205201>922141000000019411006181604+ 010049999>< ESR: >< RC: >0< Seems that the text is not found. Edit: you changed the path for the text, but missed to prepend the #AutoIt3Wrapper_Run_Debug_Mode=y Edited June 13, 2014 by Exit App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 Now the output is fully: >"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3" /UserParams +>13:59:02 Starting AutoIt3Wrapper v.2.2.0.3 SciTE v.3.4.1.0 Keyboard:00000807 OS:WIN_2008R2/Service Pack 1 CPU:X64 OS:X64 Environment(Language:0407) +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\Administrator\AppData\Local\AutoIt v3\SciTE >Running AU3Check (3.3.12.0) from:C:\Program Files (x86)\AutoIt3 input:C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3 +>13:59:02 AU3Check ended.rc:0 >Running:(3.3.12.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Program Files (x86)\AutoIt3\SciTE\ClickProffixButtonWithDynamicallyValues.au3" --> Press Ctrl+Alt+F5 to Restart or Ctrl+Break to Stop !> Starting in DebugMode.. Line: @error-@extended: Line syntax 0001: 0-0: #AutoIt3Wrapper_Run_Debug_Mode=y 0002: 0-0: #include <Constants.au3> 0014: 0-0: $result = StringRegExp(FileRead("txt.txt"),"ID\s=\s(.*)",1) 0015: 1-0: $ProffixPath = StringRegExp(FileRead("txt.txt"),"ProffixPath\s=\s(.*)",1) 0016: 1-0: $ESR = StringRegExp(FileRead("txt.txt"),"ESR\s=\s(.*)",1) 0018: 1-0: $TXT = FileRead("txt.txt") 0019: 0-160: ConsoleWrite(@LF & "TXT: >" & $TXT & "<" & @LF) TXT: >ID =23123 ProffixPath ="C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren" ESR =0100000205201>922141000000019411006181604+ 010049999>< 0020: 0-0: $ESR = StringRegExp($TXT, "ESR\s=\s(.*)", 1) 0021: 1-0: ConsoleWrite(@LF & "ESR: >" & $ESR & "<" & @LF) ESR: >0< 0022: 0-0: $RC=ControlSend("Test ReadingForm", "", "", $ESR) 0023: 0-0: ConsoleWrite(@LF & "RC: >" & $RC & "<" & @LF) RC: >0< 0027: 0-0: Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Click proffix Button", "This script will clicked the Proffix Button neu. Do you want to run it?") 0031: 0-0: If $iAnswer = 7 Then 0043: 0-0: Run($ProffixPath) 0046: 1-2: WinWaitActive("Zubler & Partner AG - PROFFIX Kreditorenbuchhaltung") +>13:59:09 AutoIt3.exe ended.rc:0 +>13:59:09 AutoIt3Wrapper Finished. >Exit code: 0 Time: 6.499 Link to comment Share on other sites More sharing options...
Exit Posted June 13, 2014 Share Posted June 13, 2014 0020: 0-0: $ESR = StringRegExp($TXT, "ESR\s=\s(.*)", 1) 0021: 1-0: ConsoleWrite(@LF & "ESR: >" & $ESR & "<" & @LF) ESR: >0< As you can see. your stringregExp returns a "0" as result. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 Is there an alternative, as I can read the values from the text? Link to comment Share on other sites More sharing options...
Exit Posted June 13, 2014 Share Posted June 13, 2014 Would be much easier, if you would post the complete code. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 (edited) That's all: txt.txt: ID = 23123 ProffixPath ="C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren" ESR = 0100000205201>922141000000019411006181604+ 010049999> Scriptcode: expandcollapse popup#AutoIt3Wrapper_Run_Debug_Mode=y #include <Constants.au3> ; ; AutoIt Version: 3.0 ; Language: English ; Platform: Win9x/NT ; Author: Jonathan Bennett (jon at autoitscript dot com) ; ; Script Function: ; Plays with the calculator. ; $result = StringRegExp(FileRead("txt.txt"),"ID\s=\s(.*)",1) $ProffixPath = StringRegExp(FileRead("txt.txt"),"ProffixPath\s=\s(.*)",1) $ESR = StringRegExp(FileRead("txt.txt"),"ESR\s=\s(.*)",1) $TXT = FileRead("txt.txt") MsgBox(0,"", $TXT) ConsoleWrite(@LF & "TXT: >" & $TXT & "<" & @LF) $ESR = StringRegExp($TXT, "ESR\s=\s(.*)", 1) ConsoleWrite(@LF & "ESR: >" & $ESR & "<" & @LF) $RC=ControlSend("Test ReadingForm", "", "", $ESR) ConsoleWrite(@LF & "RC: >" & $RC & "<" & @LF) ;MsgBox(@LF & "RC: >" & $RC & "<" & @LF) ; Prompt the user to run the script - use a Yes/No prompt with the flag parameter set at 4 (see the help file for more details) Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Click proffix Button", "This script will clicked the Proffix Button neu. Do you want to run it?") ; Check the user's answer to the prompt (see the help file for MsgBox return values) ; If "No" was clicked (7) then exit the script If $iAnswer = 7 Then MsgBox($MB_SYSTEMMODAL, "AutoIt", "OK. Bye!") Exit EndIf ; Run the Proffix V4 ;Run("C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.NET.exe") ;Run("C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.NET.exe START SHOW:pxKreditoren") ;Run("C:\Program Files (x86)\PROFFIX\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren") ;Run("P:\Proffix.Net\Prog\PROFFIX.NET.exe START SHOW:pxKreditoren") ;Run("P:\Proffix.Net\Prog\PROFFIX.v4.exe START SHOW:pxKreditoren") ;Local $iAnswer = MsgBox(BitOR($MB_YESNO, $MB_SYSTEMMODAL), "Proffix V4 started", "Proffix V4 is Starting now") Run($ProffixPath) ; Wait if the application has load the form WinWaitActive("Zubler & Partner AG - PROFFIX Kreditorenbuchhaltung") ;Press HotKey CTRL+N Send("^{n}") Sleep(2000) ; Wait if the application has load the form WinWaitActive("Buchen Kreditorenbuchhaltung") ;Press HotKey CTRL+E Send("^{e}") Sleep(2000) WinWaitActive("Einzahlungsschein einlesen") ;ControlSend("Einzahlungsschein einlesen", "", "", "0100000205201>922141000000019411006181604+ 010045256>{ENTER}") ControlSend("Einzahlungsschein einlesen", "", "", StringFormat(StringRegExp(FileRead("txt.txt"),"ESR\s=\s(.*)",1))) ; Finished! Edited June 13, 2014 by Dolce Link to comment Share on other sites More sharing options...
Dolce Posted June 13, 2014 Author Share Posted June 13, 2014 I have found it I wanted to read from a file of all values,Oops, that did not work out until now... If I grab the desired values in individual files, it works I'll post the code when I have it finished Thanks anyway Link to comment Share on other sites More sharing options...
Exit Posted June 13, 2014 Share Posted June 13, 2014 Ok, there is a lot of garbage in the code. For example the comment, that jon is the author. or the regex... at the beginning. Please cleanup the code to the minimum to reproduce the failure. Remove all unnessecary comments. Then put this two lines in front of the code #AutoIt3Wrapper_Run_Debug_Mode=y ConsoleWrite(@LF & "Code: ****" & @LF & @LF & FileRead(StringTrimRight(@ScriptFullPath, 12) & ".au3") & "End of Code: ****" & @LF& @LF) Then press F5. When script ended, please show the console output. App: Au3toCmd UDF: _SingleScript() Link to comment Share on other sites More sharing options...
BrewManNH Posted June 13, 2014 Share Posted June 13, 2014 StringRegExp using Flag 1 will return an array, your code is assuming it returns a string. 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...
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