Tip Anyone can help me ??

zalamao123

Member
Joined
Oct 3, 2015
Messages
5
Programming Experience
Beginner
Hello, I tried so hard to fix this source but I cant fix it
sad.gif
I am new on C# area...

So I came here asking if someone can fix for me the form.cs bug

C#:
[/FONT]using house_inviter.Properties;using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Windows.Forms;


namespace house_inviter
{
  public class Form1 : Form
  {
    private bool check = true;
    public const uint WM_KEYDOWN = 256U;
    public const uint VK_CLEAR = 12U;
    public const uint WM_KEYUP = 257U;
    public const uint VK_RIGHT = 27U;
    public const uint VK_CONTROL = 11U;
    public const uint VK_ALT = 12U;
    public const int WM_CLOSE = 16;
    public const int WM_LBUTTONDOWN = 513;
    public const int WM_LBUTTONUP = 514;
    public const int WM_GETTEXT = 13;
    public const string xyz = "Sylluss";
    public const string configFile = "config";
    public const string invFile = "Sylluss/inv";
    private Process[] processlist;
    private IntPtr _window;
    private int selectedProcessId;
    private int x;
    private int y;
    private string fileHash;
    private bool blockWhenChangingStatus;
    private IContainer components;
    private ComboBox comboBox1;
    private Button button1;
    private Button button2;
    private System.Windows.Forms.Timer timer1;
    private Button button4;
    private Label label3;
    private Label label4;
    private LinkLabel linkLabel1;
    private NotifyIcon notifyIcon1;


    public Form1()
    {
      this.InitializeComponent();
      ContextMenu menu = new ContextMenu();
      menu.MenuItems.Add(0, new MenuItem("Exit", new EventHandler(this.Exit_Click)));
      menu.MenuItems.Add(0, new MenuItem("Show", new EventHandler(this.Show_Click)));
      SysTray sysTray = new SysTray("HOUSE AUTO INVITER - Sylluss", Resources.icon, menu);
      Bitmap bitmapStrip = new Bitmap((Image) Resources.icon1);
      bitmapStrip.MakeTransparent();
      sysTray.SetAnimationClip(bitmapStrip);
      sysTray.StartAnimation(200, 30);
      Bitmap icon1 = Resources.icon1;
      icon1.MakeTransparent();
      this.Icon = Icon.FromHandle(icon1.GetHicon());
    }


    [DllImport("user32.dll")]
    private static extern bool PostMessage(IntPtr hWnd, uint Msg, int wParam, int lParam);


    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    public static extern int SendMessage(IntPtr A_0, int A_1, int A_2, int A_3);


    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    private static extern int GetWindowText(int hWnd, StringBuilder title, int size);


    [DllImport("user32", CharSet = CharSet.Auto, SetLastError = true)]
    internal static extern int GetWindowText(IntPtr hWnd, [MarshalAs(UnmanagedType.LPTStr), Out] StringBuilder lpString, int nMaxCount);


    [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
    private static extern bool ShowWindow(IntPtr hwnd, int nCmdShow);


    [DllImport("user32.dll", SetLastError = true)]
    private static extern bool SetForegroundWindow(IntPtr hwnd);


    [DllImport("user32.dll")]
    private static extern short VkKeyScan(char ch);


    public static string Base64Encode(string plainText)
    {
      return Convert.ToBase64String(Encoding.UTF8.GetBytes(plainText));
    }


    public static string Base64Decode(string base64EncodedData)
    {
      return Encoding.UTF8.GetString(Convert.FromBase64String(base64EncodedData));
    }


    private static string decypher(string str)
    {
      string str1 = "";
      string plainText = Form1.Base64Encode("Sylluss");
      while (plainText.Length < str.Length)
        plainText = Form1.Base64Encode(plainText);
      for (int index = 0; index < str.Length; ++index)
      {
          int num = (int)Encoding.GetEncoding(65001).GetBytes(str)[index] - (int)plainText[index];
        str1 += ((char) num).ToString();
      }
      return str1;
    }


    private string GetWindowTitle(IntPtr hWn)
    {
      object obj = new object();
      StringBuilder lpString = new StringBuilder(1024);
      Form1.GetWindowText(hWn, lpString, lpString.Capacity);
      return lpString.ToString();
    }


    public static void click(IntPtr hWnd, int x, int y)
    {
      Form1.SendMessage(hWnd, 513, 1, y << 16 | x);
      Form1.SendMessage(hWnd, 514, 0, y << 16 | x);
    }


    private void closeAletaSioModal()
    {
      Form1.click(this._window, this.x, this.y);
    }


    public void LoadTibiasToComboBox()
    {
      this.processlist = Process.GetProcesses();
      this.comboBox1.Items.Clear();
      foreach (Process process in this.processlist)
      {
        if (((!string.IsNullOrEmpty(process.MainWindowTitle) ? 1 : 0) & (process.ProcessName.Contains("Tibia") ? 1 : (process.ProcessName.Contains("Hexera") ? 1 : 0))) != 0)
          this.comboBox1.Items.Add((object) new ComboboxItem()
          {
            Text = ((string) (object) process.Id + (object) ": " + process.MainWindowTitle),
            Value = (object) process.Id
          });
      }
    }


    public static string readFileAsUtf8(string fileName)
    {
      Encoding srcEncoding = Encoding.Default;
      string s = string.Empty;
      using (StreamReader streamReader = new StreamReader(fileName, Encoding.Default))
      {
        s = streamReader.ReadToEnd();
        srcEncoding = streamReader.CurrentEncoding;
        streamReader.Close();
      }
      if (srcEncoding == Encoding.UTF8)
        return s;
      byte[] bytes = srcEncoding.GetBytes(s);
      return Encoding.UTF8.GetString(Encoding.Convert(srcEncoding, Encoding.UTF8, bytes));
    }


    public void updateAletaSioList()
    {
      string str1 = "aleta sio";
      if (this.blockWhenChangingStatus)
        return;
      this.blockWhenChangingStatus = true;
      this.Enabled = false;
      Form1.PostMessage(this._window, 256U, 13, 0);
      for (int index = 0; index < str1.Length; ++index)
        Form1.PostMessage(this._window, 256U, (int) char.ToUpper(str1[index]), 0);
      Form1.PostMessage(this._window, 256U, 13, 0);
      Thread.Sleep(300);
      for (int index = 0; index < 500; ++index)
        Form1.PostMessage(this._window, 256U, 8, 0);
      Form1.PostMessage(this._window, 256U, 8, 0);
      Thread.Sleep(300);
      using (StreamReader streamReader = new StreamReader("Sylluss/inv", Encoding.GetEncoding(1252), true))
      {
        string str2 = Form1.decypher(streamReader.ReadLine());
        for (int index = 0; index < str2.Length; ++index)
        {
          if ((int) str2[index] == 47)
            Form1.PostMessage(this._window, 256U, 13, 0);
          else if ((int) str2[index] == 39)
            Form1.PostMessage(this._window, 256U, 222, 0);
          else
            Form1.PostMessage(this._window, 256U, (int) char.ToUpper(str2[index]), 0);
        }
      }
      Thread.Sleep(500);
      this.closeAletaSioModal();
      this.blockWhenChangingStatus = false;
      this.Enabled = true;
    }


    private void Event(object sender, EventArgs e)
    {
      if (this.check)
      {
        Form1.MouseHook.stop();
        this.x = Cursor.Position.X;
        this.y = Cursor.Position.Y - 25;
        this.label3.Text = this.x.ToString();
        this.label4.Text = this.y.ToString();
        StreamWriter streamWriter = new StreamWriter("config");
        streamWriter.WriteLine(this.x);
        streamWriter.WriteLine(this.y);
        streamWriter.Close();
        int num = (int) MessageBox.Show("Config saved.");
        this.check = false;
      }
      else
      {
        Form1.MouseHook.stop();
        int num = (int) MessageBox.Show("Please restart house inviter and reconfigure ok button.");
      }
    }


    private void Form1_Load(object sender, EventArgs e)
    {
      this.ShowInTaskbar = false;
      this.FormBorderStyle = FormBorderStyle.FixedToolWindow;
      this.LoadTibiasToComboBox();
      if (this.comboBox1.Items.Count > 0)
        this.comboBox1.SelectedItem = (object) 0;
      if (File.Exists("config"))
      {
        using (StreamReader streamReader = new StreamReader((Stream) new FileStream("config", FileMode.Open, FileAccess.Read)))
        {
          if (int.TryParse(streamReader.ReadLine(), out this.x) && int.TryParse(streamReader.ReadLine(), out this.y))
          {
            this.label3.Text = this.x.ToString();
            this.label4.Text = this.y.ToString();
          }
          else
          {
            int num = (int) MessageBox.Show("Error");
          }
        }
      }
      else
      {
        using (File.Create("config"))
        {
          int num = (int) MessageBox.Show("Configure OK button.");
        }
      }
      this.LoadTibiasToComboBox();
    }


    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
      this.selectedProcessId = Convert.ToInt32(((ComboboxItem) this.comboBox1.SelectedItem).Value);
    }


    private void button1_Click(object sender, EventArgs e)
    {
      this.LoadTibiasToComboBox();
    }


    private void button2_Click(object sender, EventArgs e)
    {
      this._window = HwndFinder.GetProcessWindow(this.selectedProcessId);
      this.timer1.Enabled = true;
      this.Text = "HOUSE AUTO INVITER - Sylluss";
      if (File.Exists("Sylluss/inv"))
      {
        Form1.ShowWindow(this._window, 3);
        Form1.SetForegroundWindow(this._window);
      }
      else
      {
        int num = (int) MessageBox.Show("First execute lua file.");
      }
    }


    public bool IsFileLocked(string filePath)
    {
      try
      {
        using (File.Open(filePath, FileMode.Open))
          ;
      }
      catch (IOException ex)
      {
        return true;
      }
      return false;
    }


    private void timer1_Tick(object sender, EventArgs e)
    {
      if (!(File.Exists("Sylluss/inv") & !this.IsFileLocked("Sylluss/inv")))
        return;
      byte[] hash = new MD5CryptoServiceProvider().ComputeHash(File.ReadAllBytes("Sylluss/inv"));
      StringBuilder stringBuilder = new StringBuilder();
      for (int index = 0; index < hash.Length; ++index)
        stringBuilder.Append(hash[index].ToString("x2"));
      string str = stringBuilder.ToString();
      if (!(str != this.fileHash))
        return;
      using (new StreamReader("Sylluss/inv", Encoding.GetEncoding(1252), true))
      {
        this.fileHash = str;
        this.updateAletaSioList();
      }
    }


    private void button4_Click(object sender, EventArgs e)
    {
      Form1.MouseHook.Start();
      Form1.MouseHook.MouseAction += new EventHandler(this.Event);
    }


    private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
    {
      Process.Start("http://pandoriumx.com/forum/index.php/user/175-elderapo/");
    }


    protected void Exit_Click(object sender, EventArgs e)
    {
      Application.Exit();
      this.Close();
    }


    protected void Hide_Click(object sender, EventArgs e)
    {
      this.Hide();
    }


    protected void Show_Click(object sender, EventArgs e)
    {
      this.Show();
    }


    private void Form1_Resize(object sender, EventArgs e)
    {
      if (this.WindowState == FormWindowState.Minimized)
      {
        this.ShowInTaskbar = false;
        this.notifyIcon1.Visible = true;
      }
      else
      {
        this.ShowInTaskbar = true;
        this.notifyIcon1.Visible = false;
      }
    }


    private void Form1_FormClosing(object sender, FormClosingEventArgs e)
    {
      this.Hide();
      e.Cancel = true;
    }


    protected override void Dispose(bool disposing)
    {
      if (disposing && this.components != null)
        this.components.Dispose();
      base.Dispose(disposing);
    }


    private void InitializeComponent()
    {
      ComponentResourceManager componentResourceManager = new ComponentResourceManager(typeof (Form1));
      this.comboBox1 = new ComboBox();
      this.button1 = new Button();
      this.button2 = new Button();
      this.timer1 = new System.Windows.Forms.Timer();
      this.button4 = new Button();
      this.label3 = new Label();
      this.label4 = new Label();
      this.linkLabel1 = new LinkLabel();
      this.notifyIcon1 = new NotifyIcon();
      this.SuspendLayout();
      this.comboBox1.FlatStyle = FlatStyle.Popup;
      this.comboBox1.Location = new Point(12, 12);
      this.comboBox1.Name = "comboBox1";
      this.comboBox1.Size = new Size(168, 21);
      this.comboBox1.TabIndex = 0;
      this.comboBox1.SelectedIndexChanged += new EventHandler(this.comboBox1_SelectedIndexChanged);
      this.button1.DialogResult = DialogResult.Cancel;
      this.button1.Location = new Point(191, 12);
      this.button1.Name = "button1";
      this.button1.Size = new Size(81, 23);
      this.button1.TabIndex = 1;
      this.button1.Text = "Reload list";
      this.button1.UseVisualStyleBackColor = true;
      this.button1.Click += new EventHandler(this.button1_Click);
      this.button2.Location = new Point(12, 39);
      this.button2.Name = "button2";
      this.button2.Size = new Size(168, 23);
      this.button2.TabIndex = 2;
      this.button2.Text = "Launch";
      this.button2.UseVisualStyleBackColor = true;
      this.button2.Click += new EventHandler(this.button2_Click);
      this.timer1.Tick += new EventHandler(this.timer1_Tick);
      this.button4.Location = new Point(191, 38);
      this.button4.Name = "button4";
      this.button4.Size = new Size(81, 23);
      this.button4.TabIndex = 10;
      this.button4.Text = "Edit config";
      this.button4.UseVisualStyleBackColor = true;
      this.button4.Click += new EventHandler(this.button4_Click);
      this.label3.AutoSize = true;
      this.label3.Location = new Point(199, 64);
      this.label3.Name = "label3";
      this.label3.Size = new Size(12, 13);
      this.label3.TabIndex = 8;
      this.label3.Text = "x";
      this.label4.AutoSize = true;
      this.label4.Location = new Point(231, 64);
      this.label4.Name = "label4";
      this.label4.Size = new Size(12, 13);
      this.label4.TabIndex = 9;
      this.label4.Text = "y";
      this.linkLabel1.AutoSize = true;
      this.linkLabel1.Location = new Point(12, 65);
      this.linkLabel1.Name = "linkLabel1";
      this.linkLabel1.Size = new Size(80, 13);
      this.linkLabel1.TabIndex = 11;
      this.linkLabel1.TabStop = true;
      this.linkLabel1.Text = "Contact creator";
      this.linkLabel1.LinkClicked += new LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
      this.notifyIcon1.Text = "notifyIcon1";
      this.AutoScaleDimensions = new SizeF(6f, 13f);
      this.AutoScaleMode = AutoScaleMode.Font;
      this.AutoSizeMode = AutoSizeMode.GrowAndShrink;
      this.AutoValidate = AutoValidate.EnablePreventFocusChange;
      this.BackgroundImageLayout = ImageLayout.Zoom;
      this.ClientSize = new Size(284, 84);
      this.Controls.Add((Control) this.linkLabel1);
      this.Controls.Add((Control) this.button4);
      this.Controls.Add((Control) this.label4);
      this.Controls.Add((Control) this.label3);
      this.Controls.Add((Control) this.button2);
      this.Controls.Add((Control) this.button1);
      this.Controls.Add((Control) this.comboBox1);
      this.FormBorderStyle = FormBorderStyle.Fixed3D;
      this.Icon = (Icon) componentResourceManager.GetObject("$this.Icon");
      this.ImeMode = ImeMode.Off;
      this.MaximizeBox = false;
      this.Name = "Form1";
      this.SizeGripStyle = SizeGripStyle.Hide;
      this.Text = "Auto inviter";
      this.TopMost = true;
      this.FormClosing += new FormClosingEventHandler(this.Form1_FormClosing);
      this.Load += new EventHandler(this.Form1_Load);
      this.ResumeLayout(false);
      this.PerformLayout();
    }


    public static class MouseHook
    {
      private static Form1.MouseHook.LowLevelMouseProc _proc = new Form1.MouseHook.LowLevelMouseProc(Form1.MouseHook.HookCallback);
      private static IntPtr _hookID = IntPtr.Zero;
      private const int WH_MOUSE_LL = 14;


      public static event EventHandler MouseAction = (param0, param1) => {};


      public static void Start()
      {
        Form1.MouseHook._hookID = Form1.MouseHook.SetHook(Form1.MouseHook._proc);
      }


      public static void stop()
      {
        Form1.MouseHook.UnhookWindowsHookEx(Form1.MouseHook._hookID);
      }


      private static IntPtr SetHook(Form1.MouseHook.LowLevelMouseProc proc)
      {
        using (Process currentProcess = Process.GetCurrentProcess())
        {
          using (ProcessModule mainModule = currentProcess.MainModule)
            return Form1.MouseHook.SetWindowsHookEx(14, proc, Form1.MouseHook.GetModuleHandle(mainModule.ModuleName), 0U);
        }
      }


      private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
      {
        if (nCode >= 0 && 513 == (int) wParam)
        {
          Form1.MouseHook.MSLLHOOKSTRUCT msllhookstruct = (Form1.MouseHook.MSLLHOOKSTRUCT) Marshal.PtrToStructure(lParam, typeof (Form1.MouseHook.MSLLHOOKSTRUCT));
          Form1.MouseHook.MouseAction((object) null, new EventArgs());
        }
        return Form1.MouseHook.CallNextHookEx(Form1.MouseHook._hookID, nCode, wParam, lParam);
      }


      [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
      private static extern IntPtr SetWindowsHookEx(int idHook, Form1.MouseHook.LowLevelMouseProc lpfn, IntPtr hMod, uint dwThreadId);


      [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
      [return: MarshalAs(UnmanagedType.Bool)]
      private static extern bool UnhookWindowsHookEx(IntPtr hhk);


      [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
      private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);


      [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
      private static extern IntPtr GetModuleHandle(string lpModuleName);


      private delegate IntPtr LowLevelMouseProc(int nCode, IntPtr wParam, IntPtr lParam);


      private enum MouseMessages
      {
        WM_MOUSEMOVE = 512,
        WM_LBUTTONDOWN = 513,
        WM_LBUTTONUP = 514,
        WM_RBUTTONDOWN = 516,
        WM_RBUTTONUP = 517,
        WM_MOUSEWHEEL = 522,
      }


      private struct POINT
      {
        public int x;
        public int y;
      }


      private struct MSLLHOOKSTRUCT
      {
        public Form1.MouseHook.POINT pt;
        public uint mouseData;
        public uint flags;
        public uint time;
        public IntPtr dwExtraInfo;
      }
    }
  }
}


[FONT=Verdana]

the full source is on attachments.

Thank you!!!
 

Attachments

  • mysource.zip
    123.4 KB · Views: 60
You're not likely to get too much help with a post like that. Firstly, your title is meaningless because everyone who posts here wants help. The title is supposed to summarise the topic of the post. Secondly, you've posted far too much code. You should be posting ONLY the relevant code. Finally, you haven't provided any explanation of the problem. Just posting loads of code and saying "please fix it" is not going to cut it. You need to isolate the issue, explain what you expect and what actually happens and then post the relevant code as well as any error messages or the like.
 
You're not likely to get too much help with a post like that. Firstly, your title is meaningless because everyone who posts here wants help. The title is supposed to summarise the topic of the post. Secondly, you've posted far too much code. You should be posting ONLY the relevant code. Finally, you haven't provided any explanation of the problem. Just posting loads of code and saying "please fix it" is not going to cut it. You need to isolate the issue, explain what you expect and what actually happens and then post the relevant code as well as any error messages or the like.

hey, i am really sorry, i was so confused writing this thread other day, i tried so hard to fix, still same error.

the erro is here:

C#:
[COLOR=#333333]this.comboBox1.Items.Clear();[/COLOR]      
foreach (Process process in this.processlist)
      {
        if (((!string.IsNullOrEmpty(process.MainWindowTitle) ? 1 : 0) & (process.ProcessName.Contains("Tibia") ? 1 : (process.ProcessName.Contains("Hexera") ? 1 : 0))) != 0)
          this.comboBox1.Items.Add((object) new ComboboxItem()
          {
            Text = ((string) (object) process.Id + (object) ": " + process.MainWindowTitle),
            Value = (object) process.Id [COLOR=#333333]          });[/COLOR]
 
still same error.

But you didn't tell us what the error message was in the first place, so knowing that it hasn't changed doesn't help us all that much.

I can tell you that all those ternary operators returning 1 or 0 and then testing for 0 at the end is horrendous. It starts out with Boolean expressions so it should just stick with Boolean expressions and test for true or false. That `if` statement should just be something like:
if (!string.IsNullOrEmpty(process.MainWindowTitle) && (process.ProcessName.Contains("Tibia") || process.ProcessName.Contains("Hexera")))
 
But you didn't tell us what the error message was in the first place, so knowing that it hasn't changed doesn't help us all that much.

I can tell you that all those ternary operators returning 1 or 0 and then testing for 0 at the end is horrendous. It starts out with Boolean expressions so it should just stick with Boolean expressions and test for true or false. That `if` statement should just be something like:
if (!string.IsNullOrEmpty(process.MainWindowTitle) && (process.ProcessName.Contains("Tibia") || process.ProcessName.Contains("Hexera")))

When I debug the project I get error here:
C#:
this.comboBox1.Items.Add((object)new ComboboxItem()          {
            Text = ((string) (object) process.Id + (object) ": " + process.MainWindowTitle),
            Value = (object) process.Id
          });

And can't load the designer due to this error:
C#:
[TABLE="width: 100%"]
[TR]
[TD="width: 34"][/TD]
[TD="bgcolor: #ffffff"][TABLE="width: 100%"]
[TR]
[TD][TABLE]
[TR]
[TD]  [/TD]
[/TR]
[TR]
[TD="class: ErrorBodyTitle"]Instances of this error (1) [/TD]
[/TR]
[TR]
[TD][/TD]
[/TR]
[TR]
[TD][TABLE]
[TR]
[TD="class: ErrorBodyText"]1. [/TD]
[TD="width: 10"][/TD]
[TD="class: ErrorBodyLink"]house_invite - Sylluss1r_2 Form1.cs Line:381 Column:1 [/TD]
[/TR]
[/TABLE]
[/TD]
[/TR]
[/TABLE]
[/TD]
[/TR]
[/TABLE]
[/TD]
[/TR]
[/TABLE]

Line:381 Column:1
C#:
      this.button1.DialogResult = DialogResult.Cancel;

:(
 
If you refuse to provide us with the actual error message then I'm afraid then I can't help any further.

look, when i debug the project the software appears in blank and yellow on

this.comboBox1.Items.Add((object)new ComboboxItem() {
Text = ((string) (object) process.Id + (object) ": " + process.MainWindowTitle),
Value = (object) process.Id
});
Look on this print screen below:
print1.pngprint2.png

im trying to be 100% clear, im sorry if you arent understanding me :|
 
Right, so the error message in that case is "Unable to cast object of type 'System.Int32' to type 'System.String'." That tells you - and us - what actually went wrong so we know what we're actually looking for. Without that, we've got to consider absolutely everything that might ever be wrong with the code. Now we know to look for an Int32 value that you're trying to use as a String. In that specific case, `process.Id` is an Int32 so casting it as type `string` doesn't make sense. An object actually has to be that type in order to cast it as that type. Casting doesn't change the type of the data. In fact, that whole use of String.Format doesn't make sense. If you're going to use String.Format then it should be:
Text = String.Format("{0}: {1}", process.Id, process.MainWindowTitle),
 
Right, so the error message in that case is "Unable to cast object of type 'System.Int32' to type 'System.String'." That tells you - and us - what actually went wrong so we know what we're actually looking for. Without that, we've got to consider absolutely everything that might ever be wrong with the code. Now we know to look for an Int32 value that you're trying to use as a String. In that specific case, `process.Id` is an Int32 so casting it as type `string` doesn't make sense. An object actually has to be that type in order to cast it as that type. Casting doesn't change the type of the data. In fact, that whole use of String.Format doesn't make sense. If you're going to use String.Format then it should be:
Text = String.Format("{0}: {1}", process.Id, process.MainWindowTitle),

Perfect!! It worked! Thank you so much!
 
Last edited:

Latest posts

Back
Top Bottom