|
-
Aug 13th, 2002, 04:57 PM
#1
Thread Starter
Hyperactive Member
How to get list of programs
How do I get a list of programs running. I need to know if one program is running, WinDVD4. Does it have a special id or something. The best way would be if I could just get a list and get my prog to run through this list and to find WinDVD4 in it (shouldnt be hard)/
What code do I need or is there a bas file out there to do this.
Thanks ppl.
Oh and what I need then is to be able to change the length \ width of it to any pixels I want by typing those in.
Can I do all this through the mighty basic.
Thanks
-
Aug 13th, 2002, 05:26 PM
#2
PowerPoster
You can use the FindWindow API to find the handle, or hWnd of the DVD program. You just need to know the class name, which you can find using a program called Spy++ that comes with Visual Studio. There is also a free program to do this on http://www.patorjk.com/ if you don't have VS. Next, you will need to find out to how to modify the metrics of a window, once you have the window handle, it won't take much to modify it using the appropriate API calls.
-
Aug 13th, 2002, 06:38 PM
#3
PowerPoster
Practical Example...
Copy/paste this into a module
VB Code:
Private Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Private Const WM_GETTEXT = &HD
Private aCaptions() As String
Private lCount As Long
Public Function GetAllCaptions() As Variant
lCount = 0
Call EnumWindows(AddressOf EnumWindowsProc, 0&)
If lCount Then ReDim Preserve aCaptions(lCount - 1)
GetAllCaptions = IIf(lCount, aCaptions, Array())
End Function
Private Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim sBuffer As String * 260
If IsWindowVisible(hwnd) Then
ReDim Preserve aCaptions(lCount)
aCaptions(lCount) = Left(sBuffer, SendMessage(hwnd, WM_GETTEXT, 260, ByVal sBuffer))
If Len(Trim(aCaptions(lCount))) Then lCount = lCount + 1
End If
EnumWindowsProc = hwnd
End Function
Copy/paste this to the declarations section of a form with a Listbox (List1) and a button (Command1)
VB Code:
Private Sub Command1_Click()
Dim vCaps As Variant
Dim lIndex As Long
vCaps = GetAllCaptions()
List1.Clear
For lIndex = 0 To UBound(vCaps)
List1.AddItem vCaps(lIndex)
Next
End Sub
-
Aug 13th, 2002, 08:07 PM
#4
Thread Starter
Hyperactive Member
WOW
Thanks so much for that code
Gonna try it out
hope I will be able to change the window size.
KT
-
Aug 13th, 2002, 08:37 PM
#5
Thread Starter
Hyperactive Member
OK
Got the list of programs working
But better yet that findwindow works great
OK so I have this now
hwnd = FindWindow("WinDVDClass", vbNullString)
I get hwnd as "1100" when WinDVD is running. Great
I did a search for changing the metrics but again it doesnt seem to be on the forums.
Anyone know how to do it.
I have to say a massive thank you to all who have helped me out.
Hope I can get this final thing now.
-
Aug 13th, 2002, 08:51 PM
#6
Frenzied Member
What kind of "metrics" are you trying to change?
-
Aug 14th, 2002, 04:45 AM
#7
Thread Starter
Hyperactive Member
I need to be able to change another programs width and length (window that is).
I have its info but what is the api code to do this
-
Aug 14th, 2002, 03:36 PM
#8
Thread Starter
Hyperactive Member
Anyone know about window length, height changing or what api code is needed.
KT
-
Aug 14th, 2002, 03:59 PM
#9
The picture isn't missing
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
SetWindowPos me.hwnd, 0, 100,100,200,200,0 'makes the window at 100,100, with the w/h at 200/200
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 14th, 2002, 04:01 PM
#10
Thread Starter
Hyperactive Member
OMFG you guys are good, really good
Excellent man, not too buggy.....
One more thing my prog needs now.
Just one more and my prog is happy.
Will post later.....
Thankx man
-
Aug 14th, 2002, 05:46 PM
#11
Thread Starter
Hyperactive Member
Worked absolutely brilliantly
One more thing if you know it
Now I need to get the positon and width height of that program. I can set it now but now need to get what it is.
Thanks so much
I wonder is it possible to change the caption of the program I am changing res. Wouldnt mind putting my own little progs name in there.
Windvd tweaked by WinDVD Tweaker
Eh!!
-
Aug 14th, 2002, 05:55 PM
#12
The picture isn't missing
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim RCT as RECT
GetWindowRect me.hwnd, RCT
'then access it using RCT.left,right,top,bottom. width is right - left, height is bottom - top
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 14th, 2002, 05:58 PM
#13
Thread Starter
Hyperactive Member
Unbelievable!
Thanks man
lol
-
Aug 14th, 2002, 07:02 PM
#14
Frenzied Member
Originally posted by King_Tweaker
I wonder is it possible to change the caption of the program I am changing res. Wouldnt mind putting my own little progs name in there.
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" ( _
ByVal hwnd As Long, _
ByVal lpString As String) As Long
hwnd = Window
lpString = New Caption
-
Aug 15th, 2002, 03:23 PM
#15
Thread Starter
Hyperactive Member
I have one problem
Those all worked great but now
i have a button to move the window one pixel say up. When I click it, my prog loses focus so I added in
form1.setfocus after the move.
When someone needs to press this button many times the display looks kind of crappy, switching from the prog to mine.
Is there a way to get my prog to be always on top of this program so this wont be a problem.
KT
-
Aug 15th, 2002, 03:26 PM
#16
The picture isn't missing
use this flag in the last parameter of SetWindowPos
Const SWP_NOACTIVATE = &H10
Remember, if someone's post was not helpful, you can always rate their post negatively  .
-
Aug 15th, 2002, 03:33 PM
#17
Thread Starter
Hyperactive Member
OMG man you did it again
Made me go OMFG this guy is good.
Tanks a million.
-
Aug 17th, 2002, 05:15 PM
#18
Thread Starter
Hyperactive Member
Can anyone give me a way to read what sizes Windows is using for Window Border and Title Bar because of course I am trying to change the size of the inside window and not the outside one (+borders etcetc..)
thanks
KT
-
Aug 18th, 2002, 03:58 AM
#19
Addicted Member
its a great exemple
works fine
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
|