Jump to content

Notepad Crash Monitor


Recommended Posts

Hello, I'm not sure if someone else has already made something like this but I thought it would be cool to share. I've made a script that watches your notepad and if it crashes it will save what information you've last put into a text file.

You make it monitor your document by having the window active, press F8 and then it's monitoring. If you decide to stop the monitoring you can close it by pressing END (Keeps program running just not monitoring anything) or ESC which closes the program. I thought it would be nice to make because things to crash a lot. I have only tested it on Notepad so if you want to test it on other stuff go ahead =P

Code:

TrayTip("", "Press F8 to start monitoring." & @CRLF & "Press ESC to exit." & @CRLF & "Press END to stop monitoring.", 1)

Global $Text = ""
Global $InUse = 0
Global $Win = ""

_Main()

Func _Main()
While 1
Sleep(10)
HotKeySet("{F8}", "_monitor")
HotKeySet("{ESC}", "_exit")
HotKeySet("{END}", "_stop")
WEnd
EndFunc

Func _monitor()
If $InUse = 0 Then
$InUse = 1
Global $Win = WinGetTitle("")
TrayTip("Monitoring", "Now monitoring: " & $Win, 1)
If WinActivate($Win) Then
While 1
    sleep(10)

    If Not WinExists($Win) Then
        If FileExists(@ScriptDir & "/" & $Win & ".txt") then
            FileOpen(@ScriptDir & "/" & $Win & ".txt", 2)
        EndIf
        FileWrite(@ScriptDir & "/" & $Win & ".txt", $Text)
        MsgBox(64, "Attention", "Saved text from crashed application: " & $Win & @CRLF & "Text saved in directory: " & @ScriptDir)
        TrayTip("Monitoring", "Monitoring has stopped.", 1)
        $InUse = 0
        ExitLoop
    Else
    If WinGetText($Win) <> "" Then
    $Text = WinGetText($Win)
    EndIf
EndIf
WEnd
Else
EndIf
Else
TrayTip("Monitoring", "Program is already monitoring: " & $Win, 1)
EndIf
EndFunc

Func _stop()
TrayTip("Monitoring", "Program has stopped monitoring: " & $Win, 1)
$InUse = 0
_Main()
EndFunc

Func _exit()
    Exit
EndFunc
Edited by Donald8282
Link to comment
Share on other sites

Nice post,

but,

-i cant C any tooltips...

-cant find the text located on mine desktop where it shoot be i qhues:S

-opening another tab isnt a crash :unsure:

hope u can do something whit this :>

as finishing touch god created the dutch

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...