How to Create a Setup file in Visual Studio 2019 – C# or VB.Net

Today we are going to be creating a setup file using Visual Studio! This setup file is a packaged version of your application with a wizard that guides the user through the entire installation process.

If you have ever written an application and wanted to create an MSI or EXE installer then this is the guide for you! I’m going to go step by step and show you exactly how to create an installer!

Install Wizard

The entire process is pretty easy and simply requires a visual studio extension that was developed by Microsoft. This extension is not a 3rd party product nor is it terribly complicated to use.

Alright, so let’s get right into it!

The first thing we’re going to need to do is to download the required extension. The extension we will need is called “Microsoft Visual Studio installer project”

You access the Manage Extensions page by clicking on Extensions and then Manage Extensions at the top

Once you are on the Manage Extensions page, search for this extension. It is one of the most downloaded extensions, so it should be at the top of the list. Go ahead and download it, then we can move on to the next step!

Next, we need to restart visual studio to get it to install the extension. Once visual studio closes this little extension installer will install the new extension.

Once the extension installer comes up hit modify and let it progress through. This can take a second to install but it doesn’t take terribly long. It should only take about a minute or so.

VS Extension installer



alright, once that has finished installing, you can open visual studio again.

Now that you have Visual studio open again, you want to open the project that you would like to create the installer for. because it’s going to be a second project inside the same solution.

alright, so now that we’ve got our extension ready to go we are going to right-click on the solution and add a new project. This new project is going to be the setup project. Search for the setup project template and choose that as your new project type.

Setup Project Template

Once you select Setup Project, give it a name and then click create. This will create a second project under your Solution with the name you provided.

If you open that project, you will be greeted with the setup project’s main screen as shown below.

Setup project

Inside of this project, there will be 3 folders:

  • Application folder: This is where your exe and assembly files will be placed.
  • Desktop folder: This will be where we put items destined for the user’s desktop.
  • User’s Program Menu: This will be where we put items to be added to the user’s program menu.

To configure your new setup project follow these steps

  1. Add a new project output to the application folder.

    Select the Application Folder and then right click and select “Add a new Project Output”. This will copy over all of your dll’s and main exe from your other project. This will look just like your typical Debug folder contents. Add -> Project Output -> “Primary Output”

  2. Create a new shortcut using the primary output item

    Right click the Primary Output item that was added when you added the new project output to the Application Folder. Select “Create Shortcut” to create a new shortcut that we will later move to the desktop section.

  3. Import a file to be used as a shortcut icon

    Right click again, select Add and choose to add a file. Browse for an ico file and import it.

  4. Update your shortcut’s icon to the new imported icon

    Right click on the new shortcut we have created, select “Properties Window”, from here change the icon by clicking browse on the right. Browse into your Application Folder and choose the new icon.

  5. Copy your shortcut to the User’s Desktop folder

    Drag your new shortcut over to the User’s Desktop folder on the left side of the split-screen. This will make the wizard create that shortcut on the user’s desktop when the application is installed.

  6. Create another shortcut and put it in the User’s Programs Menu

    Now that you have the desktop shortcut in place, we need to create one more identical shortcut. Follow the same process to create the shortcut and set it’s icon. After you have the new setup created, right click on User’s Programs Menu and select to create a new folder. Create a folder for your shortcut to be under and then move your new shortcut into that folder. Now the User’s Programs Menu will have a shortcut created in it.

  7. Update the properties of the new setup project

    From this point, I would update a few properties of the setup project.
    Author: company or person who wrote the application
    Description: simple description about the app
    Manufacturer: Used for the install location.
    Those are the only properties I updated in my example.

  8. Setup Prerequisites

    If you right click the Project and select Properties, you can then click on a button that says “Prerequisites…” This will bring up a screen where you can choose to have certain prerequisites such as certain .net framework versions install with your application.

  9. Build the setup project and Give it a test run!

    Right-click on the project and choose build. Once it finishes building, right-click again and select “Open Folder in File Explorer”. This will bring up a folder with your install files in it!

Congratulations! That is all there is to it! At this point, you should have a working setup project! I hope this guide was helpful! I’ll see you in the next one!

Beginning C# – While Loops – Beginners guide to While Loops in C#

Hey everyone! Today we are going to be learning about While loops in C#. This is going to be a quick tutorial on how and why we use While statements and a general introduction to loops in programming.

A while loop is used to execute a block of code over and over until some condition is met.

For a simplified English example: “While the background color is red do these things.” This would do [these things] over and over until the background color is no longer red.

The while loop is very similar to a “for” loop. It will loop over and over again until the condition is met. This is the structure of a while loop:

while (condition)
{
//code to be executed
}

The main difference between a for loop and a while loop is that the while loop doesn’t increment the variable that it is testing each loop. Typically a for loop will be used when you have a set number of times something needs to happen. A while loop, on the other hand, is used when you need to loop until something is true or false.

This would be an example of a while loop that works just like a for Loop. Notice how there is a specific line to increment i, it doesn’t get incremented by the while loop itself.

While loop

Alright! let’s make a sample application!

Looping Application

To create this sample while loop application follow these steps:

  1. Create a new Windows forms project

    Open Visual Studio and create a new Win Forms application.

  2. Add a “Max” textbox

    Drag over a textbox from the toolbox and rename it txtMax. This will be used to store the number we would like to loop to.

  3. Add a “Max” label

    Add a label control to the left of the Max textbox, set it’s text property to Max as shown above.

  4. Add a list to show items

    Add a new list box to the form. We will use this to show results as the while loop runs. Rename this list box to LstItems.

  5. Add a Calculate button

    Drag a button over from the toolbox and change it’s text property to Calculate. Also change it’s name to btnCalc.

You should now have your sample form built and it is time to start writing code. I would go ahead and run the application, just to make sure everything is working properly before we begin writing code.

Once you have verified that your application is running properly, it is time to start writing code. First double click on the Calculate button. This will create an event handler for the buttons click event. Inside of this function, we are going to write a while loop that runs from 1 to 18. Inside of this loop, we are going to have it add an item to LstItems that displays the current age. The code for that looks like this:

int age = 1;
while(age <= 18)
{
LstItems.Items.Add(age);

Age = Age + 1;
}

Alright, now that we have our code written, it’s time to give the program a whirl! Your results should look like this:

loop from 1 to 18

Your Listbox should now show 1 to 18!

If you want to better visualize this process, you can add a breakpoint on the while statement (by clicking the line to the left of the line numbers in Visual Studio) and use F10 to step through as the code executes. This should help you really understand what the code is doing by watching it execute line by line.

breakpoints!

Alright, so we know how to use a while loop to count numbers, let’s create one more example. This example will read line by line through a file and when it runs out of lines the loop will end. This is something someone would use a while loop for instead of a for loop.

You will need to create a file and store a few values in it. I personally listed a few different foods in my text file and saved it to C:\Test\LoopTest.txt
My contents looked something like this:

Pizza
Hamburger
Hot Dog

Now that you have saved it somewhere, the code you will need to read this file is this:

LstItems.Items.Clear(); //This will clear our listbox out
System.Io.StreamReader sr = new System.IO.StreamReader("C:\\Test\\LoopTest.txt");
String currLine = sr.ReadLine();

While(currLine != null)
{
LstItems.Items.Add(currLine);
currLine = sr.ReadLine();
}

You may have to adjust the file location the stream reader is reading from but other than that, this code should run fine.

This code will first clear your list box, then it will read through your file and add each value to the list box until it runs out of items to read. Once the StreamReader has read the last item in the file, the next ReadLine will set currLine to null and that is when our test will fail and the While loop will end.

That’s really all there is to while loops! I hope this helped and I will see you in the next one!

How to Send email using C# and Gmail

hey everyone! Today we are going to be writing a simple application in CSharp that can send emails!

This application is going to be a simple little SMTP Client that will interface with Gmail’s Servers using your username and password. Since this is a pretty simple task, there isn’t a whole lot of code, so it’s a great project to start learning with!

Alright! Lets get right into building the application!
In this tutorial, I’m going to be using the devexpress components. They work just like the default windows components, they just look a little better.
The code behind is what is important and it will look almost identical regardless of the form controls.

Devexpress Blank application

Once you create your new windows forms project follow these steps to build out the UI

  1. Rename the form and change it’s text property

    Rename the form by hitting f4 to access the properties window

  2. Grab a groupbox and rename it to “Mail”

    Drag a group box over from the toolbox window. Change it’s text property (or caption) to Mail

  3. Drag over another group box and rename it to “Settings”

    Drag a second group box over from the toolbox window and change it’s text property to Settings.

  4. Add a splitter panel

    Drag a splitter panel over and put the Mail group box in the first half and the Settings group box in the second half.

  5. Dock the splitter panel to fill

    Have the new splitter panel fill the form out. Set Horizontal to false, so we have a Mail section at the top and Settings section at the bottom.

  6. Add a layout control to the bottom

    Drag and drop a layout control into the Settings group box. Have it dock to fill and we will use this to add our controls.

  7. Add textboxes to the Settings Layout control

    Add a Username textbox to the Settings layout control.
    Add a Password textbox to the Settings layout control.
    Both of those should be full width.
    Add a Port textbox to the Settings layout control, this should be half width.
    Add an SMTP textbox to the Settings layout control, this should be half width as well.

  8. Add a button to the Settings Layout Control

    Add a button to the right of the Port and SMTP text boxes. Rename this button to Send and this will be the button that sends our mail!

  9. Set default values

    Change the text property of the Username textbox to your Gmail address. Change the text property of the Port textbox to “587”. Finally, update the SMTP textbox text to be “smtp.gmail.com”

  10. Add textboxes to the Mail section

    Add a textbox to the Mail section and label it “To:”
    Add a second textbox to the mail section and label it “Subject:”
    Lastly, add a multi-line text edit to the mail section and label it “Body” (This can be a regular textbox)
    Your form should look like this:


Alright!! Now we have our form completed! It’s time to write some code!

First, we are gonna double-click on the send button, this will generate an event handler which we will put the code to send the email inside of.

Send event handler

The first line of code we are going to write will create a new NetworkCredential object called login. This will be used to pass the username/password to Gmail.

NetworkCredential login = new NetworkCredential(txtUsername.Text, txtPassword.Text);

Next we will need to create an SMTPClient object which will actually send the message. This line looks like the following:

SmtpClient client = new SmtpClient(txtSMTP.Text);

After writing that line, you will get an error and have to import System.Net.Mail. That line looks like this:

using System.Net.Mail;

After you have that setup, it is time to set our client up so it can send the message. The first setting we are going to set is the Port number. This needs to match google’s port number which is 587. This line converts our textbox’s text to an integer (variable type for numbers) and sets the client’s port to the number stored in our port textbox.

Client.Port = Convert.ToInt32(txtPort.Text);

Our next thing will be to enable SSL. Google requires SSL be enabled to use Gmail. So that code looks like this:

client.EnableSSL = true;

The last thing we are going to do is pass the credentials to the new client object and thanks to previously creating the login variable, that line looks like this:

client.Credentials = login;

Now that our client is setup, we just need to create the mail addresses and we will be ready to form our message! The code to create our mail addresses is listed below.

MailAddress sendAddr = new MailAddress(txtUsername.Text);
MailAddress recAddr = new MailAddress(txtSendTo.Text);

Next, we will need to create a new Mail Message, this is the actual content of the message.

I’m going to explain each line in paragraph form and then show the block of code after so it will be easier to copy/paste.

First, we create the object, passing it the sender and receiver addresses. After that, we pass the subject textbox’s text property as the subject. Then we pass the memo edit’s (or textbox if you used that instead) text property as the body. After that, we set the BodyEncoding to UTF8, I wouldn’t worry about this, it’s just a character encoding type. IsBodyHTML is just used to tell if the email contains HTML markup or not, I used true for this and it worked fine. Priority seems like a silly property but normal makes the most sense. Lastly, DeliveryNotificationOptions will notify you if the message fails to send.

MailMessage msg = MailMessage(sendAddr, recAddr);
msg.Subject = txtSubject.Text;
msg.Body = memBody.Text;
msg.BodyEncoding = Encoding.UTF8;
msg.IsBodyHtml = true;
msg.Priority = MailPriority.Normal;
msg.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;

Alright! That was a huge block of code and we are almost there! Your code should look something like this now!

Send code so far

Now we need to set up the Send Completed event handler. This isn’t totally necessary but it is nice that our application will be able to display an error if the send fails.

Below DeliveryNotificationOptions, we need to add the following code:

client.SendCompleted += new SendCompletedEventHandler(sendCallback);

This line will call the sendCallback function with a result. Now we just need to write that function!

private static void sendCallback(object sender, AsyncCompletedEventArgs e)
{
if (e.Cancelled || e.Error != null)
{
MessageBox.Show("Error sending Email!");
}
else
{
MessageBox.Show("Sent Successfully!");
}
}

This will show an error message or success message depending on the result!

Our very last lines will be the lines to send the email! This will be added back inside of our click event handler below the SendCompleted line!

string userToken = "sending"
client.SendAsync(msg, userToken);

The resulting code will look like this, sorry the box cuts off a little bit of the sendCallback code.

Completed Code

Once you have the code in place it is time to give it a test run! We have to change one setting in google to make this work. Google “Low Security Applications”, the top link should be a support.google.com link.

Less secure app access

After that, you need to click Less Secure App Access and allow Less secure Apps.

Without this option turned on, Google will not send your emails!

Once that is all set up, build your application and fill it out, this is what my application looked like all filled out!

SMTP client filled out

Once I hit the send button, the email sent! This is my test email that worked. Thanks for reading, I really hope this helped you out! If you have any questions, let me know in the comments below!!

Working test email

How to Read and Write to the Clipboard using C#

Hey everyone and welcome back!

Today we’re going to be learning about the clipboard, which is a really cool thing to be able to use in C#! On top of being a super useful thing to manipulate, the clipboard is really easy to work with!

If you aren’t familiar with the clipboard, what I’m talking about is when you type a word and then right-click and then copy the text. This copies the text to your “Clipboard”

The Clipboard is kind of an invisible notepad that you can copy things to and paste from. For example, you could type your name out, copy your name and then paste it to multiple places. This saves you from typing the same thing over and over again.

Alright! On to the programming! We can easily access this clipboard and have our programs do some pretty cool stuff!

Clipboard App

First, you are going to want to create a sample application like the one I have above (also shown in the video)

This little form has a text box at the top, a picture box in the middle and a button on the bottom. Nothing special there. Next, we are going to go ahead and add some code.

Double click on the button and that will create an event handler for the button’s click event. This is where we are going to do most of our operations.

To access the clipboard we are going to use the clipboard class that is inside of the system.windows namespace. So the first thing to do is make sure system.windows is imported.

using System.Windows;

Once you have system.windows imported, it’s time to use the clipboard.getText function to get the text currently saved to your clipboard.

this.txtGetData.Text = Clipboard.GetText();

Our textbox is named txtGetData and this line will set the text of that textbox to whatever text is saved in your clipboard using the Clipboard.GetText function!

In the video, I wrote some text out in notepad and copied it. Once the text was in my clipboard, all I had to do was click the giant button at the bottom to run the code and have it set the textbox’s text to what I had copied.

clipboard button clicked

The next function we are going to use is the Clipboard.GetImage() function. This can be used to retrieve an image that has been copied to your clipboard. My picturebox is named pbData and the line of code to copy the image from the clipboard looks like this:

pbData.Image = Clipboard.GetImage();

So for our example, I am going to pull up a random image using google images and then copy it to my clipboard by pressing the button.

Image copied to clipboard using GetImage()

Next, we are going to write some text TO our clipboard. This is done in a very similar way. Instead of GetText() we are going to use SetText(). Below is an example of me setting the text of my clipboard to whatever was typed into the textbox.

Clipboard.SetText(txtGetData.Text);

Setting clipboard text

Copying an image to your clipboard is done in a very similar way. The code for that (with a picture box named pbData) is:

Clipboard.SetImage(pbData.Image);

And… That’s about it for copying text & images to and from the clipboard! Those are definitely the most common uses for the Clipboard class but there are two more relatively common things you can use the Clipboard class for. You can copy raw Data to and from the clipboard and you can clear the clipboard.

To copy raw data from the clipboard, you are going to use this function:

Object obj = Clipboard.GetData();

This can be used to copy/paste all kinds of data!

The last item on our list to cover is the clear function. This will erase any data that is currently stored in your clipboard!

Clipboard.Clear();

And that about wraps up working with the Clipboard in C#! I hope this helped you on your current project and thanks for reading!

Beginning C# – Switch Statements – Beginners guide to switch statements in C#

by Darkspy13 0 Comments

Today we are going to be learning about switches in C#

Switch statements are a way to simplify if statements. Once you get a lot of if statements together the code starts becoming very cumbersome and switches are just a really elegant way of cleaning that up.

Today, We are going to break switches down while creating a sample application!

Switch structure

If you were with us last time, you are probably familiar with this form that we designed previously. This form has a label and a textbox. It also has a picture box that we are going to change the background color of using switch statements. We also have a button to perform calculations.

Sample App

First, we are going to set the label control up for our new project. We are going to change the label’s text from “age” to “color” and change it’s name to “lblcolor”

Label name

The idea of the application is going to be that the user can type in the name of a few different colors and we will update the picture box’s background color to reflect whatever color the user input.

color changer

Alright,
To do that we’re going to use a switch statement that switches based on the text you type into the textbox. We are going to have a case that’s going to be red and our first build will end there. This is basically just a simple if statement.

Inside the select statement we are going to say

pbResult.BackColor = Color.Red;

This will set the picture box’s background color to red. Now we are going to add a few other colors, such as Blue, Black, and White.

Keep in mind, CSharp is case sensitive, so this has to be a capital “B” for “Black”

switch (txtColor.Text)
{
case "red":
     pbResult.BackColor = Color.Red;
     break;
case "blue":
     pbResult.BackColor = Color.Blue;
     break;
case "black":
     pbResult.BackColor = Color.Black;
     break;
case "white":
     pbResult.BackColor = Color.White;
     break;
default:
     pbResult.BackColor = Color.Brown;
     break;
}

all right, so once you have recreated the UI and you have the above code in the click event of the button. It is time to run the application and give it a test.

What should happen is, when you type “red” into the textbox and then click the button, it will run the block of code that sets the BackColor to Red. When you type “blue” into the textbox and press the button, it will change the BackColor of the picture box to Blue!

Test with Blue picture box!

You could create this same logic with an IF statement but it would be a lot longer. The logic here is simply, if text = “red” then set the background color to red, elseif text = “blue” then set the background color to blue, and you would just repeat that logic for every color and use an else in place of default.

I hope this simple explanation of switches in C# helped! I am a hands-on type learner myself, so projects like this is how I prefer to learn things.

If you have any questions please ask in the comments below! Also, if you want me to go over any topics just let me know! I appreciate you guys sticking around and would love to help with topics you have in mind!

I’ll see you in the next one!

Important Windows 10 Keyboard Shortcuts for 2021

by Darkspy13 0 Comments
Important Windows 10 Keyboard Shortcuts for 2021

Important Keyboard Shortcuts for Windows 10. If you are looking for the best list of keyboard shortcuts then you have come to the right place. This list is pretty extensive and will make your computing that much faster!

CTRL+A. . . . . . . . . . . . . . . . . Select All
CTRL+C. . . . . . . . . . . . . . . . . Copy
CTRL+X. . . . . . . . . . . . . . . . . Cut
CTRL+V. . . . . . . . . . . . . . . . . Paste
CTRL+Z. . . . . . . . . . . . . . . . . Undo
CTRL+B. . . . . . . . . . . . . . . . . Bold
CTRL+U. . . . . . . . . . . . . . . . . Underline
CTRL+I . . . . . . . . . . . . . . . . . Italic
F1 . . . . . . . . . . . . . . . . . . . . . . Help
F2 . . . . . . . . . . . . . . . . . . . . . Rename selected object
F3 . . . . . . . . . . . . . . . . . . . . . Find all files
F4 . . . . . . . . . . . . . . . . . . . . . Opens file list drop-down in dialogs
F5 . . . . . . . . . . . . . . . . . . . . . Refresh current window
F6 . . . . . . . . . . . . . . . . . . . . . Shifts focus in Windows Explorer
F10 . . . . . . . . . . . . . . . . . . . . Activates menu bar options
ALT+TAB . . . . . . . . . . . . . . . . Cycles between open applications
ALT+F4 . . . . . . . . . . . . . . . . . Quit program, close current window
ALT+F6 . . . . . . . . . . . . . . . . . Switch between current program windows
ALT+ENTER. . . . . . . . . . . . . . Opens properties dialog
ALT+SPACE . . . . . . . . . . . . . . System menu for current window
ALT+¢ . . . . . . . . . . . . . . . . . . opens drop-down lists in dialog boxes
BACKSPACE . . . . . . . . . . . . . Switch to parent folder
CTRL+ESC . . . . . . . . . . . . . . Opens Start menu
CTRL+ALT+DEL . . . . . . . . . . Opens task manager, reboots the computer
CTRL+TAB . . . . . . . . . . . . . . Move through property tabs
CTRL+SHIFT+DRAG . . . . . . . Create shortcut (also right-click, drag)
CTRL+DRAG . . . . . . . . . . . . . Copy File
ESC . . . . . . . . . . . . . . . . . . . Cancel last function
SHIFT . . . . . . . . . . . . . . . . . . Press/hold SHIFT, insert CD-ROM to bypass auto-play
SHIFT+DRAG . . . . . . . . . . . . Move file
SHIFT+F10. . . . . . . . . . . . . . . Opens context menu (same as right-click)
SHIFT+DELETE . . . . . . . . . . . Full wipe delete (bypasses Recycle Bin)
ALT+underlined letter . . . . Opens the corresponding menu
PC Keyboard Shortcuts
Document Cursor Controls
HOME . . . . . . . . . . . . . . to beginning of line or far left of field or screen
END . . . . . . . . . . . . . . . . to end of line, or far right of field or screen
CTRL+HOME . . . . . . . . to the top
CTRL+END . . . . . . . . . . to the bottom
PAGE UP . . . . . . . . . . . . moves document or dialog box up one page
PAGE DOWN . . . . . . . . moves document or dialog down one page
ARROW KEYS . . . . . . . move focus in documents, dialogs, etc.
CTRL+ > . . . . . . . . . . . . next word
CTRL+SHIFT+ > . . . . . . selects word
Windows Explorer Tree Control
Numeric Keypad * . . . Expand all under current selection
Numeric Keypad + . . . Expands current selection
Numeric Keypad – . . . Collapses current selection
¦ . . . . . . . . . . . . . . . . . . Expand current selection or go to first child
‰ . . . . . . . . . . . . . . . . . . Collapse current selection or go to parent
Special Characters
‘ Opening single quote . . . alt 0145
’ Closing single quote . . . . alt 0146
“ Opening double quote . . . alt 0147
“ Closing double quote. . . . alt 0148
– En dash. . . . . . . . . . . . . . . alt 0150
— Em dash . . . . . . . . . . . . . . alt 0151
… Ellipsis. . . . . . . . . . . . . . . . alt 0133
• Bullet . . . . . . . . . . . . . . . . alt 0149
® Registration Mark . . . . . . . alt 0174
© Copyright . . . . . . . . . . . . . alt 0169
™ Trademark . . . . . . . . . . . . alt 0153
° Degree symbol. . . . . . . . . alt 0176
¢ Cent sign . . . . . . . . . . . . . alt 0162
1⁄4 . . . . . . . . . . . . . . . . . . . . . alt 0188
1⁄2 . . . . . . . . . . . . . . . . . . . . . alt 0189
3⁄4 . . . . . . . . . . . . . . . . . . . . . alt 0190
PC Keyboard Shortcuts
Creating unique images in a uniform world! Creating unique images in a uniform world!
é . . . . . . . . . . . . . . . alt 0233
É . . . . . . . . . . . . . . . alt 0201
ñ . . . . . . . . . . . . . . . alt 0241
÷ . . . . . . . . . . . . . . . alt 0247
File menu options in current program
Alt + E Edit options in current program
F1 Universal help (for all programs)
Ctrl + A Select all text
Ctrl + X Cut selected item
Shift + Del Cut selected item
Ctrl + C Copy selected item
Ctrl + Ins Copy selected item
Ctrl + V Paste
Shift + Ins Paste
Home Go to beginning of current line
Ctrl + Home Go to beginning of document
End Go to end of current line
Ctrl + End Go to end of document
Shift + Home Highlight from current position to beginning of line
Shift + End Highlight from current position to end of line
Ctrl + f Move one word to the left at a time
Ctrl + g Move one word to the right at a time
MICROSOFT® WINDOWS® SHORTCUT KEYS
Alt + Tab Switch between open applications
Alt +
Shift + Tab
Switch backwards between open
applications
Alt + Print
Screen
Create screen shot for current program
Ctrl + Alt + Del Reboot/Windows® task manager
Ctrl + Esc Bring up start menu
Alt + Esc Switch between applications on taskbar
F2 Rename selected icon
F3 Start find from desktop
F4 Open the drive selection when browsing
F5 Refresh contents
Alt + F4 Close current open program
Ctrl + F4 Close window in program
Ctrl + Plus
Key
Automatically adjust widths of all columns
in Windows Explorer
Alt + Enter Open properties window of selected icon
or program
Shift + F10 Simulate right-click on selected item
Shift + Del Delete programs/files permanently
Holding Shift
During Bootup
Boot safe mode or bypass system files
Holding Shift
During Bootup
When putting in an audio CD, will prevent
CD Player from playing
WINKEY SHORTCUTS
WINKEY + D Bring desktop to the top of other windows
WINKEY + M Minimize all windows
WINKEY +
SHIFT + M
Undo the minimize done by WINKEY + M
and WINKEY + D
WINKEY + E Open Microsoft Explorer
WINKEY + Tab Cycle through open programs on taskbar
WINKEY + F Display the Windows® Search/Find feature
WINKEY +
CTRL + F
Display the search for computers window
WINKEY + F1 Display the Microsoft® Windows® help
WINKEY + R Open the run window
WINKEY +
Pause /Break
Open the system properties window
WINKEY + U Open utility manager
WINKEY + L Lock the computer (Windows XP® & later)
OUTLOOK® SHORTCUT KEYS
Alt + S Send the email
Ctrl + C Copy selected text
Ctrl + X Cut selected text
Ctrl + P Open print dialog box
Ctrl + K Complete name/email typed in address bar
Ctrl + B Bold highlighted selection
Ctrl + I Italicize highlighted selection
Ctrl + U Underline highlighted selection
Ctrl + R Reply to an email
Ctrl + F Forward an email
Ctrl + N Create a new email
Ctrl + Shift + A Create a new appointment to your calendar
Ctrl + Shift + O Open the outbox
Ctrl + Shift + I Open the inbox
Ctrl + Shift + K Add a new task
Ctrl + Shift + C Create a new contact
Ctrl + Shift+ J Create a new journal entry
WORD® SHORTCUT KEYS
Ctrl + A Select all contents of the page
Ctrl + B Bold highlighted selection
Ctrl + C Copy selected text
Ctrl + X Cut selected text
Ctrl + N Open new/blank document
Ctrl + O Open options
Ctrl + P Open the print window
Ctrl + F Open find box
Ctrl + I Italicize highlighted selection
Ctrl + K Insert link
Ctrl + U Underline highlighted selection
Ctrl + V Paste
Ctrl + Y Redo the last action performed
Ctrl + Z Undo last action
Ctrl + G Find and replace options
Ctrl + H Find and replace options
Ctrl + J Justify paragraph alignment
Ctrl + L Align selected text or line to the left
Ctrl + Q Align selected paragraph to the left
Ctrl + E Align selected

Managed Debugging Assistant ‘ContextSwitchDeadlock’

If you run into the ContextSwitchDeadlock issue, it doesn’t mean your code is actually broken. You can actually turn this exception off through the settings menu of Visual Studio. You have a couple of options when it comes to fixing this issue!

This is the error I received: Managed Debugging Assistant 'ContextSwitchDeadlock' :

Managed Debugging Assistant ‘ContextSwitchDeadlock’

There are two simple fixes for this issue, the first is to simply turn the option creating this error message in visual studio.

To turn this option off you need to go to exception settings by clicking Debug -> Windows -> Exception Settings

Open Exception Settings in Visual Studio

After that we need to expand Managed Debugging Assistants and uncheck ContextSwitchDeadlock

ContextSwitchDeadlock option

The other option is going to be just adding Application.DoEvents() to the section of code that is locking up the application and not pumping messages anymore. This way the system will know that the application hasn’t crashed and is still continuing to work properly.

Whichever way you solve the issue, I hope this guide helped! Thanks for reading and I’ll see you in the next one!

SSL_Module trouble while using CertBot

by Darkspy13 1 Comment

Are you having trouble setting up SSL using Certbot? Lets figure out your ssl_module issue and get your site secure again!

I was having a lot of issues because of the following two error messages…

Could not find ssl_module; not disabling session tickets.

Could not find ssl_module; not installing certificate.
Certbot failing due to ssl_module

I had googled this multiple times, with search queries such as: could not find ssl_module; not installing certificate and could not find the answer! It turns out that the answer was really simple!

You just have to run the below command and it will fix everything!

sudo yum install mod_ssl

This is the command for CentOS. The install command could be slightly different for you if you are using a different Linux distro.

You may have to use apt-get instead of yum if you aren’t using a Red hat based distro.

Once I ran the above command and installed the SSL module we were off to the races!

SSL Module installation

At this point, I was able to run Certbot again and it ran correctly! That’s all there was to it!

Certbot running successfully

The command I used to run certbot is listed below but it was a very simple command. Just sudo certbot –Apache but just in case that helped, I figured I would list it too

Sudo Certbot --Apache

Thanks for reading! I hope this helped! I was stuck on this for about an hour… Hopefully this got to you early in your search!

Beginning C# – If Statements – Beginners guide to if statements in C#

by Darkspy13 0 Comments

alright!

Darren here and welcome back to another c-sharp tutorial!
So, last time we worked on a hello world tutorial. If you missed it, I highly recommend starting there if you are brand new!

I’m going to assume at this point you know how to make a simple windows form and drag a button on it.
Today we are going to be talking about if statements in C#.

alright, so first we are going to make a simple little form that will turn a box green or red based on some conditions.
We are going to assume this is for a movie theatre entrance and make 18 the barrier for entry.
If the person is below 18, the box will turn red and if they are over 18 the box will be green!

so, we start off with getting a button and placing it on the form. This button is just going to say calculate.

Button Calculate

Alright, next we will rename it to button calc.
This button is actually going to be what runs our code. (the button’s click event triggers the event handler)

Next, we need to grab a textbox from our toolbox. This textbox will store the movie patreon’s age.
After adding this textbox, we need to rename it txtAge.

textbox and button

so after getting the button and textbox set up, we are going to need the actual PictureBox that’s background color will be changed.
Drag a PictureBox over from your toolbar and then rename it to pbResult. I’m calling it pbResult because we will be using it to display our results.

The last control we are going to bring over would be a label to make the form look a bit better. Change the text of the label to say “age” and center everything in the middle of the form.
It doesn’t have to be the best-looking form ever since this application is just for learning purposes. After that, rename the label to lblAge and that’s it for our controls.

controls

Now that we have our simple little form built out, we need to handle the button’s click event.
To do that, you need to go to your button and select it. Now hit f4 to open the properties window on the right.
Once you are there at the top right, there will be a lightning bolt symbol that once pressed switches from properties to events.

Click Event

After clicking on that button and getting to the events view, you should see the “Click” event in the list. Double click on the click events row and Visual Studio will take you to the code window.
It will have also written out a click event handler and place you inside of the new function it created.

Click event with code

Once you are inside of the newly created function, it is time to write a simple IF statement. The new if statement should say “if textbox text is greater than 18 then make the background color of the PictureBox green.”

You will most likely see a squiggly line. If you see it or not will be based on your current Visual Studio settings.
Visual Studio is showing this warning because the text inside the textbox is actually a string instead of an integer. Strings can hold letters and numbers, so the compiler is worried that the user could cause an error.

The way to stop the warning would be to wrap int.parse() around our string to convert it into an integer(number).

So the resulting code would look like this.

if (int.Parse(txtAge.text) > 18) 
{
   pbResult.BackColor = Color.Green;
}

Ok, now we can run the program and input an age. So first we put in 20 to test and the PictureBox should turn green. After that, stop the application and re-start it.

Testing


If you put in 10 this time, the PictureBox won’t turn green. Nothing will happen actually since our if statement’s condition wasn’t true.
The value has to be more than 18 for our code to run.

You can put in 19 to see it turn green again before closing it. Now let’s beef the application up a bit.
This time we want to include people that are 18 and not just over 18. To do that, we will need a greater than or equal to sign, which is what the operator I used below is.

Greater than Or Equal To

we can come back and we can say it’s 18 that’s greater than or equal to 18.
So, it turns green but the problem is that if we say 18 and then we change it to 12 it stays green because we don’t have any code setting the color to red.

So, what we can do is drop-down below the if statement and add an else.

This else is actually a part of the if statement. So we want to say “else” set the background color to red instead of green.

if (int.Parse(txtAge.text) >= 18) 
{
   pbResult.BackColor = Color.Green;
}
else
{
  pbResult.BackColor = Color.Red;
}

Once you add the new else, your if statement now reads “If the text boxes text is greater than or equal to 18 set the PictureBox background color to green otherwise set it to the color red.”

Alright, now run the application again with the else in place. Now we can input “19” and get green, then once we change the text to 10 and click the button, we get a red background!

Test with 10

okay, so next we are going to add in an else if which will be our last thing for today.


While an else is a catch-all for anything that doesn’t satisfy the if statement, else-if is similar but has a specific condition check as well.
This allows you to say something like: “if the first thing isn’t true BUT this other specific thing IS true then do this instead.”

if (int.Parse(txtAge.text) >= 18) 
{
   pbResult.BackColor = Color.Green;
}
else if (int.Parse(txtAge.text) == 17)
{
   pbResult.BackColor = Color.Blue;
}
else
{
  pbResult.BackColor = Color.Red;
}

So, with the else-if in our example, we are going to say if the age is 17 then we set the background color to blue.
Our logic is that the worker needs to make sure the kid looks mature enough or something.

anyways, to do this we are going to say if it’s greater than or equal to 18 it needs to be green else-if they’re 17, set it to blue, otherwise set it to red.

Now we run this and test it by inputting 20. This should set the picture box to green, if we change the text to 17, the picture box should turn blue.
Lastly, if we set the number to 16, the picture box should turn red.

Else if example

So, that is it really! That about sums up if statements in C#!

They are a really nice construct and you are going to use this over and over again.

This will be very similar in C#, Java, Python, Javascript, VB.Net etc.
You may have curly bracers “{ }” or the words “then” and “end” in vb, the syntax changes a little but the concept is the same.
If this then do this, else if this then do this other thing and else do that.

The cool thing is that once you get a handle on If Statements and learn how to put a simple form together, you will be able to make so many cool things!

That’s it for now,
I really hope you guys learned something from this and join me in the next one!

I’ll see you in the next one!

Beginning C# – Hello World – Create a basic windows app in Visual Studio 2019

by Darkspy13 0 Comments

hey everyone!
Darren here and today we’re going to be learning c sharp. We are going to kick this off by creating a hello world application!

This is going to be a simple little application where we have a label that says some text and we’re going to click on a button to change what that text says.

We may change some styles of the label and a couple of other things but this will be great to get you started learning software development!

Hopefully, this will help you get started. This is not going to be the most complicated application ever but let’s get right into it!

Okay, so first we are going to choose windows forms application c-sharp for windows.

We are going to click next and then we are going to call this project “hello world”.

Name your project

It is going to save in our repos folder, which is where visual studio 2019 saves all of it’s new projects by default. We are also going to use the latest version of the.net framework we have installed. After that we click create and then it’s going to open a new project with our new form.

New form

Just for fun i’m just going to change the text property on our form so i have this whole form selected and i choose the text property and just change the text to “hello world” and it’ll change the text up here.

Title text

Next, I’m going to go ahead and run this. When it’s running you can see that the text up top now says is “hello world” in the title. Visual Studio generates a regular form that looks just like every other application, you can drag it around, minimize and maximize it.

That all works but it’s simply a blank form for now.

Next, we are going to add some text to that form. The control to add text in C# would be the label control. So we are going to drag over a label here.

Next, I’m going to bring up the properties window for that label and you can change the text of it right here. I’m gonna change the text to “test”. I’m also going to rename the label to a test name. The name property is what you would reference this label by in code.

Alright, so now that our label has some new custom text and it has a new name. We are going to make our label bigger so we can see it better.

we will start by making it 48 point to make it super big! Something else cool you can do is: go up here to format and center the label in the form horizontally. After this our label is ready to go.

Test Label

Next, we are going to start our project and now we have this label in the middle of our form that simply says “Test”.

Alright, so now we want to add a button because we’re going to actually make some stuff happen. So we head over to our toolbox on the left and drag this button over to our form.

Button on form

Let’s head over to Format and center this button horizontally. I’m also going to change the text of the button just to say “click me!” using the text property.

Next, let’s name it “BtnClickMe”, so now we have a button called button click me and we have our test label ready to go.

With any of these controls that are on a form, they’re going to have events that you can access from the properties window. So if you come over here to events, there is a click event for this button and this will allow you to execute custom code when this button is clicked on.

If you select over here on the right side of the click event in the properties window and double click, visual studio will actually generate the click event handler for you.

Click event location

Once you have the method generated in code, click inside of it and we are going to write one line of code that will change the text of our label.

lblTest.Text = "Hello World!";

First, we call it our lblTest and lblTest has a Text property. The actual text of this label is stored inside of this Text property. We set this text property equal to the text “Hello World!”.

“Hello World!” has to be in quotes because that is how you tell C# it is a string. The last thing is the semi-colon on the end, which is customary in any C-Syntax based language.

The resulting function looks like this:

Hello world function

This will get executed when the button is clicked because this is the click event handler of that button.

So, next, we head back to the designer where we can hit start and run the program.

Run

So, now we’ve got our little label that says “Test” and then when we click our button, the label changes to “Hello World!”. It’s really that easy to get events firing and change simple things on the form.

For fun, we are going to go ahead and change the font color of the label when the button gets clicked, so you kind of get a better idea of what’s going on.

So, to do that, our label actually has a forcolor property that controls the foreground color. We are going to set that to Color.Red to set the foreground color of the label to Red.

LblTest.ForeColor = Color.Red;

Color.Red is just the enumerator for the color red. This literally just means red. so, we run the application again and click our button. now it says “Hello World!” and our text is now red.

Red Hello World

alright, so to keep this short and simple, we are going to end off there. I hope you were able to set the color to red on your test form and get the text to say Hello world.

After you get this going, you can definitely play around with other options and for example, set the label’s back color to black.

There are lots and lots of properties you can change and all kinds of other details about the label control you can edit on the fly.

I also want to point out that there are tons and tons of other controls out there. The possibilities are nearly endless. I really recommend just creating a new project and playing around with all of these different controls. Just start learning everything you can!

Alright, that about wraps it up for this one. I really hope that you learned something from this. I know this isn’t the most complicated project every but we will definitely get into more complicated projects going forward.

Well, thanks again and I’ll see you in the next one!