I find I need an old vb program on win7 but got out of doing stuff like this. Despite the fact that some ways of doing things was dropped in modern windows I am guessing there is a replacement. I know send keys was considered un reliable but the problem was finding what window was the focus. Chances are the window is called something else. A good example is the program I need this for when the window is open there is no title to be seen. all my research says that vb6 is an unreliable or troublesome install on win 7. I have the source for an old vb program and have been advised to find a net replacement. And was wondering how others handled the same problems. For instance the converter by microsoft. Does it work. And how much should I expect to be converted and how much should I expect to hand code.
here is what I am talking about.
thank you for your answer.if I don't know the .net I am probally going to get into trouble. Yes that looks like what I am trying to work with. Though the coding there looks a lot better then what I came up with. Let me explain the problems I am having and maybe as coders you can tell me how I should handle it. I have a program I need to find the active window on. one of the problems I think is the program takes over my comp. and by that I mean I can not easly run any other program while this program is running. but a lot of my input is repetitive meaning I have to hit the same set of keys over and over.
sometimes for as long as an hour. I have found some stuff will run as long as it is in the background.My idea was a simple script to find the active window and handle then senkeys to send the keystrokes to it. But heres my glitch. I can not get the script to stay open long enough to read the info and everyone tells me I should never use sendkeys for this. the only advise I get is find another way besides send keys.but no search or no one has sugested another way. I tried stuff like autoit but failed on all attempts. Is there a better way? or maybe a progam I could use?
I think if you simply want to find the active window, then you should should run the script as a function (within a common module) rather than in a timer (in a form) or at the very least disable the timer once you have found the active window.
The sample code you provided lives in the TIMER's event routine within the FORM.
This would also mean if you have several forms then they are all running concurrently.
And this is why your system is becoming unresponsive?
For what you want to do, I dont think the sendkeys is the problem, its probably the timer which runs every so often... (100 milliseconds i think you had it at).
If everyone tells you you shouldn't use sendkeys to do what you want, then more than likely they are right! After all so many people cannot be wrong?
Maybe you could use API functions to attain the results you want?
Im not sure but it cannot be too difficult for you to find the answer in the documentation on MSDN.
I have seen several posts on this websites forum which deal with finding the active window.
Maybe surfing through those threads/posts would give you a better resolution to your issue.
The VB6 code migration wizard no longer exists in Visual Studio 2010 and above. If you've got VB6 code to convert, you'll either need to use Visual Studio 2008 to do a conversion, the quality of which depends entirely on your VB6 code. The more PInvoke stuff you have in it, they worse the conversion will be.
Keep in mind that the conversion utility will not rewrite your code to what you can do by hand today under .NET. It will convert the project so that it has a decent chance of at least compiling. VB6 did so many things poorly that it's sometimes just impossible for it to figure out what you were doing and rewrite appropriately.