MATLAB Answers

0

How to make a code to access the internet and other programs

Asked by Rainaire Hansford on 24 Jul 2017
Latest activity Commented on by Walter Roberson
on 11 Nov 2018 at 2:58
Is there a way to make a code open the internet browser and other programs.

  0 Comments

Sign in to comment.

Tags

Products

2 Answers

Answer by Jon Lobo on 24 Jul 2017

You can use system commands to do this. See system
You can also use the ! to do this.

  6 Comments

NET.addAssembly('System.Speech');
obj = System.Speech.Synthesis.SpeechSynthesizer;
obj.Volume = 100;
command = strtrim( input('What is your command', 's') );
parts = regexp(command, '\s+', 'split');
text_to_say = 'Unrecognized command';
if isempty(parts)
Speak(obj, text_to_say);
else
switch lower(parts)
case 'open'
if length(parts) == 2
filename = parts{2};
if exist(filename, 'file')
text_to_say = 'Opening file';
Speak(obj, text_to_say);
open(filename);
else
text_to_say = 'Could not find file to open it';
Speak(obj, text_to_say);
end
else
Speak(obj, text_to_say);
end
case 'search'
if length(parts) == 2
filename = parts{2};
cmd = sprintf('cd C:\; dir /s "%s"', filename);
text_to_say = 'Searching disk C for file';
Speak(obj, text_to_say);
[status, message] = system(cmd);
if isempty(message)
text_to_say = 'System had no response to search request';
Speak(obj, text_to_say);
else
text_to_say = 'System result of search follows';
Speak(obj, text_to_say);
Speak(obj, message);
end
else
Speak(obj, text_to_say');
end
otherwise
Speak(obj, text_to_say);
end
end
Ok Walter your going to have to walk me throught this cause I have no idea what any of this means haha I ran this code but it keeps giving error:
SWITCH expression must be a scalar or a character vector.
Error in Practice (line 11)
switch lower(parts)
Change
switch lower(parts)
to
switch lower(parts{1})

Sign in to comment.


Answer by Rainaire Hansford on 4 Aug 2018

ok well no error
What is your command parts
Undefined function or variable 'text_to_say'.
Error in Practice (line 45)
Speak(obj, text_to_say);

  7 Comments

https://stackoverflow.com/questions/40674914/google-chrome-path-in-windows-10
https://www.cnet.com/forums/discussions/internet-explorer-iexplore-exe-is-missing-in-windows-10/
You were not able to locate the executable for Internet Explorer, or for Chrome? Which Windows are you using and which browser do you want to be able to open?

Sign in to comment.