Script to move the mouse / click without seeing it happen?

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Script to move the mouse / click without seeing it happen?

Post by aboredprogrammer » Wed Jan 27, 2010 7:16 am

Hello,

I was wondering if it is possible to be able to move the mouse without seeing it happen. For example, if my mouse is currently in the location of 0,0 I want to be able to have it move to 983,503 and right click, then 358,467 and right click, without noticing that the mouse has moved at all from the 0,0 coordinates. Is this possible?

Thanks for your time.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Jan 27, 2010 1:46 pm

You might try moving the mouse to the click point, click the mouse, and move it back to the start point. May be quick enough that it will not be noticed, maybe just a flicker?.
Last edited by Bob Hansen on Thu Jan 28, 2010 8:57 pm, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Jan 27, 2010 2:40 pm

Bob wrote: May be quick enough that it will not be noticed, maybe just a flicker?.
Here's a short script that moves the cursor to a random location on the screen and returns it to its original position many times in succession. The number of times is controlled by the variable "RoundTrips". If I set "RoundTrips" to 10, so the cursor moves to a random location and returns to its original location 10 times, I don't see any flickering of the cursor. If I set "RoundTrips" to 50, I start to notice a flicker.

This script doesn't do the click since moving to random points on the screen and clicking seems potentially hazardous. But each line of code takes a few 10 thousands of a second to process so adding a "LClick" line isn't going to add much flicker.

Code: Select all

Let>RoundTrips=10

VBSTART
VBEND

Let>kk=0
VBEval>timer,starttime
Repeat>kk
  Add>kk,1
  GetCursorPos>CurX,CurY
  Random>1000,ranX
  Random>1000,ranY
  MouseMove>RanX,RanY
  MouseMove>CurX,CurY
Until>kk=%RoundTrips%
VBEval>timer-%starttime%,endtime

mdl>endtime

gdyvig
Automation Wizard
Posts: 447
Joined: Fri Jun 27, 2008 7:57 pm
Location: Seattle, WA

Use a curor editor

Post by gdyvig » Wed Jan 27, 2010 4:25 pm

I haven't tried it, but it looks like this cursor editor might work:

http://www.mp3car.com/vbulletin/softwar ... arent.html


Gale

User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Post by aboredprogrammer » Thu Jan 28, 2010 12:33 am

Thanks for all of the replies. What I am trying to do is make a script that will play a game for you automatically. For example looking for pixel colors, and If that pixel color exists, then it will LClick. How would I be able to do this without moving the game screen to the 0,0 position. Is there any way to successfully have it search for the buttons/cards/tiles without moving the screen? Just wherever the user has the game, it will locate it's position and begin playing.

Thanks.

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Jan 28, 2010 9:49 am

You cannot move the cursor without ... er, moving the cursor.

However, with some applications what you can do is send a WM_CLICK message directly to a control - say a button - and therefore bypass actually simulating mouse movements/clicks. This may, or may not work and requires us to find the handle of the control so that we can use SendMessage.

Search the forums for "SendMessageA" and "FindWindowEx".

The chances of this working on your game are extremely slim since games tend not to use regular windows controls, usually work at a lower level, and it is probably detecting the position of the cursor anyway.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jan 28, 2010 7:57 pm

You cannot move the cursor without ... er, moving the cursor.
True, but as I tried to point out earlier, you CAN move the cursor to several different screen locations, then move it back to its original location without any visible cursor movement.

User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Post by aboredprogrammer » Thu Jan 28, 2010 8:22 pm

Hello everyone,

Thanks for replying. JRL, this is exactly what I want to do. However, err, I'm running into some simple beginner problems =/.. Here is what I currently have:

Dialog>Dialog1
Caption=Ali Baba Slot Bot v1
Width=180
Height=119
Top=221
Left=199
Max=0
Min=0
Close=1
Resize=0
RadioGroup=msRadioGroup1,Speed settings,0,0,89,57,Fast%CRLF%Medium%CRLF%Slow,0
RadioGroup=msRadioGroup2,Bet settings,96,0,73,57,Bet Max%CRLF%Bet One,0
Button=Start,8,64,49,25,10,,Start bot
Button=Pause,64,64,49,25,20,,Pause bot
Button=About,120,64,49,25,30,,More info...
EndDialog>Dialog1
Show>Dialog1,r

/////////////I cannot remember now how to make it always show the dialog when the program is running.. also, if "start bot" is clicked when the "Fast" setting in the radio group is selected, how do I make it do this?" Labels? I haven't done this since 2004. When "Start Bot" is selected with the "Fast" and "Bet Max" setting, I want it to run this code below:////////////////

GetScreenRes>sX,xY
ScreenCapture>0,0,sX,sY,d:\screen.bmp
FindImagePos>C:\Windows\System32\nlhtml\bm.bmp,SCREEN,20,1,XPos,YPos,NumFound
Wait>0.1
if>imgs>0
Mou>XPos_0,YPos_0
Lcl
Endif

/////This code works fine, and finds the button it's supposed to. However, you see the cursor move and stay at the button.. How do I make it move fast where you don't see it, and have the cursor return back to the original position using this code??/////////

Thanks, and sorry if this doesn't make any sense..

aboredprogrammer

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Thu Jan 28, 2010 9:05 pm

See comments

Code: Select all

Dialog>Dialog1
    Caption=Ali Baba Slot Bot v1
    Width=180
    Height=119
    Top=221
    Left=199
    Max=0
    Min=0
    Close=1
    Resize=0
    RadioGroup=msRadioGroup1,Speed settings,0,0,89,57,Fast%CRLF%Medium%CRLF%Slow,0
    RadioGroup=msRadioGroup2,Bet settings,96,0,73,57,Bet Max%CRLF%Bet One,0
    Button=Start,8,64,49,25,10,,Start bot
    Button=Pause,64,64,49,25,20,,Pause bot
    Button=About,120,64,49,25,30,,More info...
EndDialog>Dialog1

//I cannot remember now how to make it always show the dialog when the program
//is running.. (See below)


//also, if "start bot" is clicked when the "Fast" setting in the radio group
//is selected, how do I make it do this?" Labels? (yes, labels or subroutines)


//I haven't done this since 2004. 
//When "Start Bot" is selected with the "Fast" and "Bet Max" setting, I want it to run
//this code below:////////////////

///First you need a non-modal dialog (see help for dialog)
Show>Dialog1

///then you need an infinite loop controlled by your dialog
///that oddly also allows the dialog to be controlled.

Label>Loop
  GetDialogAction>Dialog1,res1
  If>res1=2
    Exit>0
  EndIf
  If>res1=10
    If>{(%Dialog1.msRadiogroup1.ItemIndex%=0) and (%Dialog1.msRadiogroup2.ItemIndex%=0)}
     ///Do whatever when "fast" and "Bet Max" are selected and "Start Bot" is pressed
     GoSub>SB_F_BM
    EndIf
    If>{(%Dialog1.msRadiogroup1.ItemIndex%=1) and (%Dialog1.msRadiogroup2.ItemIndex%=0)}
     ///Do whatever when "Medium" and "Bet Max" are selected and "Start Bot" is pressed
    EndIf
    If>{(%Dialog1.msRadiogroup1.ItemIndex%=2) and (%Dialog1.msRadiogroup2.ItemIndex%=0)}
     ///Do whatever when "slow" and "Bet Max" are selected and "Start Bot" is pressed
    EndIf
    If>{(%Dialog1.msRadiogroup1.ItemIndex%=0) and (%Dialog1.msRadiogroup2.ItemIndex%=1)}
     ///Do whatever when "fast" and "Bet One" are selected and "Start Bot" is pressed
    EndIf
    If>{(%Dialog1.msRadiogroup1.ItemIndex%=1) and (%Dialog1.msRadiogroup2.ItemIndex%=1)}
     ///Do whatever when "medium" and "Bet One" are selected and "Start Bot" is pressed
    EndIf
    If>{(%Dialog1.msRadiogroup1.ItemIndex%=2) and (%Dialog1.msRadiogroup2.ItemIndex%=1)}
     ///Do whatever when "slow" and "Bet One" are selected and "Start Bot" is pressed
    EndIf
    ResetDialogAction>Dialog1
  EndIf
  If>res1=20
    //Pause (whatever that means)
    ResetDialogAction>Dialog1
  EndIf
  If>res1=30
    MDL>About...
    ResetDialogAction>Dialog1
  EndIf
  Wait>0.01
Goto>Loop

//This code works fine, and finds the button it's supposed to. However, you see the
//cursor move and stay at the button.. How do I make it move fast where you don't see it,
//and have the cursor return back to the original position using this code??/////// 
///   (See below)


SRT>SB_F_BM
  //you need to return the cursor to its current position so you need to
  //capture the current position
  GetCursorPos>CurX,CurY

  GetScreenRes>sX,xY
  ScreenCapture>0,0,sX,sY,d:\screen.bmp
  FindImagePos>C:\Windows\System32\nlhtml\bm.bmp,SCREEN,20,1,XPos,YPos,NumFound
  Wait>0.1
  if>imgs>0
  Mou>XPos_0,YPos_0
  Lcl

  //After doing the click,  return the mouse to where it was
  Mou>CurX,CurY
  Endif
END>SB_F_BM

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Thu Jan 28, 2010 10:16 pm

Maybe need to add a SetFocus at the beginning of the SRT?
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Post by aboredprogrammer » Fri Jan 29, 2010 5:57 pm

JRL: Thank you very much, that helped me out TREMENDOUSLY. Just two more questions though...

1. GetDialogAction>Dialog1,res1
If>res1=2
Exit>0
EndIf
/////////////where did the =2 come from? also, why does exit=0?/////////

2. When the "about" button is clicked, is there any way to show like the VB Message? Not the Macro scheduler message? Because in the title of the Macro scheduler message it says "Macro Scheduler" is there any way to show the VB message? Or should I have it show another dialog?

Bob Hansen: Yes, thank you :) I will be adding a Setfocus>* In Slots (to locate the game screen just in case)

Thanks for all of your help! You guys are great!

aboredprogrammer

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Fri Jan 29, 2010 6:51 pm

aboredprogrammer wrote:2. When the "about" button is clicked, is there any way to show like the VB Message? Not the Macro scheduler message? Because in the title of the Macro scheduler message it says "Macro Scheduler" is there any way to show the VB message? Or should I have it show another dialog?aboredprogrammer
Hi aboredprogrammer,

I have seen this question pop up many times... I think I even asked at one time if there was a way to use the standard Message> and MDL> commands such that the title would not show as "Macro Scheduler" or if one day, it could be enhanced so we could add an extra parameter to those commands to over-ride that default title and show something else instead.

The answer I've always seen coming back has been... no, use a dialog.

While that will work... because people just keep asking for this... I feel enhancing the Message> and MDL> commands to let us optionally specify our own title (or just suppress the default one) would be useful and get used... especially for those that resell compiled macros.

Another way to accomplish this might be just to add another SYSTEM variable and if we set that to something, it would use that for the Title for the Message> and MDL> commands. If we wanted to not didplay a Title at all, perhaps that could be accomplished by setting that SYSTEM variable to nothing like this:

Let>new_SYSTEM_var=

Just my two cents... carry on...
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
aboredprogrammer
Junior Coder
Posts: 40
Joined: Wed Jan 27, 2010 6:31 am

Post by aboredprogrammer » Fri Jan 29, 2010 7:23 pm

jpuziano,

Thanks for the reply! So, what you're confirming is that the only way to do this is by creating your own "Message" box using a dialog, correct? Even though this is something minuscule, this would be wonderful in future MS updates!

aboredprogrammer

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Jan 29, 2010 7:26 pm

You can set your own title for the message boxes when the macro is compiled by setting APP_TITLE. This only works for compiled macros.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jan 29, 2010 7:52 pm

Its also possible to create Windows Style message boxes by using the libfunc> function. See THIS POST by Rain for a script that can generate the message for you. You don't need this script but the script automates the possible formats and makes the message creation easy.
/////////////where did the =2 come from? also, why does exit=0?/////////
"2" is always the return code when the upper right hand "X" is pressed in a dialog. Consequently I tend to think of "2" as a reserved code and only use it if I've created a "Cancel" button. In which case "Cancel" and "X" do the same thing in the script.

Exit>0 could be Exit>"any number" or nothing. But only a number or nothing. The exit code is meant to be passed to another application. See Exit> Help

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts