Results 1 to 6 of 6

Thread: Adding a menu in another program

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Adding a menu in another program

    Hello everyone.

    In a java game (Minecraft) I want to add a server menu containing chat admin server commands. I already worked out everything required to send the keys (sendmessage WM_KEYDOWN) and to simulate mouse clicks. The only problem I have is a nice gui.

    I already tried a topmost transparant window, but it has one large problem: focus change causes the background game window to lose focus, and thus open the game menu. I somewhat fixed this by sending focus/activate messages to the game window, but this causes the game to go fullscreen on 64 bit machines. (for some reason)

    Then I thought of painting my controls ontop of the window, but I would still have to handle mouse movement which is not (easily) possible at that point. Is there any way to add a control to another window (with the coding) or set up some sort of Window hook to handle the events?

    The final goal is a simple overlay which is clickable as if it is part of the game.
    I do not have to read any information from the parent window, only have to add a Windows Forms control to it. Since java is different from .NET I doubt adding the control is even possible...

    I know window hooking is a sensitive subject at these forums, if what I want to do is not allowed using hooking then hooking is not an option, and all I would have to know then is how to add my own control as child to another (window) handle.

  2. #2
    Software Carpenter dee-u's Avatar
    Join Date
    Feb 2005
    Location
    Pinas
    Posts
    11,127

    Re: Adding a menu in another program

    I am not sure but have you searched if you can use the APIs GetMenu and InsertMenuItem?
    Regards,


    As a gesture of gratitude please consider rating helpful posts. c",)

    Some stuffs: Mouse Hotkey | Compress file using SQL Server! | WPF - Rounded Combobox | WPF - Notify Icon and Balloon | NetVerser - a WPF chatting system

  3. #3
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Adding a menu in another program

    A veeeeeeery old unresolved () thread of mine: http://www.vbforums.com/showthread.php?t=376337
    See my code in the 1st post. It will show you how to add menu item to external program using Moeur's HookControl OCX.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: Adding a menu in another program

    Thanks I'll look into it.

    Not sure about changing the items' colour; you'd need the header declaration and API's for the context menu then. May be this link can *somewhat* help you with that...too complicated for em though...
    http://msdn.microsoft.com/en-us/library/bb776881%28v=VS.85%29.aspx

    EDIT

    Wow can't believe it actually worked. This test code simply did what I wanted...
    Code:
    Public Class Form1
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Dim w As New Window("Minecraft")
            w = w.Children.Last
            With HookControl
                .AddMessage(API.WM.msg.LBUTTONDOWN, "WM_LBUTTONDOWN")
                .TargethWnd = w.Handle
                MsgBox("Success: " & .SetHook)
            End With
        End Sub
    
        Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
            MsgBox("Removed all hooks: " & HookControl.RemoveAllHooks)
        End Sub
    
        Private Sub HookControl_PostedMessage(ByVal sender As System.Object, ByVal e As AxHookCtrl.__HookControl_PostedMessageEvent) Handles HookControl.PostedMessage
            Dim Msg
            'display the messages as they arrive
            For Each Msg In HookControl.Messages
                If e.uMsg = Msg.Value Then
                    Debug.Print("Posted: " & Msg.Label & "  " & e.wParam)
                    Exit For
                End If
            Next
        End Sub
    End Class
    Nicely posts when the left mouse button is clicked. I do wonder: any chance this 'API' will fail on a 64 bit system?

  5. #5
    PoorPoster iPrank's Avatar
    Join Date
    Oct 2005
    Location
    In a black hole
    Posts
    2,729

    Re: Adding a menu in another program

    Quote Originally Posted by bergerkiller View Post
    Thanks I'll look into it.

    Not sure about changing the items' colour; you'd need the header declaration and API's for the context menu then. May be this link can *somewhat* help you with that...too complicated for em though...
    http://msdn.microsoft.com/en-us/library/bb776881%28v=VS.85%29.aspx
    Thanks for the link. But it is for shell extension context menus. Not exactly what I was looking for.

    Quote Originally Posted by bergerkiller View Post
    Nicely posts when the left mouse button is clicked. I do wonder: any chance this 'API' will fail on a 64 bit system?
    I have no idea. If it failes, try "x86" setting instead of "Any Cpu".

    Edit: Sorry. I forgot it is in VB6 forum. I have no idea if this will work with x64.
    Last edited by iPrank; May 20th, 2011 at 05:02 AM.
    Usefull VBF Threads/Posts I Found . My flickr page .
    "I love being married. It's so great to find that one special person you want to annoy for the rest of your life." - Rita Rudner


  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Jul 2009
    Posts
    629

    Re: Adding a menu in another program

    Afraid it did not work on 64 bit systems. It failed to bind the DLL and OCX DirectX control to the program, giving a crash report on startup. Since I can't compile older c++ projects, and I don't know how to compile to 64 bit on a 32 bit system, I can't get to a 64 bit DLL...

    That is what my problem was with these types of DLL's...they don't work on both platforms. I'll see if I can add a VB .NET menu control...

Posting Permissions

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



Click Here to Expand Forum to Full Width