Jump to content
Sign in to follow this  
dmegalo

Prompt To Exit Program Help

Recommended Posts

dmegalo

I wrote this little bit to keep machines from going on standby. It's short & sweet but I would rather launch a user prompt once the script is initiated that stays up until the user clicks OK. The point of the user prompt will be to click OK to exit the program (called mousemover.exe). Currently I set a hotkey to exit the program. Any help is or suggestions will be appreciated. Thank you. My script follows.

; Script Start

HotKeySet("x", "_exit")

While 1

MouseMove(10, 15, 25)

MouseMove(15, 10, 25)

Sleep(60000)

MouseMove(10, 15, 25)

MouseMove(15, 10, 25)

WEnd

Func _exit()

Exit 1

EndFunc

; End Of Script

Share this post


Link to post
Share on other sites
ChrisL

Hi

Was bored so played with this a little.

This has a GUI window which gets moved by the mouse every 30 seconds then possitions the mouse ready for you to click the button to kill it, it still kind of acts as a screen saver by moving the window.

#include <GuiConstants.au3>
opt ("GuiOnEventmode",1)

GuiCreate("Staying Alive", 232, 95,-1, -1 , BitOR($DS_MODALFRAME, $WS_CAPTION ))

$Button_1 = GuiCtrlCreateButton("Quit Mouse Mover", 20, 10, 190, 70)
GUICtrlSetOnEvent(-1, "_exit")

GuiSetState()
WinSetOnTop ( "Staying Alive", "", 1 )
HotKeySet("x", "_exit")

While 1

Sleep(30000)
WinSetOnTop ( "Staying Alive", "", 1 )
$pos = WinGetPos ( "Staying Alive" )
$newX = Random ( 5, (@DesktopWidth - $pos[2]) - 5)
$newY = Random ( 5, (@DesktopHeight - $pos[3]) -5) 
MouseClickDrag ( "Left", $pos[0]+ 5, $pos[1] + 5, $newX , $newY )
MouseMove ($newX + 115, $newY + 80)
WEnd

Func _exit()
Exit 1
EndFunc
Edited by ChrisL

Share this post


Link to post
Share on other sites
dmegalo

Thanks ChrisL. You hit this one on the nose. Exactly what I was looking for. Works like a charm. I'll post the final product (now called staying alive in tribute to you) in scripts and scraps. Muchas Gracias.

Share this post


Link to post
Share on other sites
ChrisL

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
Sign in to follow this  

×