11 Replies - 461 Views - Last Post: 10 February 2020 - 09:33 PM Rate Topic: -----

#1 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 815
  • Joined: 15-December 14

Can't figure out how to mak emy gui work

Posted 01 February 2020 - 04:53 PM

I've decided to re make my programs from command line to gui. I wanted to work on the program which would delete cache, cookies and browser history. It works when I use it with command line but I can't figure out why it won't work when I use the gui. I'm out of ideas to make this work.

My idea is to have the user use a gui and then have the code clear cache,cookies and browser history.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//
using System.ComponentModel;
using System.Threading;
using System.Diagnostics;
//
using System.Collections.Generic;
using System.IO;
using System.Text;
//
using System.Windows.Forms;

namespace GarbageSweeperGUI
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {

        }
        private void btnInternetExplorer_Click(object sender, EventArgs e)
        {
            Console.WriteLine("Deleting browser history");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 1");
            Thread.Sleep(7000);
            Console.WriteLine("Deleting cookies");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 2");
            Thread.Sleep(7000);
            Console.WriteLine("Deleting Temporary Internet Files");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 8");
            Thread.Sleep(7000);
            Console.WriteLine("Deleting form data");
            System.Diagnostics.Process.Start("rundll32.exe", "InetCpl.cpl,ClearMyTracksByProcess 16");
            Thread.Sleep(7000);
        }
    }

}



Is This A Good Question/Topic? 0
  • +

Replies To: Can't figure out how to mak emy gui work

#2 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7244
  • View blog
  • Posts: 24,556
  • Joined: 05-May 12

Re: Can't figure out how to mak emy gui work

Posted 01 February 2020 - 05:12 PM

What behavior are you seeing? What behavior are you expecting to see?

If you created your project as a WinForms project, any of the Console.WriteLine() calls that you have won't display anything because there is no console window associated with an executable compiled as a Windows executable by default.

Did you set breakpoints on your Process.Start() calls? Do the returned objects indicate where the processes ran successfully?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7244
  • View blog
  • Posts: 24,556
  • Joined: 05-May 12

Re: Can't figure out how to mak emy gui work

Posted 01 February 2020 - 06:42 PM

This StackOverflow answer regarding needing to also run at a lower integrity level may also be relevant.
Was This Post Helpful? 0
  • +
  • -

#4 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 815
  • Joined: 15-December 14

Re: Can't figure out how to mak emy gui work

Posted 02 February 2020 - 11:54 AM

Sorry I thought i included what the program was doing in my question.

The gui appears but nothing happens when I press the button for the program to clear the growers history, cookies and cache. I looked through a bunch of different tutorials before making this program and I can't figure out why it's not working


I left the deadline there as so I could know what each line was suppose to do. I got It to comment them out.

I'll look at the links you suggested when I get home from watching the super bowl game tonight.
Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7244
  • View blog
  • Posts: 24,556
  • Joined: 05-May 12

Re: Can't figure out how to mak emy gui work

Posted 02 February 2020 - 02:29 PM

View Postalbert003, on 02 February 2020 - 01:54 PM, said:

The gui appears but nothing happens when I press the button for the program to clear the growers history, cookies and cache.

Well, since you stop the message pump for 7 seconds at a time with your calls to Thread.Sleep(), the of course it will appear that nothing is happening with the GUI. What were you expecting to see on the GUI? It's not like you were trying to update any GUI elements before, during, or after starting those processes.
Was This Post Helpful? 0
  • +
  • -

#6 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6833
  • View blog
  • Posts: 28,345
  • Joined: 12-December 12

Re: Can't figure out how to mak emy gui work

Posted 03 February 2020 - 02:14 AM

You can also do the standard things of setting breakpoints (checking if your code is hit), looking at the Output or Immediate Windows, etc..
Was This Post Helpful? 0
  • +
  • -

#7 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 815
  • Joined: 15-December 14

Re: Can't figure out how to mak emy gui work

Posted 03 February 2020 - 12:50 PM

Skydiver
I had those break points originally when I had it as a command line code because I thought it would be considered bad coding to have it do everything at once.

I thought I could have the gui allow the users to pick which browser they wanted to delete cookies, cache etc and it would work in the back ground. In the original code the users can choose between IE,Chrome, MS Edge and Mozilla. Everything works but I want to make it work with a gui. My plan is to have what the code is doing in the back ground without showing what its doing. But I wanted to work on that after I get the gui to work.

Are you suggesting I use bat script instead of what I am currently using?

andrewsw
I'm not sure I know what you mean. Is this what you meant?
https://www.google.c...ZDr_QaQkqXoBQ33


I actually had a brain storm last night how to make the gui do what I wanted it to do. I will work on it and see how well it works.

This post has been edited by albert003: 04 February 2020 - 08:00 AM

Was This Post Helpful? 0
  • +
  • -

#8 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 815
  • Joined: 15-December 14

Re: Can't figure out how to mak emy gui work

Posted 07 February 2020 - 10:45 PM

My idea worked perfectly!!!!

Thank you everyone for your help.
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7244
  • View blog
  • Posts: 24,556
  • Joined: 05-May 12

Re: Can't figure out how to mak emy gui work

Posted 08 February 2020 - 08:51 PM

Congratulations! How do you end up solving your problem?
Was This Post Helpful? 0
  • +
  • -

#10 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 815
  • Joined: 15-December 14

Re: Can't figure out how to mak emy gui work

Posted 08 February 2020 - 10:47 PM

I didn't realise I had to go to properties and put in btnIE (Internet Explorer) and I was also manually putting in that function. I found out I could just touch the button I created called Internet Explorer and it would create that function.

I tried to include a screen shot I took of my program working which didn't work.

garbagesweeper.png

This post has been edited by albert003: 08 February 2020 - 10:50 PM

Was This Post Helpful? 0
  • +
  • -

#11 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7244
  • View blog
  • Posts: 24,556
  • Joined: 05-May 12

Re: Can't figure out how to mak emy gui work

Posted 09 February 2020 - 11:41 AM

Ah! You thought that C# WinForms has the same "AutoWire" feature that VB.NET and ASP.NET have. (The AutoWire feature tries to automatically attach event handlers to UI controls if you followed a particular naming convention.) I'm glad you figured it out.

As for uploading pictures, due to the major successful hack on this site about a year and a half ago, the site owner has increased security by locking down a lot of features in the backend (but unfortunately kept the frontend UI). The net result is inability to upload pictures, some posts with particular keywords being blocked from posting/saving, etc. The way most of us have been working around the issue is by using imgur or some other picture hosting site, and then linking to the pictures there.
Was This Post Helpful? 0
  • +
  • -

#12 albert003   User is offline

  • D.I.C Addict

Reputation: 37
  • View blog
  • Posts: 815
  • Joined: 15-December 14

Re: Can't figure out how to mak emy gui work

Posted 10 February 2020 - 09:33 PM

Exactly. While I was trying to figure out how to make it work I had a few ideas to make the program work. But they wouldn't have been a good idea. One idea was to have the code with the gui call another program that runs on command line. But I'm glad I figured out how to make th3 program work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1