Click to See Complete Forum and Search --> : A couple of things I need help with....


porsche
February 5th, 2000, 03:39 PM
Hi everyone, can somebody please help me with these things? I really need them to complete my program I have been working on!!!!!

1) Changing the title caption of any application that is open.
2) If I have a listbox with a list of URL's in. Is there a way that when I press a button in my program. IE5 or what ever browser opens and cycles through each URL in the list with a 2 min delay between each one...
3) Is there a way to get a list of the running programs and have one of them become the selected window when I press a button or what ever.....or the window on top.
4) Lastly, I have a program that I want to run all night long, but a message box keeps poping up every so often with a message and the option "OK"
It stops my program from running properly is there a way that I can create a small program that will run in the background which will automatically close this message box each time?????

Any help to any of these points, all if possible :) and I would be very grateful.

thanks MARTIN (porsche@angelfire.com)

Chris Eastwood
February 6th, 2000, 04:18 PM
>1) Changing the title caption of any application that is open.

This is possible, but you have to remember that most programs change the title of their main window at some point in their processing. For example, try this out on when NotePad is running :


'
' Place this in a form
'

private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" _
(byval hwnd as Long, byval lpString as string) as Long
private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
(byval hWnd1 as Long, byval hWnd2 as Long, byval lpsz1 as string, byval _
lpsz2 as string) as Long
'
' then in a click event on a button
'
private Sub Command1_Click()
Dim lHwnd as Long
'
lHwnd = FindWindowEx(0, 0, "Notepad", vbNullString)
'
If lHwnd > 0 then
SetWindowText lHwnd, "This is a test!"
End If
'
End Sub




>2) If I have a listbox with a list of URL's in. Is there a way that when
>I press a button in my program. IE5 or what ever browser opens and cycles
>through each URL in the list with a 2 min delay between each one...

You can achieve this with the ShellExecuteEX API call to open the URL - as for the two minute interval, you'll need to call the ShellExecuteEx from a timer event (hint: use a static variable as a counter for the minutes and as a pointer to your current listbox 'url' item).

See http://www.codeguru.com/vb/articles/1997.shtml for an example on how to use the ShellExecute API call.


>3) Is there a way to get a list of the running programs and have one of
>them become the selected window when I press a button or what ever.....or
>the window on top.

Take a look at the code at http://codeguru.developer.com/vb/articles/1968.shtml to see the running programs. Then use the SetActiveWindow API call to make that program have focus.



Chris Eastwood

CodeGuru - the website for developers
http://codeguru.developer.com/vb

Cakkie
February 7th, 2000, 12:05 AM
Looks to me that you're writing an app to fool one of those 'make money to surf the web' programs (hehe). I just want to make a remark with the changing of the titlebar stuff.
A lot of programs do not allow other programs to change the titlebar, and if they do, thay will regulary change it (like chris already mentioned).

Also with the combobox, i'd use an array (much easier to loop throug). The shell functon should do the work:


ieApp = shell('your url here')




this should open the url in your default browser

Tom Cannaerts
slisse@planetinternet.be

The best way to escape a problem, is to solve it.