Thread: Help clicking a command button

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    5

    Help clicking a command button

    Well I had an idea for a cool little security system for a program, that would require Windows API to click. The program would use a command button that would be enabled until mouseover. When your mouse goes over it it disables. You can use WinAPI to trick the command button to think it was clicked and follow out the action given to the button like a message box "You clicked me!". Was wondering if anyone could help me with this kind of WinAPI coding.

    The reason i'm asking is becasue i found a program that has a button like this and i want to click it.

  2. #2
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Wrong forum, and your question is a bit weird.

    Regardless, you're going to need the EnableWindow() and SendMessage() functions. When you recieve the message that the mouse is over the button, you need to send the message WM_COMMAND with LOWORD(wParam) set to the ID of the button to the window containing the button. Then handle the WM_COMMAND message you just sent.
    Away.

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    5
    I'm very new to c++, I didnt understand what you said can you show me an example?

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    erm, if you're really that new to C++, you may not want to worry about that right this moment...
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Registered User
    Join Date
    Jul 2005
    Posts
    5
    Okay here, someone I know made a program with a button that does what i said. He said in the readme that he used the button as a protection, and If you click the button it downloads the specific program i'm looking for off his server and he gave me a hint that i should use WinAPI. And I need some helping doing this because I really need the program.

  6. #6
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    No. If you don't know how to program in C or C++ already, you don't stand a chance with the Windows API. Give yourself at least 6 months to get good with C/C++ (your choice), and then at least another 6 months to get good with the Windows API, assuming you're a fast and dedicated learner. There's nothing we can do to help you do that with what you know now short of writing the program for you, and we don't do that.
    Away.

  7. #7
    Registered User
    Join Date
    Jul 2005
    Posts
    5
    Ok Edit, I have this so far

    Code:
    #include "stdafx.h"
    #include "windows.h"
    
    
    int APIENTRY WinMain(HINSTANCE hInstance,
                         HINSTANCE hPrevInstance,
                         LPSTR     lpCmdLine,
                         int       nCmdShow)
    {
    HWND hWndProSpam;
    HWND hWndButton;
    hWndProSpam = FindWindowEx(NULL, NULL, "ThunderRT6FormDC", "Pro Spam 1");
    hWndButton = FindWindowEx(hWndProSpam, NULL, "ThunderRT6CommandButton", NULL);
    EnableWindow(hWndProSpam, 1);
    EnableWindow(hWndButton, 1);
    SendMessage(hWndButton, WM_LBUTTONDOWN, NULL, NULL);
    SendMessage(hWndButton, WM_LBUTTONUP, NULL, NULL);
    
    	return 0;
    }
    Is there a way I can make it think it's been clicked? Because that still grays out the button.
    Last edited by anarchytech; 07-09-2005 at 09:44 PM.

  8. #8
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    Try the Windows forum.
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Clicking in regions.
    By harmony_krieg in forum Windows Programming
    Replies: 3
    Last Post: 09-26-2007, 03:05 PM
  2. PC makes clicking noise - now won't start up
    By hk_mp5kpdw in forum Tech Board
    Replies: 9
    Last Post: 09-25-2007, 11:34 PM
  3. Programmically simulate clicking on webbrowser2 object
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 06-25-2007, 01:19 PM
  4. Programmically simulate clicking on webbrowser2 object
    By hanhao in forum Windows Programming
    Replies: 1
    Last Post: 06-24-2007, 10:34 PM
  5. Replies: 5
    Last Post: 10-21-2005, 02:11 PM