Jump to content

Need som help (Really new to this)


Qslig
 Share

Recommended Posts

Hello!

And sorry for my bad english!

Im really new to autoit startet to learn some today and I made my first program

what the program does is that it close and program after a time you have entered

really cool :lmao: And it allso shutdown windows, I need help to make this program

"better" Becouse If you dont type in anything in the shutdown InputBox the program logoff the computer , and I allso need help with making an Count down box a box that will countdown in seconds (if possible) the time that you have entered and when that time is zero then it will close the program. And I allso need help to make the time you enter is in seconds (if possible), And help me to make the code "better" in all ways

but plz take it easy on me Im new at this program!

;Password
;--------------------------------------------------------------------------------------------------------------------------

HotKeySet("{ESC}", "close")
HotKeySet("+!s", "suprise")



$run = MsgBox(4, "ProcessTimeCloser v0.49b", "Starta ProcessTimeCloser?") 
If $run = 7 Then
    Exit
EndIf 


$passwd = InputBox("Lösenord", "Skriv in lösenordet. ESC stänger av det när det kör. & @CRLF & Shift+Alt+S visar en suprise :D", "", "*")

If $passwd = "banan" Then
msgbox(0, "Godkänt", "Weee :D", "")    
   ElseIF msgbox(0, "Error", "Fel Pass", "") THen
  Exit
 EndIF


;Answers
;-----------------------------------------------------------------------------------------------------------------------

$answer1 = InputBox("Namnet på processen", "Skriv in namnet på processen. (Exempel winamp.exe)")
$answer2 = InputBox("Tid", "Skriv in hur länge du vill att det ska ta innan programet stängs av i millisekunder. (Exempel1: 1000 = 1 sekund. Exempel2: 3600000 = 1 timma)")
$answer3 = InputBox("Shutdown", "Skriv in en av siffrona som står. Exemepl1: 1 <-- Stänger av datorn Exemepl2: 5 <-- Stänger av datorn oavsätt om det kommer upp ett error (Lämmna blankt om du vill fortfarande ha igång datorn)")

;Loading just for fun
;---------------------------------------------------------------
ProgressOn("Laddar", "Laddar inställningar", "0 Procent", "", "", 16)
For $laddar = 1 to 100 step 17
 sleep(1000)
 ProgressSet($laddar, $laddar & " Procent")

Next
ProgressSet(100, "Klart", "Laddningen är klar")
Sleep(500)
 ProgressOff() 

;Process
;---------------------------------------------------------------
If ProcessExists($answer1) Then
Sleep($answer2)
  Else
msgbox(0, "Error", "Processen finns inte", "")
 EndIf

If ProcessExists($answer1) Then
ProcessClose($answer1)
 EndIf

;Shutdown
;----------------------------------------------------------------
Shutdown($answer3)


;Funcs
;--------------------------------------------------------------------------------------------------------------------------

Func suprise()
If SoundPlay("C:\Windows\media\tada.wav") then
  sleep(1)
 Endif
If Msgbox(0, "Suprise :D", "Joel ©2005", "") = 1 Then
  $exit = MsgBox(4, "Tid Programet", "Stänga av?")
  ElseIf $exit = 6 Then
    Exit
  EndIf
Endfunc


Func close()
  $exit = MsgBox(4, "Tid Programet", "Stänga av?")
  If $exit = 6 Then
    Exit
  EndIf
EndFunc

~Best regards Joel

Edited by Qslig
Link to comment
Share on other sites

First suggestion is use the new GUI features in the beta release.

Link: http://autoitscript.com/autoit3/files/beta...it-v3.0.103.exe

Here is a better version of your current script though:

;Password
;--------------------------------------------------------------------------------------------------------------------------
HotKeySet("{ESC}", "close")
HotKeySet("+!s", "suprise")
If MsgBox(4, "ProcessTimeCloser v0.49b", "Starta ProcessTimeCloser?") = 7 Then Exit
If InputBox("Lösenord", "Skriv in lösenordet. ESC stänger av det när det kör." & @CRLF & "Shift+Alt+S visar en suprise :D", "", "*") = "banan" Then
    MsgBox(0, "Godkänt", "Weee :D", "")
Else
    MsgBox(0, "Error", "Fel Pass", "")
    Exit
EndIf
;Answers
;-----------------------------------------------------------------------------------------------------------------------
$answer1 = InputBox("Namnet på processen", "Skriv in namnet på processen. (Exempel winamp.exe)")
$answer2 = InputBox("Tid", "Skriv in hur länge du vill att det ska ta innan programet stängs av i millisekunder. (Exempel1: 1 = 1 sekund. Exempel2: 3600 = 1 timma)") * 1000
$answer3 = InputBox("Shutdown", "Skriv in en av siffrona som står. Exemepl1: 1 <-- Stänger av datorn Exemepl2: 5 <-- Stänger av datorn oavsätt om det kommer upp ett error (Lämmna blankt om du vill fortfarande ha igång datorn)")
;Loading just for fun
;---------------------------------------------------------------
ProgressOn("Laddar", "Laddar inställningar", "0 Procent", "", "", 16)
For $laddar = 100 To 1 Step -3
    Sleep(200)
    ProgressSet($laddar, $laddar & " Procent")
Next
ProgressSet(0, "Klart", "Laddningen är klar")
Sleep(800)
ProgressOff()
;Process
;---------------------------------------------------------------
If ProcessExists($answer1) Then
    Sleep($answer2)
Else
    MsgBox(0, "Error", "Processen finns inte", "")
EndIf
If ProcessExists($answer1) Then
    ProcessClose($answer1)
EndIf
;Shutdown
;----------------------------------------------------------------
Shutdown($answer3)
;Funcs
;--------------------------------------------------------------------------------------------------------------------------
Func suprise()
    If SoundPlay("C:\Windows\media\tada.wav") Then
        Sleep(1)
    EndIf
    If MsgBox(0, "Suprise :D", "Joel ©2005", "") = 1 Then
        If MsgBox(4, "Tid Programet", "Stänga av?") = 6 Then Exit
    EndIf
EndFunc  ;==>suprise
Func close()
    If MsgBox(4, "Tid Programet", "Stänga av?") = 6 Then Exit
EndFunc  ;==>close

Offering any help to anyone (to my capabilities of course)Want to say thanks? Click here! [quote name='Albert Einstein']Only two things are infinite, the universe and human stupidity, and I'm not sure about the former.[/quote][quote name='Wolvereness' date='7:35PM Central, Jan 11, 2005']I'm NEVER wrong, I call it something else[/quote]

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