Programming Language: Any | Target: A simple mouse clicker.

Hi Experts,

I need a simple source code to create a following small application, as "Mouse Clicker".

There should be the following changable parameters:

1. Left mouse button Click speed option (e.g. 100Msc delay).
2. Right mouse button Click speed option.
3. Swap left and right mouse buttons.
4. Hot key definable (e.g. Alt+Ctrl+M) to toggle on/off these mouse options
5. Running in hidden mode - in tray.

The application can be developed in any language, though VB is preferable.

Code should be ready for compillation, an already compiled examle - welcome.

I need this code for educational purposes, for developing a bigger application, where mouse click speed is essencial.

Thank you in advance! :)
andysysAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fridomCEO/ProgrammerCommented:
to 1 use GetDoubleClickTime and SetDoubleClickTime
       choice can be done via a simple edit field and or some combo box
to 2 I don't think it's possible to change  the speed option for the button separatly
to 3 is done via SwapMouseButton

4-5 would need some more time to figure out

Regards
Friedrich
0
AlexFMCommented:
Take a look at SystemParametersInfo API, it allows to get and set some of these parameters.
0
andysysAuthor Commented:
Any code? ;)
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

fridomCEO/ProgrammerCommented:
If you insist:

call backs for changing mouse click speed

#include <windows.h>
#include <assert.h>
#include <lfc.h>
#include "mouse_stuffres.h"

static UINT dblMouseClickSpeed;

long DlgMouseInfosSelected(ST_BUTTON *btn ,struct _DlgMouseInfos *dlg){
      char buf[256];
      assert(dlg->ef_doubleclick_speed);
      dlg->ef_doubleclick_speed->GetWindowText(buf, sizeof(buf));
      int nval = atoi(buf);
      if (nval){
            if (nval > 0){
                  dblMouseClickSpeed = nval;
                  SetDoubleClickTime(nval);
                  SetDlgItemInt(dlg->hwnd, TL_MOUSE_SPEED, dblMouseClickSpeed, TRUE);
            }
      }

      return (EndDialog (dlg->hwnd, 0));
}
long DlgMouseInfosInit(ST_DIALOGBOX *ctrl,struct _DlgMouseInfos *dlg)
{
      if (! dblMouseClickSpeed){
            dblMouseClickSpeed = GetDoubleClickTime();
      }

      return SetDlgItemInt(dlg->hwnd, TL_MOUSE_SPEED, dblMouseClickSpeed, TRUE);

}


The windows main program
*@@ Wedit generated application. Written Sat Apr 08 08:35:24 2006
 @@header: h:\projects\mouse_stuff\mouse_stuffres.h
 @@resources: h:\projects\mouse_stuff\mouse_stuff.rc
 Do not edit outside the indicated areas */
/*<---------------------------------------------------------------------->*/
/*<---------------------------------------------------------------------->*/
#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include <string.h>
#include "mouse_stuffres.h"
/*<---------------------------------------------------------------------->*/
HINSTANCE hInst;            // Instance handle
HWND hwndMain;            //Main window handle

LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);

/*<---------------------------------------------------------------------->*/
/*@@0->@@*/
static BOOL InitApplication(void)
{
      WNDCLASS wc;

      memset(&wc,0,sizeof(WNDCLASS));
      wc.style = CS_HREDRAW|CS_VREDRAW |CS_DBLCLKS ;
      wc.lpfnWndProc = (WNDPROC)MainWndProc;
      wc.hInstance = hInst;
      wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
      wc.lpszClassName = "mouse_stuffWndClass";
      wc.lpszMenuName = MAKEINTRESOURCE(IDMAINMENU);
      wc.hCursor = LoadCursor(NULL,IDC_ARROW);
      wc.hIcon = LoadIcon(NULL,IDI_APPLICATION);
      if (!RegisterClass(&wc))
            return 0;
/*@@0<-@@*/
      // ---TODO--- Call module specific initialization routines here

      return 1;
}

/*<---------------------------------------------------------------------->*/
/*@@1->@@*/
HWND Createmouse_stuffWndClassWnd(void)
{
      return CreateWindow("mouse_stuffWndClass","mouse_stuff",
            WS_MINIMIZEBOX|WS_VISIBLE|WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_MAXIMIZEBOX|WS_CAPTION|WS_BORDER|WS_SYSMENU|WS_THICKFRAME,
            CW_USEDEFAULT,0,CW_USEDEFAULT,0,
            NULL,
            NULL,
            hInst,
            NULL);
}
/*@@1<-@@*/
/*<---------------------------------------------------------------------->*/
/* --- The following code comes from p:\lcc\lib\wizard\defOnCmd.tpl. */
void MainWndProc_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
      switch(id) {
            // ---TODO--- Add new menu commands here
            /*@@NEWCOMMANDS@@*/
            case IDM_MOUSE_INFOS:
                  RunDlgMouseInfos(hwnd);
                  break;

            case IDM_EXIT:
            PostMessage(hwnd,WM_CLOSE,0,0);
            break;
      }
}

/*<---------------------------------------------------------------------->*/
/*@@2->@@*/
LRESULT CALLBACK MainWndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
      switch (msg) {
/*@@3->@@*/
      case WM_COMMAND:
            HANDLE_WM_COMMAND(hwnd,wParam,lParam,MainWndProc_OnCommand);
            break;
      case WM_DESTROY:
            PostQuitMessage(0);
            break;
      default:
            return DefWindowProc(hwnd,msg,wParam,lParam);
      }
/*@@3<-@@*/
      return 0;
}
/*@@2<-@@*/

/*<---------------------------------------------------------------------->*/
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, INT nCmdShow)
{
      MSG msg;
      HANDLE hAccelTable;

      hInst = hInstance;
      if (!InitApplication())
            return 0;
      hAccelTable = LoadAccelerators(hInst,MAKEINTRESOURCE(IDACCEL));
      if ((hwndMain = Createmouse_stuffWndClassWnd()) == (HWND)0)
            return 0;
      ShowWindow(hwndMain,SW_SHOW);
      while (GetMessage(&msg,NULL,0,0)) {
            if (!TranslateAccelerator(msg.hwnd,hAccelTable,&msg)) {
                  TranslateMessage(&msg);
                  DispatchMessage(&msg);
            }
      }
      return msg.wParam;
}

The resource file
/* Wedit generated resource file */
#ifdef __LCC__
#include <windows.h>
#endif
#include "mouse_stuffres.h"


DLG_MOUSE_INFO DIALOG 38, 41, 180, 180
STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
CAPTION "Mouse Facilities"
FONT 8, "MS Sans Serif"
BEGIN
    PUSHBUTTON      "Close", PB_MOUSE_DIALOG_CLOSE, 63, 103, 40, 14
    EDITTEXT        EF_DOUBLECLICK_SPEED, 107, 48, 57, 12, ES_AUTOHSCROLL
    LTEXT           "", TL_MOUSE_SPEED, 105, 25, 67, 12
    LTEXT           "Current Mouse Speed", -1, 21, 25, 76, 12
    LTEXT           "Set Current Double Click Speed", -1, 23, 49, 78, 17
END
300 ACCELERATORS
BEGIN
    81, 300, VIRTKEY, CONTROL
END
IDMAINMENU MENU
BEGIN
    POPUP "&File"
        BEGIN
        MENUITEM "&New", IDM_NEW
        MENUITEM "&Open", IDM_OPEN
        MENUITEM "&E&xit", IDM_EXIT
        END
    POPUP "&Help"
        BEGIN
        MENUITEM "&About", IDM_ABOUT
        MENUITEM "Mouse Info", IDM_MOUSE_INFOS
        END
END


The frame for displaying a dialog

/*@@ Generated by Wedit @@ */
#include <windows.h>
#include <lfc.h>
#include "mouse_stuffres.h"

/*@@Callbacks Section--------------------------------------Callbacks Section@@*/
/*@@Dialog "DlgMouseInfos"----------------------------Dialog "DlgMouseInfos"@@*/
static ST_DIALOGBOX *Set_DlgMouseInfos_Fields(HWND hwnd)
{
      struct _DlgMouseInfos *s;
      ST_DIALOGBOX *std = GetSTControlFromHwnd(hwnd);
      s = malloc(sizeof(struct _DlgMouseInfos));
      s->pb_mouse_dialog_close = GetControl(std,110);
      s->ef_doubleclick_speed = GetControl(std,108);
      s->tl_mouse_speed = GetControl(std,105);
      s->hwnd = hwnd;
      std->Data->pDlgStruct = s;
      return std;
}

BOOL APIENTRY DlgMouseInfos(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
      ST_DIALOGBOX *std;
      struct _DlgMouseInfos *s;

      std = GetSTControlFromHwnd(hwnd);
      if (std && std->Data)
      {
            s = std->Data->pDlgStruct;
            if (s)
            {
                  s->wParam = wParam;
                  s->lParam = lParam;
            }
      }
      switch(msg)
      {
            case WM_INITDIALOG:
                  /* Initialization of the dialog box */
                  std = ST_InitDialogBox(hwnd);
                  Set_DlgMouseInfos_Fields(hwnd);
                  if (!(std && std->Data)) break;
                  s = std->Data->pDlgStruct;
                  if (!s) break;
                  DlgMouseInfosInit(std,s);
                  break;
            case WM_COMMAND:
                  switch (LOWORD(wParam))
                  {
                        case PB_MOUSE_DIALOG_CLOSE:
                              DlgMouseInfosSelected(GetControl(std,110),s);
                        break;
                        case EF_DOUBLECLICK_SPEED:
                        break;
                  }
                  break;
            case WM_DESTROY:
                  /* Remove the input arguments property */
                  RemoveProp(hwnd,"InputArgument");
                  break;
            case WM_NCDESTROY:
                  ST_DestroyDialogBox(hwnd);
                  break;
      }
      return FALSE;
}
int RunDlgMouseInfos(HWND parent)
{
      return DialogBox((HANDLE)GetWindowLong(parent,GWL_HINSTANCE),MAKEINTRESOURCE(101),parent,DlgMouseInfos);
}
HWND StartDlgMouseInfos(HWND parent)
{
      return CreateDialog((HANDLE)GetWindowLong(parent,GWL_HINSTANCE),MAKEINTRESOURCE(101),parent,DlgMouseInfos);
}


Now adding swapping the mouse stuff would be easy. Make it stay unvisible, would need some extra time. Feel free to use the code as a start.

Regards
Friedrich

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike TomlinsonMiddle School Assistant TeacherCommented:
What version VB are you working in?

VB6?
VB.Net 2003?
VB.Net 2005?
0
andysysAuthor Commented:
Mostly VB 2005.
Thank you fridom. I will now be able to play around with your code. I believe it is C++, am I right?
0
fridomCEO/ProgrammerCommented:
No it's lcc-win32 C, it resembles C++ a bit. I have not bothered to write windows portable C....

Regards
Friedrich
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming Languages-Other

From novice to tech pro — start learning today.