MyEarth Posted November 12, 2015 Share Posted November 12, 2015 (edited) I want to pass parameter like variable to a ShellExecute, not so easy seems. Since the everything is optional except the filename i have think to make something like $verb = "" and the other but not work, check this out:ShellExecute("notepad.exe", "C:\Text.txt", Default, Default, Default) ShellExecute("notepad.exe", "C:\Text.txt", "", "", "") ;~ ShellExecute("notepad.exe", "C:\Text.txt")Obv need a file in C:\Text.txt or whatever you like. The first two not work, the last yes but i want to variable to optional *if* user with the GUi what to add it. I need to make many ShellExecute based on optional parameter for do this? Autoit 3.3.8.1Thanks Edited November 12, 2015 by MyEarth Link to comment Share on other sites More sharing options...
Danyfirex Posted November 12, 2015 Share Posted November 12, 2015 Default values looks like.ShellExecute("notepad.exe", "C:\test.txt","","",@SW_SHOWNORMAL)Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
mikell Posted November 12, 2015 Share Posted November 12, 2015 This works for me$soft = "notepad.exe" $file = @desktopdir & "\1.txt" $workingdir = "" $verb = "" $flag = @SW_SHOW ; cannot be "" ShellExecute($soft, $file, $workingdir, $verb) ; , $flag) Link to comment Share on other sites More sharing options...
MyEarth Posted November 12, 2015 Author Share Posted November 12, 2015 There is something i don't understand, the showflag cannot be empty, right? But if i don't write how the function understand i don't have pass a parameter if it don't have a default value? Link to comment Share on other sites More sharing options...
Danyfirex Posted November 12, 2015 Share Posted November 12, 2015 default flag for showflag is @SW_SHOWNORMAL if you put anything (I mean not set default keyword o anything). If you put default keyword AutoIt does not care about it and pass -1. then internally ends as 2^16-1 unsigned short int. Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
BrewManNH Posted November 13, 2015 Share Posted November 13, 2015 There is something i don't understand, the showflag cannot be empty, right? But if i don't write how the function understand i don't have pass a parameter if it don't have a default value?The only parameter needed for ShellExecute is the filename parameter, everything else is optional to have it run. In your example you only need 2 parameters, the program to run (Notepad.exe) and the file to open (C:\test.txt). If you're not going to change the optional parameters, you do not need to include them in the function line. The only time you need to set the optional parameters to the default values is if you're changing an optional parameter that comes after one of the other optional ones, then you must include them even if set to default. 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