What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » Visual Basic Code Help

Pages: (2): « First « 1 [ 2 ] Last »
Visual Basic Code Help
Author: Message:
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: RE: Visual Basic Code Help
quote:
Originally posted by DJeX
I tryed your module but it didn't work.
I tryed the code you posted and that aswell did not work.
They both  work perfect if you follow the instructions though.

eg: for the module, did you tried it out with an unpatched english MSN Messenger version 6.x while the main window was not minimized to the system tray, as stated in the first comment in that module and in my post? It will not work on Messenger 7 or whatever as the controls there are build up in another way (without windows)...

quote:
Originally posted by DJeX
This is what I did:

I made a test program called Notepad with a button called Test on it. I replaced the correct words in the code above (PROJECT and VIEW CODE) with NOTEPAD and TEST. Then I ran my test program then run the code above but still didn't work.
First of all, everything is made specifically for a certain situation; The code in the form doesn't work for everything.

Nevertheless, this time the blame was on my part. Though, you could've found where it went wrong if you'd understand what the code does (instead of simply copy/pasting).

Both lines with
GetWindowText CurHwnd, T, Length
must be
GetWindowText CurHwnd, T, Length + 1
and you should have replaced the obsolete GetWindowWord() API with GetWindowLong(), as stated in the comments...

I've done both edits in the source for you now... Sorry about the misleading.

quote:
Originally posted by DJeX
I just need a simple code that will find a button on another program that is running and press it. Like for example how that Hit Man Pro anti-spyware program works, it controls the other programs that it downloads.
The code shown is exactly what you want. Nobody can give you anything more specific if you aren't specific.

If you understand how the method works, you'll see that you can not make something general, working for everything in every situation as each situation is totally different. Even the code in Hitman Pro is specifically made for specific programs.

The big key here is to understand every line of code and understand what every API call exactly does. The MSDN Library can help you in that (http://www.msdn.com/).

-

To further help you and as asked in my previous post, be specific of what you want (and I mean really specific with all the small details and stuff)...

This post was edited on 11-27-2005 at 10:06 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
11-27-2005 08:29 PM
Profile PM Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Visual Basic Code Help
quote:
Originally posted by CookieRevised
Nevertheless, this time the blame was on my part. Though, you could've found where it went wrong if you'd understand what the code does (instead of simply copy/pasting).

Both lines with
GetWindowText CurHwnd, T, Length
must be
GetWindowText CurHwnd, T, Length + 1
and you should have replaced the obsolete GetWindowWord() API with GetWindowLong(), as stated in the comments...

I've done both edits in the source for you now...

It worked this time. Thank you :D

What I'm trying to do is make a program that will automaticly update my computer when clicked. So like it will update norton antivirus and anti-spyware programs by its self. I makeing it for my Grand father since hes not the best on computers and often gets confused.

EDIT: I tryed that code with Norton System Works and MS Anti-Spyware and it finds the Window but cant find the button in the window to click.


This post was edited on 11-27-2005 at 09:54 PM by DJeX.
[Image: top.gif]
11-27-2005 09:44 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Visual Basic Code Help
First of all, Norton has his own auto-update features, check out the help files and manuals.

Second, even if you are able to press on a button, there are extremely many things which can go wrong and extremely many things which needs to be done first or after pressing the button.

I don't recommend making this for your grandfather (as good as the intention might be) as it will most likely produce more problems (not to mention crashes or whatever) which he can't solve at all. Instead teach him how to update such stuff for himself (or write it down or something)...


---------

For the problem itself, again I emphesize on understanding the code and understanding the methods used to find the button.

The button can be a child of another control which on his turn can be a child of another control which on his turn (...) etc (...), which on his turn is a child of the main window. You need to enumerate the complete tree. The Form code only looks at buttons directly placed on the main window. The Module code looks at buttons in all child windows and childs of those child windows.

Note that the term "window" is not the thing you think of as a window. A control like a button is also a window... Anything that has a window handle is called a window.

Note that not all programs work in the same way and not all programs have window controls which you could subclass or control (eg: MSN Messenger 7.x is a good example of this).

This post was edited on 11-27-2005 at 11:04 PM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
11-27-2005 11:01 PM
Profile PM Find Quote Report
DJeX
Veteran Member
*****

Avatar


Posts: 1138
Reputation: 11
– / Male / –
Joined: Jul 2003
O.P. RE: Visual Basic Code Help
Ahh ok, I see what your saying. But because I want to learn this I still want to get it to work. Just for my own knoledge. Now your saying I should use EnumWindows() and EnumChildWindows() funtions right? Would they work the same as the GetWindow() and GetDesktopWindow()? Like for example:

CurHwnd = GetWindow(CurHwnd, GW_CHILD) < -- Original code.

CurHwnd = EnumWindows (CurHwnd, GW_CHILD) <-- Would that work?
[Image: top.gif]
11-27-2005 11:50 PM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15519
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Visual Basic Code Help
quote:
Originally posted by DJeX
Ahh ok, I see what your saying. But because I want to learn this I still want to get it to work. Just for my own knoledge. Now your saying I should use EnumWindows() and EnumChildWindows() funtions right? Would they work the same as the GetWindow() and GetDesktopWindow()? Like for example:

CurHwnd = GetWindow(CurHwnd, GW_CHILD) < -- Original code.

CurHwnd = EnumWindows (CurHwnd, GW_CHILD) <-- Would that work?
nope... they are completely different. See the code in the Module for an example of EnumChildWindows()...

The enumuration functions use something which is called a "callback function" to work. The functions are called only once, and they in turn will call the function you provided as a parameter (hence the "callback") for each window they find.

For the complete detailed info about these API's (and any other API for that matter) see the msdn library and search for those API functions.

EnumWindows()
EnumChildWindows()

You should also never use the GetWindow() API for the purpose of enumerating/scrolling thru all the windows (hence the Form code isn't that good). Reasons for this can be read in the msdn library again.

This post was edited on 11-28-2005 at 12:27 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
11-28-2005 12:11 AM
Profile PM Find Quote Report
Pages: (2): « First « 1 [ 2 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On