已经知道那个按钮中心在屏幕的坐标(7cm,2cm),就是以左上角为坐标原点,那个按钮在从左往右7cm,从上往下的2cm处请教!谢谢先!

解决方案 »

  1.   

    模拟鼠标动作可以用API函数mouse_event,它可以实现模拟鼠标按下和放开等动作。
    VOID mouse_event(
      DWORD dwFlags, // 鼠标动作标识。
      DWORD dx, // 鼠标水平方向位置。
      DWORD dy, // 鼠标垂直方向位置。
      DWORD dwData, // 鼠标轮子转动的数量。
      DWORD dwExtraInfo // 一个关联鼠标动作辅加信息。
    ); 其中,dwFlags表示了各种各样的鼠标动作和点击活动,它的常用取值如下:
     MOUSEEVENTF_MOVE 表示模拟鼠标移动事件。
     MOUSEEVENTF_LEFTDOWN 表示模拟按下鼠标左键。
     MOUSEEVENTF_LEFTUP 表示模拟放开鼠标左键。
     MOUSEEVENTF_RIGHTDOWN 表示模拟按下鼠标右键。
     MOUSEEVENTF_RIGHTUP 表示模拟放开鼠标右键。
     MOUSEEVENTF_MIDDLEDOWN 表示模拟按下鼠标中键。
     MOUSEEVENTF_MIDDLEUP 表示模拟放开鼠标中键。取得鼠标的当前位置:
     BOOL GetCursorPos(LPPOINT lpPoint);
    设置鼠标的当前位置:
     BOOL SetCursorPos(int X, int Y); 具体过程可以这样写:
     CPoint oldPoint,newPoint;
     GetCursorPos(&oldPoint); //保存当前鼠标位置。
     newPoint.x = oldPoint.x+40;
     newPoint.y = oldPoint.y+10;
     SetCursorPos(newPoint.x,newPoint.y); //设置目的地位置。
     mouse_event(MOUSEEVENTF_RIGHTDOWN,0,0,0,0);//模拟按下鼠标右键。
     mouse_event(MOUSEEVENTF_RIGHTUP,0,0,0,0);//模拟放开鼠标右键。再说一句,兄弟啊,这种问题,10点真是太少了啊!下次注意
      

  2.   

    取得ToolBar父窗口的hWnd和该按钮的ID,发送WM_Command通知消息Command identifier
    Each button has a command identifier associated with it. When the user selects a button, the toolbar sends the parent window aWM_COMMAND message that includes the command identifier of the button. The parent window examines the command identifier and carries out the command associated with the button. WM_COMMAND
    The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated. WM_COMMAND 
    wNotifyCode = HIWORD(wParam); // notification code 
    wID = LOWORD(wParam);         // item, control, or accelerator identifier 
    hwndCtl = (HWND) lParam;      // handle of control 
     
    Parameters
    wNotifyCode 
    Value of the high-order word of wParam. Specifies the notification code if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0. 
    wID 
    Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator. 
    hwndCtl 
    Value of lParam. Handle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL. 
    Return Values
    If an application processes this message, it should return zero. Res
    Accelerator keystrokes that select items from the window menu are translated into WM_SYSCOMMAND messages. If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, no WM_COMMAND message is sent. However, if an accelerator keystroke occurs that does not match any of the items in the window's menu or in the window menu, a WM_COMMAND message is sent, even if the window is minimized. If an application enables a menu separator, the system sends a WM_COMMAND message with the low-word of the wParam parameter set to zero when the user selects the separator.QuickInfo
      Windows NT: Requires version 3.1 or later.
      Windows: Requires Windows 95 or later.
      Windows CE: Requires version 1.0 or later.
      Header: Declared in winuser.h.
      

  3.   

    谢谢楼上2位大侠的指点!
    To renjunjun(飞黄) 大侠:不是我不想给分,是我只有那可怜的10分啊,全给了!不好意思啊!我会新开帖子给您分的!另外,还有一事情请教:我的那个是厘米(cm),怎么和代码
    newPoint.x = oldPoint.x+40;
    newPoint.y = oldPoint.y+10;
    相协调,转换呢?
    继续请教!
      

  4.   

    继续请教:
    ----还有一事情请教:我的那个是厘米(cm),怎么和代码
    newPoint.x = oldPoint.x+40;
    newPoint.y = oldPoint.y+10;
    相协调,转换呢?谢谢先!
      

  5.   

    ScaleX、ScaleY 方法
    object.ScaleX (width, fromscale, toscale)
    object.ScaleY (height, fromscale, toscale)
    用于 fromscale 和 toscale 设置值:
    常数 值 描述 
    vbPixels 3 像素 (显示器或打印机分辨率的最小单位) 
    vbCentimeters 7 厘米 
      

  6.   

    谢谢大侠先!To zyl910(910:分儿,我又来了!) 大侠 :
    您说"取得ToolBar父窗口的hWnd和该按钮的ID,发送WM_Command通知消息"-----问题是现在取得ToolBar父窗口的hWnd没问题,但是ToolBar按钮的ID是一个变化的值,每次都不同,故不知如何是好???
    谢谢先!
      

  7.   

    renjunjun给imur05捐献了200可用分;imur05收到了:180可用分
      

  8.   

    大侠真是好人啊!除了技术纯火炉青,还热情给分助人!!!!!!!感谢感谢!!!!!对了,您的那个代码好像是vc的?  vb好像没有VOID 关键字啊!请教请教!