Hello!
May anybody tell me if it is possible to move the mouse on the desktop with a code?! If yes, how to do so?
May anybody tell me if it is possible to move the mouse on the desktop with a code?! If yes, how to do so?
' // Blitz Max Code ' //============================= ' // Mouse API Function Example by Eikon ' // Converted to Blitz Max by Plash ' // Note: This only works on WIN32 ' //============================= Extern "win32" Function SetCursorPos%(x%, y%) Function mouse_event%(dwFlags%, dx%, dy%, cButtons%, dwExtraInfo%) End Extern Desk_W = ClientWidth(Desktop()) Desk_H = ClientHeight(Desktop()) ' // [GUI] Global Parent:TGadget = CreateWindow("Automate Mouse", (Desk_W / 2) - 75, (Desk_H / 2) - 61, 150, 122, 0, 1) Global New_X:TGadget = CreateTextField(5, 5, 64, 18, Parent, 0) Global New_Y:TGadget = CreateTextField(75, 5, 64, 18, Parent, 0) Global Move:TGadget = CreateButton ("Move Mouse", 5, 26, 134, 18, Parent, 1) Global Simu:TGadget = CreateButton ("Simulate Click", 5, 48, 134, 18, Parent, 1) Global SimuMove:TGadget = CreateButton ("Move&Simu Click", 5, 70, 134, 18, Parent, 1) SetGadgetText New_X, Desk_W / 2 ' // [Defaults] SetGadgetText New_Y, Desk_H / 2 ' // [Mouse_Event dwFlag Constants] Const MOUSEEVENTF_ABSOLUTE = -32768 ' // Use absolute coords Const MOUSEEVENTF_MOVE = 1 ' // Trigger move event Const MOUSEEVENTF_LEFTDOWN = 2 ' // LMB Down Const MOUSEEVENTF_LEFTUP = 4 ' // LMB Up Const MOUSEEVENTF_RIGHTDOWN = 8 ' // RMB Down Const MOUSEEVENTF_RIGHTUP = 16 ' // RMB Up Const MOUSEEVENTF_MIDDLEDOWN = 32 ' // MMB Down Const MOUSEEVENTF_MIDDLEUP = 64 ' // MMB Up Const MOUSEEVENTF_WHEEL = 128 ' // NT Only: Mouse wheel moved Const Val% = MOUSEEVENTF_LEFTDOWN + MOUSEEVENTF_LEFTUP ' Left Click ' // [Main] Repeat Select WaitEvent() Case EVENT_WINDOWCLOSE End Case EVENT_GADGETACTION ' // [Gadget Event] Select EventSource() Case Move ' // [Move Button] SetCursorPos Int(TextFieldText(New_X)), Int(TextFieldText(New_Y)) Case Simu ' // [Simulate Left Click] mouse_event Val%, 0, 0, 0, 0 Case SimuMove SetCursorPos Int(TextFieldText(New_X)), Int(TextFieldText(New_Y)) mouse_event Val%, 0, 0, 0, 0 End Select End Select Forever