Jump to content

If mouse is at the top left corner of the screen


Recommended Posts

Hello,
I've tried to make a notepad application to writing notes slightly easier. What I want to do is when I hover my mouse on the top left of the screen a function will be done. It doesn't seem to work. And is it possible to know if the user tries to close the notepad? Like : If X button is pressed: Do this ?

#include <Constants.au3>

$s = "(1, 1)"
if $s = Mousegetpos() then Example()



Func Example()
   $PASSWORD = InputBox("PASSWORD","TYPE HERE PASSWORD","AutoIt","*")
   Run("notepad.exe")
EndFunc


while 1
   sleep(1000)
wend

 

Edited by lawonama
Link to comment
Share on other sites

You could do something like this:

 

#include <Constants.au3>

Local $aPos = 0

While Sleep(500)
    $aPos = MouseGetPos()
    If IsArray($aPos) Then
        If $aPos[0] = 0 And $aPos[1] = 0 Then Example()
    EndIf
WEnd

Func Example()
    $PASSWORD = InputBox("PASSWORD", "TYPE HERE PASSWORD", "AutoIt", "*")
    Run("notepad.exe")
EndFunc   ;==>Example

Saludos

Link to comment
Share on other sites

Here is what I came up with.

AdlibRegister("_CheckMouse")

Local $iMouseDelay = 1 ;Seconds to Hold Mouse
Local $iNotepadClose = 1 ;1 - Closed   0 - Open
If ProcessExists("Notepad.exe") Then $iNotepadClose = 0

While 1
    Sleep(10)
    If $iNotepadClose = 1 Then
        If ProcessExists("Notepad.exe") Then $iNotepadClose = 0
    EndIf
    If $iNotepadClose = 0 Then
        If Not ProcessExists("Notepad.exe") Then
            $iNotepadClose = 1
            _DetectedClose()
        EndIf
    EndIf
WEnd

Func _CheckMouse()
    $aPOS = MouseGetPos()
    If IsArray($aPOS) Then
        If $aPos[0]+$aPos[1] = 0 Then
            Sleep($iMouseDelay*1000)
            $aPOS = MouseGetPos()
            If $aPos[0]+$aPos[1] = 0 Then _Example()
        EndIf
    EndIf
EndFunc

Func _Example()
    $sOpenPrompt = InputBox("", "Enter Password", "", "*")
    If $sOpenPrompt = "password" Then Run("notepad.exe")
EndFunc

Func _DetectedClose()
    MsgBox(0, "", "Notepad was just closed")
EndFunc

 

Edited by ViciousXUSMC
Link to comment
Share on other sites

Amazing! Thanks to both of you guys. This is amazing!

Is it also possible to use the inserted password as the title of the notepad when you close it, and save it to My Documents > Create map called $sOpenPrompt and save it as "Todays Date + $sOpenPrompt"

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