Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » C# Language » Send key to JUMP TO FILE winamp window
       
Author Reply
Catalin
posted 4 posts
since Feb 11, 2012 
from

Send key to JUMP TO FILE winamp window

  Posted on: 11 Feb 2012       

Hi,
I'm trying to send key stroke to winamp Jump to File window, using c#, when is not in foreground but I don't know how.
So far I managed to send keys to winamp like "c" key to toggle play/pause using this example (this example work even when winamp is minimized):


using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    class Test
    {
  
        [DllImport("User32.Dll", EntryPoint = "PostMessageA")]
        static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr FindWindow([MarshalAs(UnmanagedType.LPTStr)] string lpClassName,
                                                [MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);

      
       public static void com()
        {
            IntPtr hwnd = FindWindow("Winamp v1.x", null);
            PostMessage(hwnd, 0x100, 0x43, 0);
        }
    }
}

0x43 is the Virtual-Key Code for „C" key.

Can someone help me with this problem and give me an example of haw I can send keys to Jump to File window in winamp?

Vulpes
posted  5419 posts
since  Feb 28, 2011 
from 

 Re: Send key to JUMP TO FILE winamp window
  Posted on: 11 Feb 2012        0  
According to this link:

http://blog.winamp.com/2008/08/14/keyboard-shortcuts/ 

the keyboard shortcut for Jump To File is 'J'.

So, I'd send the virtual  keycode for 'J' which is 0x4A.
Catalin
posted  4 posts
since  Feb 11, 2012 
from 

 Re: Send key to JUMP TO FILE winamp window
  Posted on: 12 Feb 2012        0  
Thanks for the answer.

What I want is to send keys to the window (JUMP TO FILE) not to open it. I'm trying to make an application that search a melody in winamp play list by sending keys to this window.
From what I know I have to send keys to a child class of wimamp which is called "Edit", but I don't know how.

  I found some examples but it didn't work for me.
I want to use "PostMessage" because I want to be able to sent keys even the window is not in focus.

Thanks.

Vulpes
posted  5419 posts
since  Feb 28, 2011 
from 

 Re: Send key to JUMP TO FILE winamp window
  Posted on: 12 Feb 2012        0  
Well, you'll need to use FindWindowEx to get the handle for the child window and then send it the keys using PostMessage.

I imagine you've obtained the window class name using Spy++. 

The code will be something like this:

[DllImport("user32.dll", CharSet = CharSet.Auto)]
static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

// ...

IntPtr chwnd = FindWindowEx(hwnd, null, "Edit", null); 

Catalin
posted  4 posts
since  Feb 11, 2012 
from 

 Re: Send key to JUMP TO FILE winamp window
  Posted on: 12 Feb 2012        0  

I obtained the name of the class using Winspector.
This is what I found with Winspector:

- 000B099A: BaseWindow_RootWnd „Jump to file"
        - 00090820: BaseWindow_RootWnd „Jump to file"
                - 004E0242: Winamp Gen „Jump to file"
                        - 001707CC: #32770 „Jump to file"
                                - 00200806: Edit

I changed my script into this but with no result.

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    class Test2
    {
  
        [DllImport("User32.Dll", EntryPoint = "PostMessageA")]
        static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr FindWindow([MarshalAs(UnmanagedType.LPTStr)] string lpClassName,
                                               [MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]

        static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
      
       public static void comm()
        {

            IntPtr hwnd = FindWindow("Winamp v1.x", null);
            IntPtr chwnd = FindWindowEx(hwnd, IntPtr.Zero, "Edit", null);
            PostMessage(chwnd, 0x100, 0x43, 0);
        }
    }
}


Maybe these are banal questions but I'm very new in c#
Thank you very much for your time.

Vulpes
posted  5419 posts
since  Feb 28, 2011 
from 

 Re: Send key to JUMP TO FILE winamp window
  Posted on: 12 Feb 2012   Accepted Answer     0  
I think the problem here is that "Edit" is not a child of Winamp's main window but a child of some other window (apparently one with the class name "#32770") down the chain.

What you'll therefore need to do is to repeatedly call FindWindowEx for each level of child window until you eventually drill down to "Edit".

Catalin
posted  4 posts
since  Feb 11, 2012 
from 

 Re: Send key to JUMP TO FILE winamp window
  Posted on: 13 Feb 2012        0  

Hello again.
Using your advice I managed to send keys to "Jump to File" window.
Below is the script that works perfect for me:

using System;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication1
{
    class test
    {

        [DllImport("User32.Dll", EntryPoint = "PostMessageA")]
        static extern bool PostMessage(IntPtr hWnd, uint msg, int wParam, int lParam);

        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr FindWindow([MarshalAs(UnmanagedType.LPTStr)] string lpClassName,
                                               [MarshalAs(UnmanagedType.LPTStr)] string lpWindowName);
        [DllImport("user32.dll", CharSet = CharSet.Auto)]

        static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        public static void comm()
        {

            IntPtr hwnd = FindWindow("BaseWindow_RootWnd", null);        
            IntPtr chwnd1 = FindWindowEx(hwnd, IntPtr.Zero, "BaseWindow_RootWnd", null);
            IntPtr chwnd2 = FindWindowEx(chwnd1, IntPtr.Zero, "Winamp Gen", null);
            IntPtr chwnd3 = FindWindowEx(chwnd2, IntPtr.Zero, "#32770", null);
            IntPtr chwnd4 = FindWindowEx(chwnd3, IntPtr.Zero, "Edit", null);

            PostMessage(chwnd4, 0x100, 0x43 , 0);
      
       
        }

      
    }
}

0x43 is the Virtual-Key Code for „C" key.


Thank you very much for your answer.

       
Nevron Gauge for SharePoint
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!

 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved