I'm having trouble making a more complex chatbot in notepad - loops

Here is a part of my current (working) chatbot code in Notepad so you can get an idea of how I am coding it:
dim n, q
n=inputbox("Hello, I'm a chatbot. What is your name?")
q=inputbox(""& n &" is a great name! Thank you for activating me, "& n &"! How are you?")
I want to be able to make "if and else" parts (for example, if "happy" is typed in after being asked "How are you feeling" it should say "great", if you type anything else it would say something differently.) How do I do this in Notepad?
Also, how do I get it to loop and say something based on keywords (like how Eliza the chatbot will keep talking for infinity just by looping and referring to a bank of keywords and responses) in Notepad?
I know these are really basic questions, but I have have searched the web multiple times; all searches ending up empty handed.

Unfortunately, you asked a very inspecific question making it hard to answer. That is why your post received a downvote and a close down request. However, you seem enthousiastic and I can only encourage that.
First of all, VBScript is not a very nice language. Oh, yes it seems simple, it nicely integrates with some standard windows components and you can run it out of the box. But it is ancient and does some things differently than more common languages. If you want to do more complex things faster, ultimately you'd switch to another (scripting) language.
With VBScript it is not (easily) possible to use notepad as input/output device. For your setup I'd prefer the command line (press your windows key and enter CMD+enter, there it is).
You can write output to the command line with
WScript.StdOut.Write "What is your name?"
You can retrieve output from the command line with
wscript.stdin.read(0)
name = wscript.stdIn.readline()
And to make your chatbot complete:
WScript.StdOut.Write "Hello " & name
Now you want to do some conditional branching. Well, I do not say W3Schools is a very good resource, but for now it is sufficient. Look at their if ... then ... else page (<- clickable link). If you are using IE, you can even try some things yourself.
Finally you can use Do While ... Loop's to make the code repeat itself.
A chatbot like Eliza is a prestigeous project. Don't be discouraged if you only can build a very simple version. The cake is in the coding, not the result.

Related

How to manually type a logarithm base on Windows 10/11 in a .txt file

I am currently using a text file to write down some quick notes about searching algorithms and their complexity. To do so, I want to be able to write my notes properly. (for a better understanding)
For instance, I would usually write log n of base 2.
Instead, I want to write logâ‚‚ n.
Is their any way to write it on a keyboard without copying and pasting an exemple seen online ?
UPDATE:
I found a way to do it.
Since I am using Windows 11, I found out that when doing "WIN + ." on my keyboard not only the emote menu would show up, but also a symbol menu.
symbol menu
The character you're looking for is Unicode "Subscript Two", U+2082.
How to insert it in your document is dependent on the application you use, your OS, etc.: read documentation.

Remove PDF password protection, knowing the password WINDOWS

I'd like to do something similar to Removing PDF password protection, knowing the password but in Windows. I have a folder with several PDFs that all have the same password, which I know. I would like to remove the password and overwrite the original files (don't worry, my data is a copy of another folder).
My thoughts are to use Autohotkey and create a script to open the file, paste the password, click enter, press Ctrl+P, click Print as PDF, save as the original file name, close Edge (which is what I'm using to open the PDFs), and then go to the next file in the folder.
I'm honestly not that familiar with AHK and would appreciate any help in what the code should be.
Thanks!
Edit: Here's some code I've tried but it doesn't seem to work.
^+q::
Loop %A_WorkingDir%\*.pdf
sleep 10000
Send, PASSWORD
sleep 2000
Send, {Enter}
Send, ^p
Click 105,694
WinClose, A
Return
When looping through files (using a files-loop as you have), it's not actually opening these but is giving you access to its OS-level properties, such as path, name, and system properties. You can use this information to open each one, using Run - something like, Run , %A_LoopFileLongPath%. Note that you may need to set Edge as your default PDF viewer if it isn't already.
Currently, your loop is only executing the line just beneath it, which is a 10-sec. sleep. You have 2,000 PDFs? That's about 5.5 hours of sleep before moving on. ;) If you want to execute more than one line, enclose it in braces { }, like so:
Loop , 1000
{
; stuff
}
From there, I would consider using WinWaitActive along with possibly ControlSend instead of Sleep and possibly Send. This will make your script more robust and may also take less time (assuming 10s is an upper bound). If at all possible, I would also discourage using clicks as these can sometimes be problematic (sometimes you have to send it multiple times for one click or locations might change). You can definitely make it work without these suggestions, it just might take more trial-and-error.
It may also be a good idea to build in a way to pause your script if needed, since this will likely take some time to do things to 2,000 files.
The help documentation is excellent and shows proper syntax and examples. I'd recommend consulting it for each of the commands.
https://www.autohotkey.com/docs/AutoHotkey.htm

IRC(Twitch chat) Text-to-speech

Hey everyone I'm looking for a way to code a program/bot in VB that would read my chat, but only if a command is used
For example: "!tts Hello"
And It would read it using TTS and show it on screen
$USERNAME$ !tts: Hello
Now the thing I don't know how to set up is the program reading the chat, printing it on screen I believe is the easy part.
Also if it's possible to add an option to select to which audio output it will go.
You need to study more coding...
Im not a master at it myself. but i would make a boolean that could be true if the first letter in a chatline is a "!". And then a command that would add that line to a text-to-speech module

Recording command line input and output on linux with C

Basically I want to do a program almost like a keylogger. The thing is that I as network admin sometimes I don't remember what I did to a machine on certain case, or same times I make howto's and tutorials for linux. I want to record what have i done.
So basically the idea of this program is:
you type the name of the program, (I call it rat for the moment)
$ rat
Welcome everything from now on will be recorded
recording $ ls
file1 file2 file3
recording $ quit
Bye bye
Everything you do will go out to an xml file. Something like this
<?xml version='1.0' encoding='UTF-8' ?>
<rat>
<command>
<input>ls</input>
<output>file1 file2 file3</output>
<err><err>
</command>
</rat>
i am doing some tests with fp_in = popen( input, "w");
and system, but first with popen i cant change directories and with "system i cant properly manage the input and output.
I was also checking if there is something I can do to bash like a plugin but haven't find any information.
At some points if feels like it I should create another shell (which is way beyond my current abilities) or fork bash sh. But it should been that complicated right.
I am open to suggestion where to start.
I am rusty with C, so I am reading again a lot of basic stuff.
With the xml file, later i was thinking on making a program to store this data and/or editing this data so i can create tutials and howto.
I can think of many ways of expanding this up to using printscreen so all the stored images go to a file you can upload to a server (for the moment i am glad to store the data). It could be a usefull tool.
ps. I do know this can be use for evil things too.
There already exists the script command, which will record all input and output into the terminal, writing it into a transcript. I would recommend just using that, unless you have particular needs that it doesn't meet. Actually, the nicest version of script that I've seen has been the NetBSD version, so you may want to look into that if the Linux version doesn't meet your needs.
If you would like to write it yourself, instead of using system, I would recommend that you use fork/exec to create a single shell process, which you copy all input and output into. To get an idea of how this works, I'd recommend looking at the source code for an existing version of script.
Most shells have a script built-in which will simply record the text in- and out- from the command line. Not quite what you're looking for... To my surprise script is not a built in, which means it is a model for building what you want.
The script command does almost what you want: it simply records the text in- and out- from the command line.
If you make your prompt distinctive (so that you can reliably tell the difference between shell commands and everything else) you can post-process the output of script to achieve your goals. Alternately you can hack script to get it to emit the XML you're looking for.
You can also try approaching this from a different angle. Instead of using a regular shell, connect to the machine using ssh or telnet and run your commands that way. Many ssh/telnet clients (PuTTY, for instance) have an option to log all console input and output during the session. You should be able to post-process this log to generate whatever type of logfile that you need.
Depending on your setup, you might not even have to use a second machine (you should be able to ssh into yourself).

Unable to put a simulation in C to a webpage

I have the following simulation in C for cars in a traffic circle
alt text http://dl.getdropbox.com/u/175564/cars.png
For example,
7 <space> <enter>
gives more cars to the simulation, while
s1 <enter>
puts a top sign to the incoming road #1.
I want to put the simulation to an internet page such that users can try it.
However, I do not know where I should start.
I know Joomla and little about Django. Perhaps, they can be useful.
How can you put a C program to a Webpage such that users can use it?
CGI is what you want; it will let you embed any program you want into a website, it was made for that purpose. Then perhaps embedding a few more options with PHP and HTML will let the user acutally input data into the program via the web. It should not be too hard.
Take a look here for more info: http://www.cs.tut.fi/~jkorpela/perl/cgi.html
I think that is a good pointer in the right direction. I hope that helps.
You could run the C code in a flash app using alchemy:
http://labs.adobe.com/technologies/alchemy/
Here's a good intro to writing CGIs in C: http://www.cs.tut.fi/~jkorpela/forms/cgic.html
However, since you're a beginner, I'd recommend porting your program to PHP. It's a very easy language to pick up, and it's a much easier route than writing a CGI in C.
I assume the C program needs input while it's running and not via command-line arguments? If I'm wrong, you can just use PHP and shell_exec() to run the program. The function returns anything printed to stdout.
Such a page might look like:
$sim = shell_exec("/path/to/binary -a 5 -b 6");
echo $sim;
Where the string passed to shell_exec is exactly what you'd type on the command line.
If you want a dynamic simulation, where the cars moves while you watch , you'll need an applet or flash.
A cgi program renders the page on each http GET/POST (on reload, submit etc)
and that is probably not what you want.
I would start with a flash or java applet wrapper. You can communicate with your application over a tcp connection and display the results in the flash or applet.
I would recommend going with sockets. If your C program could set up and listen on a local or internet socket, you could use the socket facilities in any language to send it arguments and get output.
If that's going to be too much of a pain, have php exec the program while directing the output to some file. Then, have php read that file.
Looking at the output of your program, I think trying to print the results of shell_exec() will result in clobbered output.
So, you could shell_exec("/bin/program -arguments > /tmp/prog-tmp.txt") , then read prog-tmp.txt.

Resources