Jump to content

help!!!!!!


Recommended Posts

I am just learning basic commands with autoit. Here is what i am trying to do. I need a script to keep the screen alive with mouse movement. After 4 hours if the mouse has not moved out of the mouse patern that was set it will kill the application rsntmain.exe and close. If the mouse is moved out of that pattern then i want to reset the 4 hour clock. Any help would be awesome. I have seen many scripts but non of them have all these features.  I found this if any of this can help please let me know.

#Region ;**** Directives created by AutoIt3Wrapper_GUI ****

#AutoIt3Wrapper_icon=H:IconsClock.ico
#AutoIt3Wrapper_outfile=H:ProjectsAutoItNoSleep.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=Prevents your computer from locking or going to screensaver as it normally would when idle
#AutoIt3Wrapper_Res_Description=Prevents your computer from locking or going to screensaver as it normally would when idle
#AutoIt3Wrapper_Res_Fileversion=1.0.0.0
#AutoIt3Wrapper_Res_LegalCopyright=Copyright Mike Langford ©2009
#AutoIt3Wrapper_Res_Language=1033
#AutoIt3Wrapper_Run_AU3Check=n
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
Opt("TrayOnEventMode",1)
Opt("TrayMenuMode",1)
 
$AboutItem = TrayCreateItem("About")
TrayItemSetOnEvent(-1,"ReadList")
TrayCreateItem("")
$ExitItem = TrayCreateItem("Exit")
TrayItemSetOnEvent(-1,"ReadList")
 
Func ReadList()
$SelectedItem = TrayItemGetText(@TRAY_ID)
If $SelectedItem="Exit" Then
Exit
ElseIf $SelectedItem="About" Then
Call("About")
EndIf
EndFunc
 
 
Func About()
MsgBox(064,"No Sleep Utility","Prevents your computer from automatically locking or going to screen saver as it normally would." & @CRLF & "Copyright Mike Langford ©2009")
EndFunc
 
 
While 1
Sleep(30000)
$CurPos = MouseGetPos ( )
MouseMove ( $CurPos[0] + 1, $CurPos[1] )
MouseMove ( $CurPos[0] - 1, $CurPos[1] )
WEnd

 

Link to comment
Share on other sites

  • Moderators

Hi, vargac, welcome to the forum. A couple of things:

  • Please provide a more descriptive title - this is a Help forum, so just putting Help!!! doesn't tell us anything.
  • Why don't you just modify the settings on the computer to never go to sleep?
  • What is rsntmain.exe? Perhaps it would be simpler to write code that will keep the computer awake as long as that process is active.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Seems odd and counter-intuitive from a computer security standpoint.

Here's the logic I would use.

Create Counter variable (clock)

Set mouse to static position (0,0)

Do

Giggle Mouse and Return to 0,0

Wait for desired period

Check if mouse is at 0,0

If Not

Reset Counter

Else

Increment Counter

If Counter has reached end limit (four hours) Exit Loop

Loop

Link to comment
Share on other sites

Hi Jlogan3o13. Sorry about the Title. These computers are on a domain. Rsntmain is the application. The script i posted keeps the computer alive infinetly. I want to time out after 4 hours if the mouse does not move out of that position. If it does move i want the clock to restart the count down to program closing. Any Help would be awesome.

Link to comment
Share on other sites

  • Moderators

Do you need to check where the mouse is? Something simple like this will make the mouse blip (very fast) every 3.5 hours, regardless of whether it has moved or not.

$x = MouseGetPos(0)
$y = MouseGetPos(1)

    While 1
        MouseMove(1, 1, 0)
        Sleep(100)
        MouseMove($x, $y, 0)
        Sleep(10800000)
    WEnd

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

I need to keep the mouse moving every 5 min because the time out on the workstations go to screen saver and no matter what i have tryed they go to it due to group policy. Every 5 min i need the mouse to move on pixel left one pixel right. then after 4 hours of this if they dont move it from that pixel patter i want the application to shut down. but if they do move the mouse i want it to start the count down clock again.

Link to comment
Share on other sites

I think he wanted to track the mouse location to determine if a user moved it so as to reset the "clock".

Of course it will not be reliable if for some reason the user returns the mouse to the location as I described (slim, but could happen).

Maybe a random mouse location would be better?

Edited by spudw2k
Link to comment
Share on other sites

  • Moderators

In that case, just change what I have in post #7 to 5 minutes. Every 5 minutes it will move the mouse and then move it back, so fast most would not even notice. Then you don't have to worry about the 4 hour time limit.

Edit: You could even move the MouseGetPos inside the While loop. That way, it determines where the mouse is first, and then returns it to that position. If a user happens to be doing something, it would move and then move back to where they are.

While 1
        $x = MouseGetPos(0)
        $y = MouseGetPos(1)
        
        MouseMove(1, 1, 0)
        Sleep(100)
        MouseMove($x, $y, 0)
        Sleep(1800000)
    WEnd
Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Have a look in the help file for Random, @DesktopWidth, @DesktopHeight and TimerInit. Those on top of the mouse move commands can accomplish your desired task.

Try to play with some code and post what you've come up with. We'll help you from there and you'll learn how to code in AutoIt better than being handed a working solution.

Edited by spudw2k
Link to comment
Share on other sites

While 1
   $x = MouseGetPos(0)
   $y = MouseGetPos(1)
   
   MouseMove(1, 1, 0)
   Sleep(100)
   MouseMove($x, $y, 0)
   Sleep(14400000)
If ProcessExists("rsntmain.exe") Then
   ProcessClose("rsntmain.exe")
End
Link to comment
Share on other sites

  • Moderators

The way you have it right now, it will follow this pattern:

  • get the current Mouse x and y positions
  • Move the mouse to 1, 1
  • Wait 100 ms
  • Move the mouse back to the previous position
  • Wait 4 hours
  • Close process if it is there
  • Loop back to the beginning

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Here's a fully functioning script that will move the mouse 10 pixels every 4 minutes, for up to 4 hours, then exits itself.

I have also included a hotkey (Shift + ESC) that will allow you to quickly exit the script. I used 10 pixels because, on my computer at least, 1 pixel wasn't enough movement. The moves are instantaneous so you don't even see the mouse moving.

I have included a ToolTip in the code, but that's only for testing and letting you know it's running, you'd probably want to remove that from the script otherwise it might get very annoying.

HotKeySet("+{ESC}", "Escape")
Global $aMousePos
Global $Timer1 = TimerInit()
Global $i4Hours = 14400000 ; 4 hours in ms
Global $Timer2 = TimerInit()
Global $i4Minutes = 240000, $bExit = False
While TimerDiff($Timer1) < $i4Hours
    If TimerDiff($Timer2) >= $i4Minutes Then
        $aMousePos = MouseGetPos()
        MouseMove($aMousePos[0] + 10, $aMousePos[1] + 10, 0)
        MouseMove($aMousePos[0], $aMousePos[1], 0)
        $Timer2 = TimerInit()
        ToolTip("Mouse Moved")
        Sleep(1000)
        ToolTip("")
    EndIf
    If $bExit then ExitLoop
    Sleep(1000)
WEnd
ToolTip("Exiting script")
sleep(1000)
ToolTip("")
Func Escape()
    $bExit = True
EndFunc

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Link to comment
Share on other sites

Looks like Brewman did the heavy lifting for you.  The last piece would be a check to see if the mouse moved by the user in order to reset the clock or not (if I understood your original request).  This could be accomplished by having a second variable to store the MouseGetPos array and compare the two. 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...