Hey another thing which i need help with.
My current tool gets this when it fails to read the process and read from the process.
so instead of the window, how can i print the messages to a text box?
Hey another thing which i need help with.
My current tool gets this when it fails to read the process and read from the process.
so instead of the window, how can i print the messages to a text box?
" Spy sappin mah sentry! "
Read about try and catch though didnt find that page, thanks
" Spy sappin mah sentry! "
Glad to help out![]()
Well wall o crap inc
How would you guys make that code execute only if there was a process, and if there wasnt it would write to my error log?Code:using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using Magic; namespace SnigelStatus { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void timer1_Tick(object sender, EventArgs e) { BlackMagic WoW = new BlackMagic(); WoW.OpenProcessAndThread(SProcess.GetProcessFromProcessName("WoW.exe")); string PlayerName = WoW.ReadASCIIString(0x00C923F8, 12); uint PlayerBase = WoW.ReadUInt(WoW.ReadUInt(WoW.ReadUInt(0x00CF7C00) + 0x34) + 0x24); uint CurHealth = WoW.ReadUInt(WoW.ReadUInt(PlayerBase + 0x8) + (0x17 * 4)); uint MaxHealth = WoW.ReadUInt(WoW.ReadUInt(PlayerBase + 0x8) + (0x1F * 4)); int HPPer = (int)(((double)CurHealth / (double)MaxHealth) * 100); progressBar1.Value = HPPer; } } }
Last edited by snigelmannen; 12-15-2009 at 05:01 PM.
" Spy sappin mah sentry! "
Code:try { WoW.OpenProcessAndThread(SProcess.GetProcessFromProcessName("WoW.exe")); string PlayerName = WoW.ReadASCIIString(0x00C923F8, 12); uint PlayerBase = WoW.ReadUInt(WoW.ReadUInt(WoW.ReadUInt(0x00CF7C00) + 0x34) + 0x24); uint CurHealth = WoW.ReadUInt(WoW.ReadUInt(PlayerBase + 0x8) + (0x17 * 4)); uint MaxHealth = WoW.ReadUInt(WoW.ReadUInt(PlayerBase + 0x8) + (0x1F * 4)); } catch (Exception e) { Console.WriteLine("{0} Exception caught.", e); }
Thanks for the help will try it.
" Spy sappin mah sentry! "
Hmm another question, ehm console writeline can that be change to the errorlog i have? like Error.Writeline?
" Spy sappin mah sentry! "
Yep, you can do whatever you like with the error. That's just one option. The variable e is the exception.
Well i am getting an error when writing to that box but that's because its a richtextbox or w/e its called, cant use writeline with it, its something else that i gotta use.
been looking it up but it still doesn't give any good answers.
and thanks for the help with try - catch it doesn't crash anymore and just stays open when it doesn't find the process, though i had to move the whole code within the try catch. else it would fail, as stated not a coder i don't know how this all works.
" Spy sappin mah sentry! "
richTextBox.AppendText() is the method you're after.
Try-Catch works by trying to execute the code in the Try block, then catching any error that happened whilst doing so.
Well its working quite as i wanted now, just gotta learn how to truncate it some.
Now i tried to add a error sound, it went well as it plays the sound sadly it spams it got a better solution then the below?
Code:catch (Exception SProcess) { ErrorText.Text = "Error" + SProcess; SoundPlayer simpleSound = new SoundPlayer("http://snigelmannen.dnsdojo.org/SnigelStatus/moo3.wav"); simpleSound.Play(Stop); }
" Spy sappin mah sentry! "
What do you mean by "spams"? I'd use a soundplayer myself if I wanted to play a sound, it shouldn't repeat unless you tell it to.
Well if you can be bothered ill just put the link to the version with the error sound.
Index of /SnigelStatus/Beta
" Spy sappin mah sentry! "