|
-
Aug 13th, 2000, 02:31 PM
#1
Thread Starter
Frenzied Member
How can I find WinAmp Main window, and send the key 'x' to it??
-
Aug 13th, 2000, 02:52 PM
#2
Code:
Private Sub Command1_Click()
AppActivate ("Winamp")
SendKeys "x"
End Sub
-
Aug 13th, 2000, 03:03 PM
#3
OR.........
you could use FindWindow and the classname to get the hwnd, then use SendMessageByString and send "x" to it, this would be more reliable.
Code:
Private Declare Function SendMessageByString Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
-
Aug 13th, 2000, 03:06 PM
#4
Thread Starter
Frenzied Member
Could you give an example on how to use it....i can't get it to work....
-
Aug 13th, 2000, 04:00 PM
#5
I couldnt get it to work either, thats why I didnt post a sample
-
Aug 13th, 2000, 04:03 PM
#6
Thread Starter
Frenzied Member
-
Aug 13th, 2000, 04:22 PM
#7
Send the WM_CHAR message:
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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
Const WM_CHAR = &H102
Private Sub Command1_Click()
Dim hWinamp As Long
'Get the hWnd of Winamp
hWinamp = FindWindow("Winamp v1.x", vbNullString)
'Send the X button to Winamp
SendMessage hWinamp, WM_CHAR, vbKeyX, 0
End Sub
-
Aug 13th, 2000, 04:26 PM
#8
Thread Starter
Frenzied Member
Hi megatron!
Nothing happens....
-
Aug 13th, 2000, 04:36 PM
#9
I already tried that!
I tried using WM_KEYDOWN and WM_KEYUP and WM_CHAR nothing worked.
-
Aug 13th, 2000, 04:38 PM
#10
Thread Starter
Frenzied Member
I have also looked at the SendKeys help topic in VB....didn't work either!
-
Aug 13th, 2000, 05:10 PM
#11
Try this. I've used WM_KEYDOWN instead.
Code:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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
Const WM_KEYDOWN = &H100
Private Sub Command1_Click()
Dim hWinamp As Long
'Get the hWnd of Winamp
hWinamp = FindWindow("Winamp v1.x", vbNullString)
'Send the X button to Winamp
SendMessage hWinamp, WM_KEYDOWN, vbKeyX, 0
End Sub
-
Aug 13th, 2000, 05:11 PM
#12
????
I tried the SendKeys code myself, it worked fine.
but winamp has to be open first..(obviously)
-
Aug 14th, 2000, 04:35 AM
#13
Thread Starter
Frenzied Member
Thanks Megatron! That worked!
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
|