Jump to content
Dr_TDM

How to stop the mouse from moving

Recommended Posts

Dr_TDM

Hello

 

I have a small code, and i want to freeze the mouse movement, I need a very simple solution,, I've tried Mouse Trap,, but didn't success,   i'm new to this..

Share this post


Link to post
Share on other sites
JLogan3o13

@Dr_TDM welcome to the forum. As you are new, you may have missed the fact that we can't help much without being able to see your "small code". Otherwise, you're asking us to first guess at what you're trying to accomplish and then troubleshoot for you. Please help us help you by posting your code ;) 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
water

Does the _Mousetrap example script work for you?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Dr_TDM

thanks JLogan3o13 for the reply,, i have no problem posting the code,, but i remember i once read in one of the threads, that  the member should not say why the script is for or post it,, otherwise it will be deleted,,  anyways..

 

i need the mouse to be clicking every one minute,, but in te same spot that i leave the mouse when i start the function,,,

 

i have managed to make a step foward with help from trojan55  

but either the (mouseclick) works or the (mousemove),,, but couldn't do both...

 

so here is the code

Global $Paused
HotKeySet("{PGDN}","_Start")
HotKeySet ("{PGUP}", "TogglePause")
HotKeySet ("{Delete}", "_Freeze")

Func _Freeze()
   $pos = MouseGetPos()
    While 1
    MouseMove($pos[0],$pos[1])
    WEnd
 EndFunc

Func _Start()

      For $a = 1 to 1000 step 1
   MouseClick ("Left")
   Sleep (60000)
   Next


EndFunc


While 1
    Sleep(10000)
WEnd

Func TogglePause()
    $Paused = NOT $Paused
    While $Paused
        sleep(100)
        ToolTip('Script is "Paused"',0,0)
    WEnd
    ToolTip("")
EndFunc
 

 

 

Share this post


Link to post
Share on other sites
Dr_TDM

also i've tried combining the two functions to start with one hotkey but it is the same,,, only one function starts

 

Func _Freeze()
   $pos = MouseGetPos()
    While 1
    MouseMove($pos[0],$pos[1])
    WEnd
   For $a = 1 to 1000 step 1
   MouseClick ("Left")
   Sleep (3000)
   Next


 EndFunc

Share this post


Link to post
Share on other sites
water
4 minutes ago, Dr_TDM said:

but i remember i once read in one of the threads, that  the member should not say why the script is for or post it,, otherwise it will be deleted

If this means we are talking about game autoamtion here then you can be sure that not only your code will be removed but the thread will be blocked as well.
So it would greatly help if you could tell us which program you try to automate :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Dr_TDM

water thank you,,, but the idea of the Mousetrap is good,, but i couldn't do it,,,

 

i don't know what is the #include for,

Share this post


Link to post
Share on other sites
water

Dog ate your help file? The explanation what the statement is for is just a click away :)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
JLogan3o13

@Dr_TDM I agree with water, since you opened the door please explain exactly what you're trying to accomplish with 

Quote

i need the mouse to be clicking every one minute,, but in te same spot that i leave the mouse when i start the function,,,

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Dr_TDM

@JLogan3o13 @water

It's not a game issue,, i have a problem with windows,, it keeps removing the selection from my current window, so it becomes inactive and then the keyboard strokes don't do anything...

I need the code to keep clicking the mouse so the window that i'm working on keeps active,, most of my work is on excel and i mostly use the keyboard. 

 

I tried to fix it but could't,, and the service guy adviced to install a new windows,, but i cannot because i have a lot of programes that will take days to re-install and configure..

So this code is a simple solution for me...

Share this post


Link to post
Share on other sites
water

When working with Excel you shouldn't automate the GUI but use the Excel UDF that comes with AutoIt. So your scripts will become much more reliable.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
mrider

Suggestion:

Instead of trying to make it so the mouse can't move, instead have the program start with a snapshot of the mouse's current location when the program starts, and then always click there even if the mouse has moved.

Local $sleep = 60*1000 ; 1 minute, adjust as necessary
Local $orig_pos = MouseGetPos()
While True
    Sleep($sleep)
    Local $new_pos = MouseGetPos()
    MouseClick("Left", $orig_pos[0], $orig_pos[1], 1, 0)
    MouseMove($new_pos[0], $new_pos[1], 0)
    ConsoleWrite("Clicked" & @LF)
WEnd

 


How's my riding? Dial 1-800-Wait-There

Trying to use a computer with McAfee installed is like trying to read a book at a rock concert.

Share this post


Link to post
Share on other sites
junkew

this looks more logical to use

https://www.autoitscript.com/autoit3/docs/functions/WinActivate.htm

with weird behavior in windows I first would be concerned about a virus. Finding the rootcause of your problem looks much better than a bypass with a script.

Share this post


Link to post
Share on other sites
Dr_TDM

@water @mrider @junkew  

 

thanks you all for replying,, @water i work with excel manually and i don't need to automate it,,,

@junkew the winactivate is the best solution,, thanks for the suggestion.. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.