Jump to content

Close the Window Game. Updated


qazwsx
 Share

Recommended Posts

Here is a little game i made where you have to try and close the Gui window. Once you close it the game tells you how many seconds it took you to do so. If you want to give up just push the "pause" button on your keyboard. Have fun. Updated now no esc or alt f4.

#include <GUIConstants.au3>
#include <misc.au3>
#include <date.au3>
AutoItSetOption("WinTitleMatchMode", 4)
Global $pos
Global $winpos
Global $handle
Global $bottomleft
GLobal $startpos
Global $end
Global $time
HotKeySet ("{pause}", "_endgame")
HotKeySet ("{esc}", "_cheater")

$begin = TimerInit ()
$taskbar = WinGetHandle ("[classe:Shell_TrayWnd", "")
WinSetState ($taskbar, "", @SW_HIDE)
WinKill ("[class:#32770]")



$Form1 = GUICreate("Game", 212, 61, 314, 201)
$Label1 = GUICtrlCreateLabel("Try to close me!!!", 0, 16, 206, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
WinWait ("Game")
$handle = WinGetHandle ("Game")
WinSetOnTop ($handle, "", 1)
_windowinfo ()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete ()
            $End = TimerDiff ($begin)
            $time = $end / 1000
            Msgbox (0, "Win", "You Won in " & $time & " Seconds")
            Exit
            
        Case Else
            _X ()
            If WinExists ("Windows Task Manager") Then 
                WinSetState ($handle, "", @SW_HIDE)
                Winkill ("Windows Task Manager")
                MsgBox (0, "Cheater", "No Cheating")
                WinSetState ($handle, "", @SW_SHOW)
            EndIf
            _X()
            If _IsPressed (02) Then
                WinSetState ($handle, "", @SW_HIDE)
                MsgBox (0, "Cheater", "No Right Clicking")
                WinSetState ($handle, "", @SW_SHOW)
            Endif
            _X()
            If _IsPressed (12) Then
                WinSetState ($handle, "", @SW_HIDE)
                MsgBox (0, "Cheater", "No cheating")
                WinSetState ($handle, "", @SW_SHOW)
            EndIf
            _X()
            _X()
    EndSwitch
WEnd


Func _X ()
    $pos = MouseGetPos ()
    If $pos[0] > $startpos[0] and $pos[0] < $bottomleft[0] and $pos[1] > $startpos[1] and $pos[1] < $bottomleft[1] Then
        WinMove ($handle, "", Random (0, 900), Random (0, 700))
        _windowinfo ()      
    Endif
    Sleep (1)
EndFunc



Func _windowinfo ()
    $startpos = Wingetpos ($handle)
$startpos[1] = $startpos[1] - 50
$bottomleft = Mousegetpos ()
$bottomleft[0] = $startpos[0] + $startpos[2] + 50
$bottomleft[1] = $startpos[1] + $startpos[3]
Endfunc

Func _cheater ()
            WinSetState ($handle, "", @SW_HIDE)
            MsgBox (0, "Cheater", "No Cheating")
            WinSetState ($handle, "", @SW_SHOW)
Endfunc



Func _endgame ()
    WinSetState ($taskbar, "", @SW_SHOW)
    WinSetState ($handle, "", @SW_HIDE)
    MsgBox (0, "Lost", "You lose")
    Exit
EndFunc

And Ashley's code

#include <GUIConstants.au3>
#include <misc.au3>
#include <date.au3>
#NoTrayIcon
AutoItSetOption("WinTitleMatchMode", 4)
Global $pos
Global $winpos
Global $handle
Global $bottomleft
GLobal $startpos
Global $end
Global $time
hotkeyset("{esc}" , "Donothing")
hotkeyset("{alt}" & "{F4}" , "Donothing")
hotkeyset("{F9}" , "Unlock")
hotkeyset("l" , "_endgame"); testing purposes
$begin = TimerInit ()
$taskbar = WinGetHandle ("[classe:Shell_TrayWnd", "")
WinSetState ($taskbar, "", @SW_HIDE)
WinKill ("[class:#32770]")
$Rcolor = Random( 0xFFFFFF, 0x2B1B1B1, 1000)
$change = Random( 0x5d6a42, 0x54f5891, 1)


$Form1 = GUICreate("Catch me", 212, 61, 314, 201)
$Label1 = GUICtrlCreateLabel("Try to close me!!!", 0, 16, 206, 36)
GUISetBkColor($Rcolor)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
WinWait ("Catch me")
$handle = WinGetHandle ("Catch me")
WinSetOnTop ($handle, "", 1)
_windowinfo ()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete ()
            $End = TimerDiff ($begin)
            $time = $end / 1000
            Msgbox (0, "Win", "You Won in " & $time & " Seconds")
            Exit
           
        Case Else
            _X ()
            If WinExists ("Windows Task Manager") Then
                WinSetState ($handle, "", @SW_HIDE)
                Winkill ("Windows Task Manager")
                MsgBox (0, "Cheater", "No Cheating")
                WinSetState ($handle, "", @SW_SHOW)
            EndIf
            If _IsPressed (02) Then
                WinSetState ($handle, "", @SW_HIDE)
                MsgBox (0, "Cheater", "No Right Clicking")
                WinSetState ($handle, "", @SW_SHOW)
            Endif
            _X()
            _X()
    EndSwitch
    GUISetBkColor($change)
    sleep(10)
    GUISetBkColor($Rcolor)
    Sleep(10)
    GUISetBkColor($change)
    sleep(10)
    GUISetBkColor($Rcolor)
    Sleep(10)
    GUISetBkColor($change)
    sleep(10)
    GUISetBkColor($Rcolor)
    Sleep(10)
   
WEnd


Func _X ()
    $pos = MouseGetPos ()
    If $pos[0] > $startpos[0] and $pos[0] < $bottomleft[0] and $pos[1] > $startpos[1] and $pos[1] < $bottomleft[1] Then
        WinMove ($handle, "", Random (0, 900), Random (0, 700))
        _windowinfo ()   
    Endif
    Sleep (1)
EndFunc



Func _windowinfo ()
    $startpos = Wingetpos ($handle)
$startpos[1] = $startpos[1] - 50
$bottomleft = Mousegetpos ()
$bottomleft[0] = $startpos[0] + $startpos[2] + 50
$bottomleft[1] = $startpos[1] + $startpos[3]

Endfunc


Func _endgame ()
    WinSetState ($taskbar, "", @SW_SHOW)
    MsgBox (0, "Lost", "You lose")
    Exit
EndFunc

Func Donothing ()

EndFunc

Func Unlock()
#NoTrayIcon
;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Pwd Char=*123, Mandatory
$password = "Password001"; Password needed to access script!
If Not IsDeclared("InputBoxAnswer") Then Local $InputBoxAnswer
$InputBoxAnswer = InputBox("cheatbox!","Please type in a password to access this program!","","*M","-1","-1","-1","-1")
Select
    Case @Error = 0;OK - The string returned is valid
        If $InputBoxAnswer = $password Then
            MsgBox(1024,"Password was correct!","You typed the correct Password. you ended this game by cheating!"); What to do if password was entered correctly!
            time()
        Else
            MsgBox(1024,"Password was wrong!","You typed the Wrong Password. You may not access this file!"); What to do if password was not entered correctly!
            Exit
        EndIf
   
    Case @Error = 1;The Cancel button was pushed
        MsgBox(1024,"You pressed the Cancel Button!","A Password is requuired to access this file!")
        Exit
   
    Case @Error = 3;The InputBox failed to open
   ;

EndSelect

EndFunc

Func time ()
    $End = TimerDiff ($begin)
            $time = $end / 1000
    Msgbox (0, "Win", "You Won in " & $time & " Seconds")
        GUIDelete ()
        Exit
EndFunc

Any suggestions on how to make the game more challenging are welcome.

1.au3

Edited by sccrstvn93
Link to comment
Share on other sites

Its not quite impossible i've done it a couple times. Sometime if u get lucky it will move under you mouse. Lol i never thought about alt f4 ill have to fix that.

heres the code to fix esc... theres an idea on how to stop it for using F4 but it dont work...

#include <GUIConstants.au3>
#include <misc.au3>
#include <date.au3>
#NoTrayIcon
AutoItSetOption("WinTitleMatchMode", 4)
Global $pos
Global $winpos
Global $handle
Global $bottomleft
GLobal $startpos
Global $end
Global $time
HotKeySet ("{pause}", "_endgame")
hotkeyset("{esc}" , "Donothing")
hotkeyset("{alt}" & "{F4}" , "Donothing")
hotkeyset("l" , "_endgame")
$begin = TimerInit ()
$taskbar = WinGetHandle ("[classe:Shell_TrayWnd", "")
WinSetState ($taskbar, "", @SW_HIDE)
WinKill ("[class:#32770]")



$Form1 = GUICreate("Game", 212, 61, 314, 201)
$Label1 = GUICtrlCreateLabel("Try to close me!!!", 0, 16, 206, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
WinWait ("Game")
$handle = WinGetHandle ("Game")
WinSetOnTop ($handle, "", 1)
_windowinfo ()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete ()
            $End = TimerDiff ($begin)
            $time = $end / 1000
            Msgbox (0, "Win", "You Won in " & $time & " Seconds")
            Exit
            
        Case Else
            _X ()
            If WinExists ("Windows Task Manager") Then 
                WinSetState ($handle, "", @SW_HIDE)
                Winkill ("Windows Task Manager")
                MsgBox (0, "Cheater", "No Cheating")
                WinSetState ($handle, "", @SW_SHOW)
            EndIf
            If _IsPressed (02) Then
                WinSetState ($handle, "", @SW_HIDE)
                MsgBox (0, "Cheater", "No Right Clicking")
                WinSetState ($handle, "", @SW_SHOW)
            Endif
            _X()
            _X()
    EndSwitch
WEnd


Func _X ()
    $pos = MouseGetPos ()
    If $pos[0] > $startpos[0] and $pos[0] < $bottomleft[0] and $pos[1] > $startpos[1] and $pos[1] < $bottomleft[1] Then
        WinMove ($handle, "", Random (0, 900), Random (0, 700))
        _windowinfo ()      
    Endif
    Sleep (1)
EndFunc



Func _windowinfo ()
    $startpos = Wingetpos ($handle)
$startpos[1] = $startpos[1] - 50
$bottomleft = Mousegetpos ()
$bottomleft[0] = $startpos[0] + $startpos[2] + 50
$bottomleft[1] = $startpos[1] + $startpos[3]
Endfunc


Func _endgame ()
    WinSetState ($taskbar, "", @SW_SHOW)
    MsgBox (0, "Lost", "You lose")
    Exit
EndFunc

Func Donothing ()

EndFunc

greate game... i won once

P.S Could be turned in to a nasty pop up that wont let you do anything untill its closed... and the pop up could be loaded at start up...

Link to comment
Share on other sites

I just fixed esc and alt f4 thx for the help.

just another update for you...

Also i added a cheat box press f to get it the cheet is 'password001' without the 's

so here it is

#include <GUIConstants.au3>
#include <misc.au3>
#include <date.au3>
#NoTrayIcon
AutoItSetOption("WinTitleMatchMode", 4)
Global $pos
Global $winpos
Global $handle
Global $bottomleft
GLobal $startpos
Global $end
Global $time
hotkeyset("{esc}" , "Donothing")
hotkeyset("{alt}" & "{F4}" , "Donothing")
hotkeyset("{F9}" , "Unlock")
hotkeyset("l" , "_endgame") ; testing purposes
$begin = TimerInit ()
$taskbar = WinGetHandle ("[classe:Shell_TrayWnd", "")
WinSetState ($taskbar, "", @SW_HIDE)
WinKill ("[class:#32770]")



$Form1 = GUICreate("Game", 212, 61, 314, 201)
$Label1 = GUICtrlCreateLabel("Try to close me!!!", 0, 16, 206, 36)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
WinWait ("Game")
$handle = WinGetHandle ("Game")
WinSetOnTop ($handle, "", 1)
_windowinfo ()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete ()
            $End = TimerDiff ($begin)
            $time = $end / 1000
            Msgbox (0, "Win", "You Won in " & $time & " Seconds")
            Exit
            
        Case Else
            _X ()
            If WinExists ("Windows Task Manager") Then 
                WinSetState ($handle, "", @SW_HIDE)
                Winkill ("Windows Task Manager")
                MsgBox (0, "Cheater", "No Cheating")
                WinSetState ($handle, "", @SW_SHOW)
            EndIf
            If _IsPressed (02) Then
                WinSetState ($handle, "", @SW_HIDE)
                MsgBox (0, "Cheater", "No Right Clicking")
                WinSetState ($handle, "", @SW_SHOW)
            Endif
            _X()
            _X()
    EndSwitch
WEnd


Func _X ()
    $pos = MouseGetPos ()
    If $pos[0] > $startpos[0] and $pos[0] < $bottomleft[0] and $pos[1] > $startpos[1] and $pos[1] < $bottomleft[1] Then
        WinMove ($handle, "", Random (0, 900), Random (0, 700))
        _windowinfo ()      
    Endif
    Sleep (1)
EndFunc



Func _windowinfo ()
    $startpos = Wingetpos ($handle)
$startpos[1] = $startpos[1] - 50
$bottomleft = Mousegetpos ()
$bottomleft[0] = $startpos[0] + $startpos[2] + 50
$bottomleft[1] = $startpos[1] + $startpos[3]
Endfunc


Func _endgame ()
    WinSetState ($taskbar, "", @SW_SHOW)
    MsgBox (0, "Lost", "You lose")
    Exit
EndFunc

Func Donothing ()

EndFunc

Func Unlock()
#NoTrayIcon
;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Pwd Char=*123, Mandatory
$password = "Password001"; Password needed to access script!
If Not IsDeclared("InputBoxAnswer") Then Local $InputBoxAnswer
$InputBoxAnswer = InputBox("cheatbox!","Please type in a password to access this program!","","*M","-1","-1","-1","-1")
Select
    Case @Error = 0;OK - The string returned is valid
        If $InputBoxAnswer = $password Then
            MsgBox(1024,"Password was correct!","You typed the correct Password. you ended this game by cheating!"); What to do if password was entered correctly!
            time()
        Else
            MsgBox(1024,"Password was wrong!","You typed the Wrong Password. You may not access this file!"); What to do if password was not entered correctly!
            Exit
        EndIf
    
    Case @Error = 1;The Cancel button was pushed
        MsgBox(1024,"You pressed the Cancel Button!","A Password is requuired to access this file!")
        Exit
    
    Case @Error = 3;The InputBox failed to open
    ;

EndSelect

EndFunc

Func time ()
    $End = TimerDiff ($begin)
            $time = $end / 1000
    Msgbox (0, "Win", "You Won in " & $time & " Seconds")
        GUIDelete ()
        Exit
EndFunc
Link to comment
Share on other sites

i updated my code...

Please post it updated on first post...

I made it realy flashy and enoying.. so now it like a pop up that you cant get rid of... you can still play it like a game

#include <GUIConstants.au3>
#include <misc.au3>
#include <date.au3>
#NoTrayIcon
AutoItSetOption("WinTitleMatchMode", 4)
Global $pos
Global $winpos
Global $handle
Global $bottomleft
GLobal $startpos
Global $end
Global $time
hotkeyset("{esc}" , "Donothing")
hotkeyset("{alt}" & "{F4}" , "Donothing")
hotkeyset("{F9}" , "Unlock")
hotkeyset("l" , "_endgame") ; testing purposes
$begin = TimerInit ()
$taskbar = WinGetHandle ("[classe:Shell_TrayWnd", "")
WinSetState ($taskbar, "", @SW_HIDE)
WinKill ("[class:#32770]")
$Rcolor = Random( 0xFFFFFF, 0x2B1B1B1, 1000)
$change = Random( 0x5d6a42, 0x54f5891, 1)


$Form1 = GUICreate("Catch me", 212, 61, 314, 201)
$Label1 = GUICtrlCreateLabel("Try to close me!!!", 0, 16, 206, 36)
GUISetBkColor($Rcolor)
GUICtrlSetFont(-1, 20, 400, 0, "MS Sans Serif")
GUISetState(@SW_SHOW)
WinWait ("Catch me")
$handle = WinGetHandle ("Catch me")
WinSetOnTop ($handle, "", 1)
_windowinfo ()

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            GUIDelete ()
            $End = TimerDiff ($begin)
            $time = $end / 1000
            Msgbox (0, "Win", "You Won in " & $time & " Seconds")
            Exit
            
        Case Else
            _X ()
            If WinExists ("Windows Task Manager") Then 
                WinSetState ($handle, "", @SW_HIDE)
                Winkill ("Windows Task Manager")
                MsgBox (0, "Cheater", "No Cheating")
                WinSetState ($handle, "", @SW_SHOW)
            EndIf
            If _IsPressed (02) Then
                WinSetState ($handle, "", @SW_HIDE)
                MsgBox (0, "Cheater", "No Right Clicking")
                WinSetState ($handle, "", @SW_SHOW)
            Endif
            _X()
            _X()
    EndSwitch
    GUISetBkColor($change)
    sleep(10)
    GUISetBkColor($Rcolor)
    Sleep(10)
    GUISetBkColor($change)
    sleep(10)
    GUISetBkColor($Rcolor)
    Sleep(10)
    GUISetBkColor($change)
    sleep(10)
    GUISetBkColor($Rcolor)
    Sleep(10)
    
WEnd


Func _X ()
    $pos = MouseGetPos ()
    If $pos[0] > $startpos[0] and $pos[0] < $bottomleft[0] and $pos[1] > $startpos[1] and $pos[1] < $bottomleft[1] Then
        WinMove ($handle, "", Random (0, 900), Random (0, 700))
        _windowinfo ()      
    Endif
    Sleep (1)
EndFunc



Func _windowinfo ()
    $startpos = Wingetpos ($handle)
$startpos[1] = $startpos[1] - 50
$bottomleft = Mousegetpos ()
$bottomleft[0] = $startpos[0] + $startpos[2] + 50
$bottomleft[1] = $startpos[1] + $startpos[3]

Endfunc


Func _endgame ()
    WinSetState ($taskbar, "", @SW_SHOW)
    MsgBox (0, "Lost", "You lose")
    Exit
EndFunc

Func Donothing ()

EndFunc

Func Unlock()
#NoTrayIcon
;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Pwd Char=*123, Mandatory
$password = "Password001"; Password needed to access script!
If Not IsDeclared("InputBoxAnswer") Then Local $InputBoxAnswer
$InputBoxAnswer = InputBox("cheatbox!","Please type in a password to access this program!","","*M","-1","-1","-1","-1")
Select
    Case @Error = 0;OK - The string returned is valid
        If $InputBoxAnswer = $password Then
            MsgBox(1024,"Password was correct!","You typed the correct Password. you ended this game by cheating!"); What to do if password was entered correctly!
            time()
        Else
            MsgBox(1024,"Password was wrong!","You typed the Wrong Password. You may not access this file!"); What to do if password was not entered correctly!
            Exit
        EndIf
    
    Case @Error = 1;The Cancel button was pushed
        MsgBox(1024,"You pressed the Cancel Button!","A Password is requuired to access this file!")
        Exit
    
    Case @Error = 3;The InputBox failed to open
    ;

EndSelect

EndFunc

Func time ()
    $End = TimerDiff ($begin)
            $time = $end / 1000
    Msgbox (0, "Win", "You Won in " & $time & " Seconds")
        GUIDelete ()
        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...