Jump to content

Close Window


Recommended Posts

Hello,

I made a program that automates some Windows tasks. I let a windows appear and then the user can take the right action. If they click a button the right action starts. But When the right action is done, then the windows still exists. So it doesn't close. I already tried WinKill and ExitLoop.

Link to comment
Share on other sites

HI,

may you show the script code?

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

OK, here it is:

#include <GUIConstants.au3>

HotKeySet("{F2}", "Terminate")


WinWaitActive("Habbo ~ Habbo Hotel - ")
Sleep(5000)
Send("Hey, welkom bij de Quiz-O-Matic {ENTER}")
Sleep(5000)
Send("Het spel gaat over een paar seconden beginnen {ENTER}")
Sleep(3500)
Send("Zit iedereen? Dan gaan we beginnen {ENTER}")
Sleep(1000)

MouseClick("left", 619, 419, 2)
MouseClick("left", 699, 532, 1)
Sleep(3800)
MouseClick("left", 620, 406, 2)
Sleep(4000)
;tellers
MouseClick("left", 681, 499, 2)
MouseClick("left", 716, 528, 1)
MouseClick("left", 730, 475, 2)
MouseClick("left", 700, 535, 2)
Sleep(1000)

;vragen
Get_Line()
Sleep(10000)

GUICreate("Winnaar", 170, 40) ; will create a dialog box that when displayed is centered
$left = GUICtrlCreateButton("links", 10, 10)
$cnt = GUICtrlCreateButton("niemand", 60, 10)
$right = GUICtrlCreateButton("rechts", 120, 10)
GUISetState (@SW_SHOW)    ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
Case $msg = $left
    MouseClick("left", 701, 533, 1)
    Sleep(1000)
    MouseClick("left", 685, 544, 1)
    Winkill("Winnaar")
Case $msg = $right
    MouseClick("left", 718, 528, 1)
    Sleep(1000)
    MouseClick("left", 733, 519, 1)
    Winkill("Winnaar")
Case $msg = $cnt
    Winkill("Winnaar")  
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
endselect   
Wend
Link to comment
Share on other sites

Try something like this.

For the creation of the little GUI :

$winnaar = GUICreate("Winnaar", 170, 60,-1,-1, $WS_DLGFRAME, $WS_EX_TOPMOST)

and when it has to diseappear :

GUIDelete($winnaar)

looks like this :

...
$winnaar = GUICreate("Winnaar", 170, 60,-1,-1, $WS_DLGFRAME, $WS_EX_TOPMOST) ; will create a dialog box that when displayed is centered
$left = GUICtrlCreateButton("links", 10, 10)
$cnt = GUICtrlCreateButton("niemand", 60, 10)
$right = GUICtrlCreateButton("rechts", 120, 10)
GUISetState (@SW_SHOW)      ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $left
            MouseClick("left", 701, 533, 1)
            Sleep(1000)
            MouseClick("left", 685, 544, 1)
            GUIDelete($winnaar)
            ;Winkill("Winnaar")
        Case $msg = $right
            MouseClick("left", 718, 528, 1)
            Sleep(1000)
            MouseClick("left", 733, 519, 1)
            GUIDelete($winnaar)
            ;Winkill("Winnaar")
        Case $msg = $cnt
            GUIDelete($winnaar)
            ;Winkill("Winnaar")    
    endselect 
Wend
...

Veel succes ermee :D

Edited by Gyzmok
D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
Link to comment
Share on other sites

I tried it, but it doesn't work. Althought not for more then one time. This is the whole script:

#include <GUIConstants.au3>

HotKeySet("{F2}", "Terminate")


WinWaitActive("Habbo ~ Habbo Hotel - ")
Sleep(5000)
Send("Hey, welkom bij de Quiz-O-Matic {ENTER}")
Sleep(5000)
Send("Het spel gaat over een paar seconden beginnen {ENTER}")
Sleep(3500)
Send("Zit iedereen? Dan gaan we beginnen {ENTER}")
Sleep(1000)

MouseClick("left", 619, 419, 2)
MouseClick("left", 699, 532, 1)
Sleep(3800)
MouseClick("left", 620, 406, 2)
Sleep(4000)
;tellers
MouseClick("left", 681, 499, 2)
MouseClick("left", 716, 528, 1)
MouseClick("left", 730, 475, 2)
MouseClick("left", 700, 535, 2)
Sleep(1000)

;vragen
;/;/;/;/;/;/;/;/;/;/
Get_Line()
Sleep(10000)

$winnaar = GUICreate("Winnaar", 170, 60,-1,-1, $WS_DLGFRAME, $WS_EX_TOPMOST)
$left = GUICtrlCreateButton("links", 10, 10)
$cnt = GUICtrlCreateButton("niemand", 60, 10)
$right = GUICtrlCreateButton("rechts", 120, 10)
GUISetState (@SW_SHOW)    ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
Case $msg = $left
    MouseClick("left", 701, 533, 1)
    Sleep(1000)
    MouseClick("left", 685, 544, 1)
    GUIDelete($winnaar)
Case $msg = $right
    MouseClick("left", 718, 528, 1)
    Sleep(1000)
    MouseClick("left", 733, 519, 1)
    GUIDelete($winnaar)
Case $msg = $cnt
    GUIDelete($winnaar)
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
endselect   
Wend

Get_Line()
Sleep(10000)

$winnaar = GUICreate("Winnaar", 170, 60,-1,-1, $WS_DLGFRAME, $WS_EX_TOPMOST)
$left = GUICtrlCreateButton("links", 10, 10)
$cnt = GUICtrlCreateButton("niemand", 60, 10)
$right = GUICtrlCreateButton("rechts", 120, 10)
GUISetState (@SW_SHOW)    ; will display an empty dialog box

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    Select
Case $msg = $left
    MouseClick("left", 701, 533, 1)
    Sleep(1000)
    MouseClick("left", 685, 544, 1)
    GUIDelete($winnaar)
Case $msg = $right
    MouseClick("left", 718, 528, 1)
    Sleep(1000)
    MouseClick("left", 733, 519, 1)
    GUIDelete($winnaar)
Case $msg = $cnt
    GUIDelete($winnaar)
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
endselect   
Wend
;/;/;/;/;/;/;/;/;/;/
FileDelete(@TempDir & "\temp.ini")

While 1
    ToolTip("Druk op F2 om de HABBO Quiz Bot te stoppen")
WEnd
Func Get_Line()
    If Not FileExists(@TempDir & "\temp.ini") Then FileCopy(@ScriptDir & "\text.ini", @TempDir & "\temp.ini", 1)
    $last = "used"
    $count = 0
    While $last = "used"
        $count = $count + 1
        If $count = 20 Then ExitLoop
        $rand = Random(1, 20, 1)
        $last = IniRead(@TempDir & "\temp.ini", "text", $rand, "")
        Sleep(10)
    WEnd
    IniWrite(@TempDir & "\temp.ini", "text", $rand, "used")
    Send($last)
EndFunc ;==>Get_Line
FileDelete(@TempDir & "\temp.ini")

Func Terminate()
    FileDelete(@TempDir & "\temp.ini")
    Exit 0
EndFunc

The code that's between the ;/;/;/;/;/;/;/;/;/;/ signs must be repeated 10 times. But the current code won't allow me to run it more then one time. I don't know what's wrong?

Link to comment
Share on other sites

Hmm I see...

Your problem is :

You never get out of the first While 1 ... Wend loop

In each case you need an Exitloop

Using 10 times the same code should be in a loop like this :

for $i = 1 to 10 step 1

...

next

example : try something like this

...
for $i = 1 to 10 step 1
    Get_Line()
    Sleep(10000)
    $winnaar = GUICreate("Winnaar", 170, 60,-1,-1, $WS_DLGFRAME, $WS_EX_TOPMOST) ; will create a dialog box that when displayed is centered
    $left = GUICtrlCreateButton("links", 10, 10)
    $cnt = GUICtrlCreateButton("niemand", 60, 10)
    $right = GUICtrlCreateButton("rechts", 120, 10)
    GUISetState (@SW_SHOW)      ; will display an empty dialog box
    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $left
                MouseClick("left", 701, 533, 1)
                Sleep(1000)
                MouseClick("left", 685, 544, 1)
                GUIDelete($winnaar)
                ExitLoop
            Case $msg = $right
                MouseClick("left", 718, 528, 1)
                Sleep(1000)
                MouseClick("left", 733, 519, 1)
                GUIDelete($winnaar)
                ExitLoop
            Case $msg = $cnt
                GUIDelete($winnaar)
                ExitLoop 
        endselect 
    Wend
Next
...

Ik hoop dat dit terug een stap in de goede richting is ...

Niet opgeven ! :D

D2charkeeper = No more 'expired characters' in D2.File Date Changer = Change the file date(s), attributes and the filename case of multiple files @ once.Updater_full = Copy/Update your autoitscripts, pictures, .mp3, .avi etc ... subdirs from your PC to your memory stick or to your external harddisk. Now with scheduling and logging.Questmapper
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...