DssLexius Posted September 23, 2008 Share Posted September 23, 2008 While 1 $rep = GUIGetMsg() Switch $rep Case $GUI_EVENT_CLOSE Exit Case $B1 Run($CmdLineRaw) Exit Case $B2; get the file name MsgBox(0, "File Name", "File name is: " & $CmdLineRaw, 50) EndSwitch WEndon Case $B2 script shows a MessageBox with the FullPath and name of File but i only want to display the File Name.can anyone tell me about it?before compiling the message box looks like thisAfter compiling to exe the message box shows nothing.after compiling it is not showing name or path.i want to show a message box which will tell only file name and also after compiling it should work.LOT OF THANXXXES IN ADVANCE FOR YOUR HELP Link to comment Share on other sites More sharing options...
DaRam Posted September 23, 2008 Share Posted September 23, 2008 That is because you have not passed it any parameters in the Command Line ! When it is compiled AutoIt3 does not include the exe name in $CmdLineRaw Try passing it a parameter using Windows Run or from a Console window. Link to comment Share on other sites More sharing options...
weaponx Posted September 23, 2008 Share Posted September 23, 2008 $string = '/ErrorStdOut "C:\test\TestScript.au3"' $result = StringRegExp($string,'/ErrorStdOut\h+"(?:.*\\)?(.*)"',3) Msgbox(0,"File Name","File name is: " & $result[0]) Link to comment Share on other sites More sharing options...
DssLexius Posted September 23, 2008 Author Share Posted September 23, 2008 (edited) That is because you have not passed it any parameters in the Command Line ! When it is compiled AutoIt3 does not include the exe name in $CmdLineRaw Try passing it a parameter using Windows Run or from a Console window. thanks for the information. $string = '/ErrorStdOut "C:\test\TestScript.au3"' $result = StringRegExp($string,'/ErrorStdOut\h+"(?:.*\\)?(.*)"',3) Msgbox(0,"File Name","File name is: " & $result[0]) Thanks for your code example. it's working fine now but it is still showing *.au3 file name after compiling. Edited September 23, 2008 by DssLexius Link to comment Share on other sites More sharing options...
DssLexius Posted September 23, 2008 Author Share Posted September 23, 2008 i renamed the script to "CompiledProgram.au3" and compiled it.after compiling the file name was "CompiledProgram.EXE" but on running it and clicking the button for message box it shows script name is "CompiledProgram.exe" but it is still showing "TestScript.AU3"can you correct it? or tell me what is the problem?thanks a lot for your help to me. Link to comment Share on other sites More sharing options...
martin Posted September 23, 2008 Share Posted September 23, 2008 i renamed the script to "CompiledProgram.au3" and compiled it.after compiling the file name was "CompiledProgram.EXE" but on running it and clicking the button for message box it shows script name is "CompiledProgram.exe" but it is still showing "TestScript.AU3"can you correct it? or tell me what is the problem?thanks a lot for your help to me.It looks like you blindly followed what weaponx told you. Remove his $String = line and then in the next line replace $string with $CmdLineRaw. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
DaRam Posted September 23, 2008 Share Posted September 23, 2008 All you need is this (I think): If @compiled Then $FileName = @AutoItExe $iSlashPos = StringInStr($FileName, "\", 1, -1) If $iSlashPos > 0 Then $FileName = StringMid($FileName, $iSlashPos+1) Else $FileName = @ScriptName EndIf MsgBox(0, "File Name", "File name is: " & $FileName, 50) Link to comment Share on other sites More sharing options...
DssLexius Posted September 23, 2008 Author Share Posted September 23, 2008 All you need is this (I think): If @compiled Then $FileName = @AutoItExe $iSlashPos = StringInStr($FileName, "\", 1, -1) If $iSlashPos > 0 Then $FileName = StringMid($FileName, $iSlashPos+1) Else $FileName = @ScriptName EndIf MsgBox(0, "File Name", "File name is: " & $FileName, 50) no i don't need this but thanks for you effort. ok, i changed the code to this While 1 $rep = GUIGetMsg() Switch $rep Case $GUI_EVENT_CLOSE Exit Case $B1 Run($CmdLineRaw) Exit Case $B2; get the file name $result = StringRegExp($CmdLineRaw,'/ErrorStdOut\h+"(?:.*\\)?(.*)"',3) Msgbox(0,"File Name","File name is: " & $result[0]) EndSwitch WEnd but now it is giving this error: Line -1: Error: Subscript used with non-Array variable. Link to comment Share on other sites More sharing options...
DW1 Posted September 23, 2008 Share Posted September 23, 2008 Looks like StringRegExp() is getting an error. Use this to see if StringRegExp() is getting an error: While 1 $rep = GUIGetMsg() Switch $rep Case $GUI_EVENT_CLOSE Exit Case $B1 Run($CmdLineRaw) Exit Case $B2; get the file name $result = StringRegExp($CmdLineRaw,'/ErrorStdOut\h+"(?:.*\\)?(.*)"',3) If @error Then MsgBox(0, "test", "Error in StringRegExp()") Else Msgbox(0,"File Name","File name is: " & $result[0]) EndIf EndSwitch WEnd AutoIt3 Online Help Link to comment Share on other sites More sharing options...
DssLexius Posted September 23, 2008 Author Share Posted September 23, 2008 Looks like StringRegExp() is getting an error. Use this to see if StringRegExp() is getting an error: While 1 $rep = GUIGetMsg() Switch $rep Case $GUI_EVENT_CLOSE Exit Case $B1 Run($CmdLineRaw) Exit Case $B2; get the file name $result = StringRegExp($CmdLineRaw,'/ErrorStdOut\h+"(?:.*\\)?(.*)"',3) If @error Then MsgBox(0, "test", "Error in StringRegExp()") Else Msgbox(0,"File Name","File name is: " & $result[0]) EndIf EndSwitch WEnd ok, on trying this i am getting the following Error: i added a line to get error number and with error number: from the HelpFile about StringRegExp() errors: Flag = 3 or 4 : @Error Meaning 0 Array is valid. 1 Array is invalid. No matches. 2 Bad pattern, array is invalid. @Extended = offset of error in pattern. can anyone help me to Resolve this? Link to comment Share on other sites More sharing options...
martin Posted September 24, 2008 Share Posted September 24, 2008 ok, on trying this i am getting the following Error:i added a line to get error number and with error number:from the HelpFile about StringRegExp() errors:Flag = 3 or 4 :@Error Meaning 0 Array is valid. 1 Array is invalid. No matches. 2 Bad pattern, array is invalid. @Extended = offset of error in pattern. can anyone help me to Resolve this?The StringREgExp is trying to match whatever comes after the last '\' character. If you don't have such a character in your parameters then that is why it fails. What are the parameters you are using? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
trancexx Posted September 24, 2008 Share Posted September 24, 2008 This is like communication over broken phone. While 1 $rep = GUIGetMsg() Switch $rep Case $GUI_EVENT_CLOSE Exit Case $B1 Run($CmdLineRaw) Exit Case $B2; get the file name MsgBox(0, "File Name", "File name is: " & $CmdLineRaw, 50) EndSwitch WEnd on Case $B2 script shows a MessageBox with the FullPath and name of File but i only want to display the File Name. can anyone tell me about it? before compiling the message box looks like this After compiling to exe the message box shows nothing. after compiling it is not showing name or path. i want to show a message box which will tell only file name and also after compiling it should work. LOT OF THANXXXES IN ADVANCE FOR YOUR HELPAnd that is exactly as it should be. DaRam gave you all the answers you need, just read again (both his posts). Read and try to understand, you'll see. It's all there. ♡♡♡ . eMyvnE 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