Jump to content

"do something" if the mouse is outside the gui while pressing the desired button.


kp3
 Share

Recommended Posts

I made this for some guy in the support forums... If annyone else would want it. Im posting it here.

Basicly, If u press space when the cursor is outside the gui named Test. Two message boxes appears. Everything is easy to change. But plz dont ask stupid questions!!!!

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=..\..\..\..\Documents and Settings\Robert Nilsson\Mina dokument\ledamp
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstants.au3>
#Include <Misc.au3>
hotkeyset("{space}","one")
Opt("GUIOnEventMode", 1)
$Form1 = GUICreate("Test", 633, 449, 193, 115)
$Label1 = GUICtrlCreateLabel("OMG! IT IS A GUI!!!!!!!!!!!!!!! WONDER WHAT HAPPENS IF I CLICK IT!!!!", 8, 32, 601, 28)
GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("nothing!", 56, 72, 44, 17)
GUISetState(@SW_SHOW)

;values that i dunno why they got to be here;
;end of those crappy values
While 1
    Sleep(100)
WEnd

;press space

func one()
    if winactive("Test") then          ;change winactive to whatever u want...If u want it even if the iwndow is hidden just remove it.
        $Pos = wingetpos("Test"); Get width, position, height and all that stuff of the windo
        $loc = mousegetpos(); get mouse position
            if $loc[1] <= $pos[1] or $loc[1] >= $pos[3]+$pos[1] or $loc[0] <= $pos[0] or $loc[0] >= $pos[2]+$pos[0] then;To make if thing so it continnues if u press inside the gui u should just invert the >:s
                msgbox("","YAY!","u pressed outside the gui")
                msgbox("","info","u pressed on x:"&$loc[0]&" y:"&$loc[1])
            endif
        endif
endfunc

[s]My scripts =)Password protect process (with tray menu lol)Clickous meousDisable ctrl+alt+del and password protect folder...Andous herous lolKp3s security center v.1Click me[/s]Ok... You shouldnt use annyone of them cuz they use alot of memory and contain alot of errors and stuff.. I was a n00b :P Ignore it... And if u for some reason want to use them... Watch out for my realy bad spelling :I

Link to comment
Share on other sites

The gui part is a bit unclear but the func is realy the only thing that matters.

[s]My scripts =)Password protect process (with tray menu lol)Clickous meousDisable ctrl+alt+del and password protect folder...Andous herous lolKp3s security center v.1Click me[/s]Ok... You shouldnt use annyone of them cuz they use alot of memory and contain alot of errors and stuff.. I was a n00b :P Ignore it... And if u for some reason want to use them... Watch out for my realy bad spelling :I

Link to comment
Share on other sites

ok

[quote]Baby you're all that I want, When you're lyin' here in my armsI'm findin' it hard to believe, We're in heavenAnd love is all that I need , And I found it there in your heartIt isn't too hard to see, We're in heaven .Bryan Adams[/quote].............................................................................[u]AUTOIT[/u]

Link to comment
Share on other sites

With this script you just can't MOVE your mouse cursor outside the window :rolleyes:

#include <GUIConstants.au3>

$Width = 400
$Height = 500

$GUI = GUICreate("Don't move your mouse outside this window",$Width,$Height)
GUISetState()

HotKeySet("{ESC}","esc")

While 1
    If WinActive($GUI) Then
    $a = GUIGetCursorInfo()
    
    $pos = MouseGetPos()
    
    $size = WinGetPos($GUI)
    
    If $a[0] < -5 Then
        MouseMove($size[0], $pos[1], 0)
    EndIf
    
    If $a[1] < -30 Then
        MouseMove($pos[0], $size[1], 0)
    EndIf
    
    If $pos[0] > $size[0]+$Width+9 Then
        MouseMove($size[0]+$Width+9, $pos[1], 0)
    EndIf
    
    If $pos[1] > $size[1]+$Height+33 Then
        MouseMove($pos[0], $size[1]+$Height+33, 0)
    EndIf
    EndIf
WEnd


Func esc()
    Exit
EndFunc
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...