Pressing Alt Key With Win Api
Results 1 to 8 of 8

Thread: Pressing Alt Key With Win Api

  1. #1
    Senior Member
    Join Date
    Dec 2001
    Posts
    151

    Pressing Alt Key With Win Api

    How would you simulate the pressing of the Alt key to a program?

    Code:
    Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    
    Public Const VK_MENU = &H12
    Public Const WM_KEYDOWN = &H100
    Public Const WM_KEYUP = &H101
    
    SendMessageLong lhWnd, WM_KEYDOWN, VK_MENU, 0
    SendMessageLong lhWnd, WM_KEYUP, VK_MENU, 0
    That's the code i have right now, but it doesn't seem to select the menu
    -[h3llbringer] is back, again.
    -MSN CLoNE.

  2. #2
    Senior Member
    Join Date
    Jan 2003
    Posts
    1,499
    I know how to do this but before I tell you I want a legitimate reason as I notice you have negative points.

    No Offence I'm sure you are a nice guy I just want to make sure your not just another malicious little turd sponging knowledge off the good guys.

  3. #3
    Senior Member
    Join Date
    Jan 2002
    Posts
    1,207
    I'm wondering if you need to send WM_SYS* messages to active the menu of a window... just an idea

    I don't see any reason for suspecting that you have less than honourable intentions... presumably it's just to try and automate a program which doesn't provide a convenient interface for automation.

    Slarty

  4. #4
    Senior Member
    Join Date
    Dec 2001
    Posts
    151
    i'm trying to make a bot for MSN6 that will automate the changing of the Display Pictures.
    Since the MSN6 API doesn't have any options to do so, i'm trying to find another way around this.
    I'm just trying to bring the menu up so that i can bring the Display Picture window up.
    Honest, I won't do anything bad with it. =D
    -[h3llbringer] is back, again.
    -MSN CLoNE.

  5. #5
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long

    hWnd is the window id, wMsg is the Alt key value, et cetera...

    you need to obtain the hWnd of the Application you want to send Alt to... This can be done many ways, i'd suggest reading up on your win API...
    yeah, I\'m gonna need that by friday...

  6. #6
    Senior Member
    Join Date
    Dec 2001
    Posts
    151
    I don't need to know what the params stand for, I already know that. I just don't seem to be sending the command to the application properly or with the right params. It just doesn't seem to be selecting the menu. And yes, i have looked up the use of the command but i've found nothing with selecting the menu. That's why i'm seeking your expertise.
    -[h3llbringer] is back, again.
    -MSN CLoNE.

  7. #7
    Senior Member tampabay420's Avatar
    Join Date
    Aug 2002
    Posts
    953
    i haven't messed with windows API in a while, you should be able to find many tutorials, bas, etc...
    in fact a fellow named Dos32 wrote some really nice tutorials and BAS files on complicated Windows API (most of it is from back in the day of AOL Progz)
    yeah, I\'m gonna need that by friday...

  8. #8
    Junior Member
    Join Date
    Jun 2003
    Posts
    1
    in VC++ or SDK its simple just Send a Message
    ::SendMessage(hWnd,WM_KEYDOWN,VK_MENU,0);
    ::SendMessage(hWnd,WM_KEYUP,VK_MENU,0);
    here the Hwnd is the Handle to the Window to which u want to send the Message
    To send the message to Desktop Window
    use GetDesktopwindow();

    for VC++ Querys Email me at thevampirea@yahoo.co.in

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •