Sign in to follow this  
Followers 0
yousefsamy

what's the problem with this code shutdown !!

16 posts in this topic

#1 ·  Posted (edited)

here in my code i want it to force restart then i type this :

Here is my Full Code

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Form1_1 = GUICreate("Timer V1.1", 285, 149, 192, 124)
GUISetBkColor(0x99B4D1)
$Combo1 = GUICtrlCreateCombo("ShutDown", 16, 8, 241, 25, BitOR($GUI_SS_DEFAULT_COMBO,$CBS_SIMPLE))
GUICtrlSetFont(-1, 10, 400, 0, "Impact")
GUICtrlSetColor(-1, 0xFFFFFF)
GUICtrlSetBkColor(-1, 0x6D6D6D)
$start = GUICtrlCreateButton("Start", 152, 48, 129, 97)
$Label1 = GUICtrlCreateLabel("Mins", 24, 64, 51, 31)
GUICtrlSetFont(-1, 16, 400, 0, "Neo Tech Alt Medium")
$Input1 = GUICtrlCreateInput("", 24, 96, 105, 32, BitOR($GUI_SS_DEFAULT_INPUT,$ES_NUMBER))
GUICtrlSetFont(-1, 14, 400, 0, "MS Sans Serif")
GUICtrlSetData( $Combo1 , "Restart |Log off")
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $start
            $t = GUICtrlRead($Input1)
            $c = GUICtrlRead($Combo1)
            If $c = "Shutdown" Then
                Sleep( $t * 60000 )

                Shutdown(5)
            ElseIf $c = "Restart" Then
                Sleep( $t * 60000 )

                Shutdown(6)
            ElseIf $c = "Log off" Then
                Sleep( $t * 60000 )

                Shutdown(4)
                EndIf


    EndSwitch
WEnd
Edited by yousefsamy

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

How about showing all of your GUI creation? Without seeing all of your code, or at least a decent reproducer, you're asking us to first guess at what you're trying to do and then troubleshoot it for you. Help us help you.

 

Edit: And while this is the most important thing in the world to you, adding more exclamation points to your titles doesn't get it noticed any faster.

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

ok i reedit it ... full source now  :sweating:

Share this post


Link to post
Share on other sites

force reboot ==> shutdown(6) no result for this code !! why 

Share this post


Link to post
Share on other sites

In your GUICtrlSetData you have a space after Restart. In your If statement you do not. So this:

ElseIf $c = "Restart" Then

will never resolve. You need to delete the space in your GUICtrlSetData line.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

really shutdown and log off are working except restart which i dont know why it didnt work with me ^_^ not with spaces 

Share this post


Link to post
Share on other sites

I just explained why it didn't work. What is your question?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

my question is why only code of restart not working ??  :ermm:

Share this post


Link to post
Share on other sites

yousefsamy,

You have already been told. Your present code:

GUICtrlSetData( $Combo1 , "Restart |Log off")
You have an extra space after "Restart so the comparison ElseIf $c = "Restart" Then will never be true.

Change the line to read:

GUICtrlSetData( $Combo1 , "Restart|Log off")
and it will work. ;)

M23

1 person likes this

Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

oh my god ,,, my eyes are very weak nowadays    :sweating:

Share this post


Link to post
Share on other sites

I thought that is what I said, guess I should have included pictures like Melba :)


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
JLogan3o13,,

you have told me another reason 

you told me here is the wrong  ===>  

  1. ElseIf $c = "Restart" Then
 
but no it's in another place 

 ,,

Share this post


Link to post
Share on other sites

Look, I realize that English is not your native tongue, as I stated in my reply to your uncalled for but tolerated since you weren't asking me for help PM, and as stated in at least one other post here, but you are going to have to think out your words more carefully in the posts you make here. The code fixing answers that JLogan3o13 and Melba23 made in this thread are pretty much exactly the same. The only difference is JLogan3o13 saying what needs to be done, and Melba23 showing you the unworking code and the working code.

Now don't take this as me flaming you, I'm not trying, or doing, that. I realize that the world is a big place, and English is not everybody's first language. However, this forum's primary, and only, language is English. :)

1 person likes this

- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

Share this post


Link to post
Share on other sites

oh it's okay bro ^_^

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