Sign in to follow this  
Followers 0
oToom

Help with my script.

5 posts in this topic

#include <GUIConstants.au3>

Guicreate("[SA]", 169, 92)

$Start = GUICtrlCreateButton("Start", 10, 10, 150, 30)
$Stop = GUICtrlCreateButton("Stop", 10, 50, 150, 30)

Global $hWNd = WinGetTitle("Windows Live Messenger")

GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    
    Select 
        
        Case $Msg = $Start
            while 1 
                If $hWnd Then
                    WinClose($hWnd)
                Else
                    Sleep(30000)
                EndIf
            WEnd 
                
        Case $Msg = $Stop
            GUIDelete()
            Exit    
        
    EndSelect
        
WEnd

Well that is my script so far.

What i am tring to do is, my sister broke her laptop, and is bugging me none stop to use msn on my computer.

What i want to do is click the start button, and it will constantly check until the window, Windows Live Messenger is found, then close msn. Is this the correct way of going about it?

Cheers guys.

Share this post


Link to post
Share on other sites

BUMP

Help please.

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>

Guicreate("[SA]", 169, 92)

$Start = GUICtrlCreateButton("Start", 10, 10, 150, 30)
$Stop = GUICtrlCreateButton("Stop", 10, 50, 150, 30)

Global $hWNd = WinGetTitle("Windows Live Messenger")

GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    
    Select 
        
        Case $Msg = $Start
            while 1 
                If $hWnd Then
                    WinClose($hWnd)
                Else
                    Sleep(30000)
                EndIf
            WEnd 
                
        Case $Msg = $Stop
            GUIDelete()
            Exit    
        
    EndSelect
        
WEnd

Well that is my script so far.

What i am tring to do is, my sister broke her laptop, and is bugging me none stop to use msn on my computer.

What i want to do is click the start button, and it will constantly check until the window, Windows Live Messenger is found, then close msn. Is this the correct way of going about it?

Cheers guys.

You are evil to your sister... just like me :)

I think this will do it:

#include <GUIConstants.au3>

Guicreate("[SA]", 169, 92)

$Start = GUICtrlCreateButton("Start", 10, 10, 150, 30)
$Stop = GUICtrlCreateButton("Stop", 10, 50, 150, 30)

GUISetState(@SW_SHOW)

While 1
    $Msg = GUIGetMsg()
    
    Select 
        
        Case $Msg = $Start
            while 1 
                WinWaitActive("Windows Live Messenger")
                    WinClose("Windows Live Messenger")
                Else
                    Sleep(30000)
                EndIf
            WEnd 
                
        Case $Msg = $Stop
            GUIDelete()
            Exit    
        
    EndSelect
        
WEnd

Have not tested it though.


[font="Courier New"]This sentence is a lie. Or is it?[/font]Better leave AutoIt then

Share this post


Link to post
Share on other sites

#include <GUIConstants.au3>
Global $loop = True
Guicreate("[SA]", 169, 92)
$Start = GUICtrlCreateButton("Start", 10, 10, 150, 30)
$exit = GUICtrlCreateButton("Exit", 10, 50, 150, 30)
GUISetState(@SW_SHOW)
While 1
    $Msg = GUIGetMsg()
    Select
        Case $Msg = $Start
            _checkForMsn()
        Case $Msg = $exit
            Exit
        case $Msg = $GUI_EVENT_CLOSE
            Exit
    EndSelect
WEnd
func _checkForMsn()
    GUICtrlSetData($Start, "Stop")
    While 1
        $Msg = GUIGetMsg()
        Select
            Case $Msg = $Start
                GUICtrlSetData($Start, "Start")
                ExitLoop
            Case $Msg = $exit
                Exit
            case $Msg = $GUI_EVENT_CLOSE
                Exit
        EndSelect
        $hWNd = WinGetTitle("Windows Live Messenger")
        if $hWnd then
            WinClose($hWnd)
;~          ExitLoop
        EndIf
    WEnd
EndFunc

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Haavy, thank you, Works perfects.

sandin, also works fine. Yet Haavy's is alot easier so i will go for his. Thank you both!

EDIT: I got rid of the GUI so she cannot see it =p

Edited by oToom

Share this post


Link to post
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
Sign in to follow this  
Followers 0