|
-
Oct 23rd, 2008, 04:50 PM
#1
Thread Starter
Addicted Member
[RESOLVED] [2008] Error boxes killing me
First off, this is not something I coded but rather a product I had created for me. In any case I have no source to edit just a buggy program that I'd like to destroy now. When I run the application it runs fine for a bit and then starts throwing error messages then if you click on no I don't want to debug it will continue as normal and then throw more boxes until it is finished.
What I want to create is a little program that will watch for those boxes and automatically click the no box for me behind the scenes so I can continue working on things.
What can I use to watch for those boxes and then kill them?
Chris
-
Oct 23rd, 2008, 05:08 PM
#2
Re: [2008] Error boxes killing me
Are you familiar with Spy++? I would suggest using that to see if you can reliably identify the boxes and the buttons on the box. If so, then you can use API calls to check for the existence of them. You'd probably want to do the check in a fairly fast timer, but the check shouldn't be very slow, so you could probably set the timer interval to 200 and be fine. That would mean that the worst wait would be one fifth of a second, which isn't much.
My usual boring signature: Nothing
 
-
Oct 23rd, 2008, 05:17 PM
#3
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
I've heard of it but never used it before. I know the titles of the boxes and figured there was a listener class that I could code to listen for the boxes to be called and kill them that way but I've been searching for sample code to use and been unsuccessful so far.
Do you know what api to use for that? is it WinAPI MessageBox?
Chris
-
Oct 23rd, 2008, 05:21 PM
#4
Re: [2008] Error boxes killing me
Decompile it and you'll have a 1:1 source.
-
Oct 23rd, 2008, 05:23 PM
#5
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
Decompile it? Oh boy...wouldn't it be easier to code a simple listener to kill the boxes?
-
Oct 23rd, 2008, 07:11 PM
#6
Re: [2008] Error boxes killing me
What's it written in? If it was written in .NET, then decompiling might be a reasonable way to go.
Spy++ comes with Visual Studio, so you probably have it. It's a neat little tool to play around with, even if you don't end up using it. There are probably many more pieces than I have used, but the two critical ones that I can see for you are the crosshairs tool, and the form that shows all windows on the screen. You might be surprised at the number of windows displayed unless you realize that EVERYTHING is a window. Every button, icon, taskbar, etc. You would want to bring that up when the box in question is on the screen, then try to find it in the list of windows. Next you'd press the button and wait for the next box and find it in the list, and so on. What you'd be looking for is some common identifying characteristic. They might all be the same windows class, or they might all be children of some other form, or they might all have readily identifiable captions (you wouldn't really need Spy++ to see that).
The crosshairs tool can be used by moving it around on the screen. When you move it over any window (and everythings a window) it shows you various information about the window, such as class, and so forth.
This is the first step that I would take, and it may not work. It is possible that you simply won't notice any pattern to the boxes that you can latch onto. For the API calls I am thinking of, you'd need to be able to get the handle for the window that you want to send the message to, and you can get the handle via the caption, or via the windows class, but some windows have no captions, and the windows class for a messagebox is certainly not going to be unique. Therefore, if there is no caption, then you need to be able to say, "I want the second instance of windows class C located below window W." If you can find a pattern like that, the rest is not so difficult.
Perhaps others will have an easier way, though, since this is a messagebox.
My usual boring signature: Nothing
 
-
Oct 23rd, 2008, 07:19 PM
#7
Re: [2008] Error boxes killing me
writing a program to click msgboxes that way is a hack.
i'd decompile the original program + rewrite it
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 23rd, 2008, 07:19 PM
#8
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
Thanks Shaggy Hiker. It is a .net app. Where can I find Spy++?
Chris
-
Oct 23rd, 2008, 07:24 PM
#9
Re: [2008] Error boxes killing me
Spy++ is included with the pro edition of vs2005, so i'd assume also vs2008 pro. doesn't appear to come with vb2008 express though.
if you have got it it'll be in your Visual Studio Tools menu
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Oct 23rd, 2008, 07:26 PM
#10
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
Damn...it's not. Ok...I am pretty frustrated with it, I would decompile it if I knew how to, I found Red Gate's .net reflector but I don't know if that is possible to use. There is a lot of functions in here.
-
Oct 23rd, 2008, 07:50 PM
#11
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
I've got it fully decompiled now but it has a lot of errors now in the code that I don't think I can fix. I used .net reflector and one of their add ins to decompile it back to vb.net but it's not all good code. what can I do?
Here is example decompiled code with error:
vb Code:
Private Sub button_sort_Click(ByVal sender As Object, ByVal e As EventArgs) Dim control As Control For Each control In Me.tabControl1.SelectedTab.Controls control.Enabled = False Next Dim list As New List(Of Uri) Dim str As String For Each str In Me.textBox_result.Text.Split(Me.newline, 0) Try Dim uri As New Uri(str.Trim) list.Add(uri) Catch obj1 As Object End Try Next If (Form1.CS$<>9__CachedAnonymousMethodDelegate4 Is Nothing) Then Form1.CS$<>9__CachedAnonymousMethodDelegate4 = New Comparison(Of Uri)(Nothing, Form1.<button_sort_Click>b__3) End If list.Sort(Form1.CS$<>9__CachedAnonymousMethodDelegate4) Me.textBox_result.Text = "" Dim uri As Uri For Each uri In list Me.textBox_result.AppendText((uri.ToString & ChrW(13) & ChrW(10))) Next Dim control As Control For Each control In Me.tabControl1.SelectedTab.Controls control.Enabled = True Next End Sub
Here is the error:
vb Code:
If (Form1.CS$<>9__CachedAnonymousMethodDelegate4 Is Nothing) Then Form1.CS$<>9__CachedAnonymousMethodDelegate4 = New Comparison(Of Uri)(Nothing, Form1.<button_sort_Click>b__3) End If list.Sort(Form1.CS$<>9__CachedAnonymousMethodDelegate4)
ideas?
Last edited by cmmorris1; Oct 23rd, 2008 at 07:54 PM.
-
Oct 23rd, 2008, 07:56 PM
#12
Re: [2008] Error boxes killing me
Well then back to Shaggy's idea. If you don't have Spy++, use WinID. It is perfect for investigating different types of windows.
-
Oct 23rd, 2008, 08:13 PM
#13
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
I found spy++ for vs 2008 finally although not in the tools menu. Did some looking with the crosshairs and there is a message box with Error in the title of the form that has two buttons to click. I just need to know what code to use to look for error message box and click no.
-
Oct 23rd, 2008, 09:50 PM
#14
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
I fixed a lot of the code errors in the project but when I run the application it starts up fine and I enter my license code for the program and then it breaks and shows me this in the debugger:
Nevermind...I fixed that...crosses fingers.
Last edited by cmmorris1; Oct 23rd, 2008 at 09:53 PM.
-
Oct 23rd, 2008, 10:19 PM
#15
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
Still too many errors here...does anyone know how to create a simple program to watch for error boxes and click no?
chris
-
Oct 24th, 2008, 09:54 AM
#16
Re: [2008] Error boxes killing me
Here is one way to click the 'No' button in Notepad when it asks you on close if you want to save the changes.
Start notepad, type something and try to close it. A dialog will pop and ask you "Do you want to save the changes?" Leave it open and run the code bellow. In your case, you must change the strings in the FindWindow and FindWindowEx accordingly (see what Spy++ is telling you).
Code:
'api constant declarations
Const BM_CLICK As Integer = &HF5
'sendmessage overload that is used to send messages to the button
Private Declare Auto Function SendMessage Lib "user32.dll" Alias "SendMessage" _
(ByVal hWnd As IntPtr, ByVal Msg As Integer, _
ByVal wParam As Integer, ByVal lParam As IntPtr) As IntPtr
'API to find the dialog window
Private Declare Auto Function FindWindow Lib "user32" _
(ByVal ClassName As String, ByVal WindowTitle As String) As IntPtr
'API to find some sub window inside the dialog window
Private Declare Auto Function FindWindowEx Lib "user32" _
(ByVal parentHandle As IntPtr, ByVal childAfter As IntPtr, _
ByVal ClassName As String, ByVal WindowTitle As String) As IntPtr
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim ParentWindowHWND As IntPtr
Dim ChildWindowHWND As IntPtr
'as seen with Spy++, the class name of the Dialog is #32770, the text is "Notepad"
'search for the handle of the dialog
ParentWindowHWND = FindWindow("#32770", "Notepad")
'now you'll have to find the "No" buton. Spy++ will show you that the class name of the button
'is "Button" and the text is "No". The latter is false, it actually has
'an accelerator (underscore below N). WinID is not making the same mistake.
'Anywayz, add '&' appropriately.
If ParentWindowHWND <> IntPtr.Zero Then
ChildWindowHWND = FindWindowEx(ParentWindowHWND, IntPtr.Zero, "Button", "&No")
Else
MessageBox.Show("Program is not running.", "Error")
End If
'we have the handle of the No button, so let's click it
SendMessage(ChildWindowHWND, BM_CLICK, 0, IntPtr.Zero)
End Sub
-
Oct 24th, 2008, 10:26 AM
#17
Re: [2008] Error boxes killing me
was the program actually written 2008? If it was written in 2005 that may be the source of some of the errors. And are you getting actual errors or are they "warning"s? Would love to see a screenshot or something of the error list.
-
Oct 24th, 2008, 01:01 PM
#18
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
It was written in 2005 and I converted to 2008 Lord Orwell.
There is about 100 Actual errors in the code that make no
sense to me.
One of those is in this line here:
If (Form1.CS$<>9__CachedAnonymousMethodDelegate4 Is Nothing) Then
I have no idea what that even means?
Chris
-
Oct 24th, 2008, 01:11 PM
#19
Re: [2008] Error boxes killing me
a little late to the party...
if it is something you had created, and it isn't working, why use it?
-
Oct 24th, 2008, 01:13 PM
#20
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
Well it was created for me, it works as far as what it does but I can't fix the error boxes that keep popping up on me. I've got the source to it now but I spent 3 hours last night trying to fix it myself and it's killing me 
If I could fix it then I'd be happy, if not then a fix like creating a listener to kill the error boxes wouldn't be so bad.
-
Oct 24th, 2008, 01:39 PM
#21
Re: [2008] Error boxes killing me
I would say that fixing the errors is superior to the button clicker, but the source you have comes from decompiling, right? That would mean that some of the names could be looking a bit odd, such as the one you posted.
The line in question is looking to see whether something is nothing. You know it is associated with Form1, but it is not Form1 itself. It doesn't really look like a member variable, so I would take a look at the properties of form1, and look at the code around it to see whether there is a property that would make sense in that context.
For the button clicker, Hack's code would be the place to start, especially with all the comments.
My usual boring signature: Nothing
 
-
Oct 24th, 2008, 05:18 PM
#22
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
I did spend a lot of time last night attempting to do just that, I also thought about hiring someone to do the same software again but only if I had to go that route. I'm fairly new to this so coding the entire thing isn't an option but I'm definitely learning a lot as I go so this is good in that respect. I will keep plugging away at that and see if I can't repair it myself.
-
Oct 24th, 2008, 05:48 PM
#23
Re: [2008] Error boxes killing me
if you don't mind me asking, what does this code do?
-
Oct 24th, 2008, 05:49 PM
#24
Thread Starter
Addicted Member
Re: [2008] Error boxes killing me
No..not at all, this is a little web scraper utility that I use for my niche businesses.
-
Oct 24th, 2008, 09:24 PM
#25
Re: [2008] Error boxes killing me
is ... that ... ALL?!? exactly how many lines approximately are you dealing with? There are a bunch of sample scraper codes on this forum already. Perhaps someone could help you rewrite something from scratch without errors in it. Actually, uploading the code would help as well.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|