Jump to content
Sign in to follow this  
Tigerweld

Help with storing varible and OK

Recommended Posts

Tigerweld

noob here, I'm stuck and don't know what to do next. I've looked at other examples but don't seem to understand the ok part. I'm trying to get input from the user and storing it as a string - can this be done? Anyways, here is my code. Thanks so much!

CODE
#include <GUIConstants.au3>

GUICreate("Printer Drivers")

GUICtrlCreateLabel("Select the printer model.", 10, 10)

$4000P = GUICtrlCreateRadio ("4000 Printer", 10, 40, 80, 30)

$4050P = GUICtrlCreateRadio ("4050 Printer", 10, 70, 80, 30)

GUICtrlCreateButton("OK", 10, 120, 30)

GUICtrlSetState ($4000P, $GUI_CHECKED)

GUISetState ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

ExitLoop

Case $msg = $4000P And BitAND(GUICtrlRead($4000P), $GUI_CHECKED) = $GUI_CHECKED

$Printer = ("c:\printerDrivers\4000\")

Case $msg = $4050P And BitAND(GUICtrlRead($4050P), $GUI_CHECKED) = $GUI_CHECKED

$Printer = ("c:\printerDrivers\4050\")

EndSelect

Wend

Share this post


Link to post
Share on other sites
Valuater

#include <GUIConstants.au3>

Global $Printer

GUICreate("Printer Drivers")

GUICtrlCreateLabel("Select the printer model.", 10, 10)
$4000P = GUICtrlCreateRadio("4000 Printer", 10, 40, 80, 30)
$4050P = GUICtrlCreateRadio("4050 Printer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($4000P, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($4000P) Then $Printer = "c:\printerDrivers\4000\"
            If _IsChecked($4050P) Then $Printer = "c:\printerDrivers\4050\"
            MsgBox(0x0, "Test", " You chose " & $Printer, 4)
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Tigerweld

cool beans! Now how do I make it exit when I click ok? :)

#include <GUIConstants.au3>

Global $Printer

GUICreate("Printer Drivers")

GUICtrlCreateLabel("Select the printer model.", 10, 10)
$4000P = GUICtrlCreateRadio("4000 Printer", 10, 40, 80, 30)
$4050P = GUICtrlCreateRadio("4050 Printer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($4000P, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($4000P) Then $Printer = "c:\printerDrivers\4000\"
            If _IsChecked($4050P) Then $Printer = "c:\printerDrivers\4050\"
            MsgBox(0x0, "Test", " You chose " & $Printer, 4)
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

8)

Share this post


Link to post
Share on other sites
Anonymouse

cool beans! Now how do I make it exit when I click ok? :)

#include <GUIConstants.au3>

Global $Printer

GUICreate("Printer Drivers")

GUICtrlCreateLabel("Select the printer model.", 10, 10)
$4000P = GUICtrlCreateRadio("4000 Printer", 10, 40, 80, 30)
$4050P = GUICtrlCreateRadio("4050 Printer", 10, 70, 80, 30)
$button = GUICtrlCreateButton("OK", 10, 120, 30)
GUICtrlSetState($4000P, $GUI_CHECKED)

GUISetState()


While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $button
            If _IsChecked($4000P) Then $Printer = "c:\printerDrivers\4000\"
            If _IsChecked($4050P) Then $Printer = "c:\printerDrivers\4050\"
            MsgBox(0x0, "Test", " You chose " & $Printer, 4)
            Exit ; is this what you mean?
    EndSelect
WEnd

Func _IsChecked($control)
    Return BitAND(GUICtrlRead($control), $GUI_CHECKED) = $GUI_CHECKED
EndFunc   ;==>_IsChecked

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)

Share this post


Link to post
Share on other sites
Tigerweld

ok I just put an EXIT after the msg. I assume that is ok right?

Share this post


Link to post
Share on other sites
Tigerweld

Hey if I place an EXIT it exits the script. I just want to close the form. What is the syntax for closing the for when I press OK?

Share this post


Link to post
Share on other sites
Anonymouse

Hey if I place an EXIT it exits the script. I just want to close the form. What is the syntax for closing the for when I press OK?

I believe you're looking for:

GUIDelete ( [winhandle] )

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)

Share this post


Link to post
Share on other sites
Tigerweld

Thanks, but how do I use that with an OK button?

Share this post


Link to post
Share on other sites
Anonymouse

Thanks, but how do I use that with an OK button?

GUIDelete deletes GUI. I'm on a friends lappy so I don't have autoit helpfile to back me up but I think

GUICtrlDelete?

It's usually the same thing for both... GUI = GUI Form & GUICtrl = GUI Control.

So if you use GuiCtrlCreate on it, usually it should be GUICtrl[sufix]

check the helpfile though, I may be wrong - Murphy knows it wouldn't be the first time. :P

[edit] you might not want to Delete it though, it might be more effecient to DISABLE it. look up disable in the helpfile, too. I like that function :)[/edit]

Edited by Anonymouse

children may smile; the wise ponder- Dr. Holmes of Hardvard Medical School on an Ether BingeLove Makes The World Go Round?So does five shots of tequila. What's your point?[quote name='Valik' date='Jun 5 2008, 05:13 PM']wraithdu, 24 hours. Said I have a bad attitude, just driving the point home with a ban.[/quote]This is classic. :)

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  

×