Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

how to simulate mouse movements every 5 minutes (without actually moving them)?


  • Please log in to reply
7 replies to this topic
techie108
  • Members
  • 250 posts
  • Last active: Jul 01 2017 06:17 AM
  • Joined: 05 Aug 2012

as above - is it possible to make the mouse pointer active every 5 minutes without the computer actually moving it (i.e. screen will be off - i don't want to wake it up, but i want all my other programs to think the user is still here). 

 

program is similar to the zen jiggle function here : 

 

https://mousejiggler.codeplex.com/

 

any guru knows how to code this in ahk? :)



techie108
  • Members
  • 250 posts
  • Last active: Jul 01 2017 06:17 AM
  • Joined: 05 Aug 2012

anyone knows?



Puttah
  • Members
  • 95 posts
  • Last active: Feb 17 2014 09:55 AM
  • Joined: 07 Nov 2009

It's quite simple really.

 

Try

min = 5 ;Number of minutes to wait

loop {
    sleep, % min*60*1000
    mousemove, 10, 0, 20, R
    mousemove, -10, 0, 20, R
}

If you need a better understanding of what's going on in each ilne, each function is explained in the autohotkey help.



techie108
  • Members
  • 250 posts
  • Last active: Jul 01 2017 06:17 AM
  • Joined: 05 Aug 2012

It's quite simple really.

 

Try

min = 5 ;Number of minutes to wait

loop {
    sleep, % min*60*1000
    mousemove, 10, 0, 20, R
    mousemove, -10, 0, 20, R
}

If you need a better understanding of what's going on in each ilne, each function is explained in the autohotkey help.

 

not exactly what i mentioned - because in this case, the computer DOES move the cursor. i'm looking for a solution where the cursor isn't moved, but all the apps think the user is active. also, it should not disrupt my work when i'm actually using it - that's the main thing i'm trying to avoid.



guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
well the program you posted, has the c# source code available at that link. so it should not be hard to translate at all.

the relevant parts:

https://mousejiggler...ggle/Jiggler.cs
        internal const int INPUT_MOUSE = 0;
        internal const int MOUSEEVENTF_MOVE = 0x0001; 

        public static void Jiggle (int dx, int dy)
        {
            INPUT inp = new INPUT();
            inp.TYPE = Jiggler.INPUT_MOUSE;
            inp.dx = dx;
            inp.dy = dy;
            inp.mouseData = 0;
            inp.dwFlags = Jiggler.MOUSEEVENTF_MOVE;
            inp.time = 0;
            inp.dwExtraInfo = (IntPtr)0;

            if (SendInput(1, ref inp, 28) != 1)
            {
                throw new Win32Exception();
            }
        }
https://mousejiggler...gle/MainForm.cs


        private void jiggleTimer_Tick(object sender, EventArgs e)
        {
            // jiggle
            if (cbZenJiggle.Checked)
            {
                Jiggler.Jiggle(0, 0);
            }
            else
            {
                if (zig)
                {
                    Jiggler.Jiggle(4, 4);
                }
so it looks like the "zen jiggle" only means that it moves the mouse to 0,0 each timer iteration? that seems fairly innocuous. maybe its the SendInput method of moving the mouse that causes the cursor to "not move" as you claim?

are you certain that this 'zen jiggle' feature does not move the mouse to 0,0 location of screen?

Seidenweber
  • Moderators
  • 638 posts
  • Last active: Sep 06 2015 01:51 PM
  • Joined: 10 May 2011

I'm using it that way to prevent a shut down before all backups are done

    SetTimer, FakeMe, 1000 ; check once a second
    Return

    FakeMe:
        If A_TimeIdlePhysical > 300000 ; 5 minutes since last REAL user action
            MouseMove,0,0,0,R ; mouse pointer stays in place but sends a mouse event
    Return

but it will wake up the screen.


All questions & answers are related to AHK 1.1.19.03 x64 Unicode

 


guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011

maybe its the SendInput method of moving the mouse that causes the cursor to "not move" as you claim?



it looks like this is the case

here is the MOUSEINPUT structure that is used for the SendInput call:

http://msdn.microsof...3(v=vs.85).aspx
 

MOUSEEVENTF_MOVE
0x0001
Movement occurred.

If the mouse has moved, indicated by MOUSEEVENTF_MOVE, dx and dy specify information about that movement. The information is specified as absolute or relative integer values.


from that wording, it seems that the MOUSEEVENTF_MOVE sends a message that the mouse has already finished moving?

guest3456
  • Members
  • 1704 posts
  • Last active: Nov 19 2015 11:58 AM
  • Joined: 10 Mar 2011
@techie108

i have no idea if this will work or not, please try it and see if the "computer thinks the mouse has moved" as you are attempting

i have tried to re-create the zenjiggle from the program you linked to
 
#NoEnv
#Persistent

   mins := 5

   SetTimer, ZenJiggle, % mins*60*1000

return


ZenJiggle:
   
   ;// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx
   VarSetCapacity(MOUSEINPUT, 28, 0)
   NumPut(0, MOUSEINPUT, 0) ;// type = 0 (INPUT_MOUSE)
   
   ;// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx
   NumPut(0, MOUSEINPUT, 4) ;// x = 0
   NumPut(0, MOUSEINPUT, 8) ;// y = 0
   NumPut(0, MOUSEINPUT, 12) ;// mouseData = 0
   NumPut(1, MOUSEINPUT, 16) ;// dwFlags = 1 (MOUSEEVENTF_MOVE)
   NumPut(0, MOUSEINPUT, 20) ;// time = 0
   NumPut(0, MOUSEINPUT, 24) ;// dwExtraInfo = 0
   
   ;// http://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx
   DllCall("SendInput", "UInt", 1, "UInt", &MOUSEINPUT, "Int", 28 )
   
return



if it doesn't work, maybe we'll need Lexikos or HotKeyIt or someone who's good with structs and the winapi to help out