Jump to content

buttons easy noob question


Recommended Posts

how do i check to see if a button has been pressed my button variable is $filec if that has been pused i want it to do this

If Not IsDeclared("sInputBoxAnswer") Then Dim $sInputBoxAnswer
$sInputBoxAnswer = InputBox("gui","Path and file name to file:",$file," ","500","130","-1","-1")
Select
   Case @Error = 0;OK - The string returned is valid
$file = $sInputBoxAnswer
msgbox (0,"debug","file now is" $file )
   Case @Error = 1;The Cancel button was pushed

   Case @Error = 3;The InputBox failed to open

EndSelect

Please help

Link to comment
Share on other sites

1

you have errors

msgbox (0,"debug","file now is" $file )

should be

msgbox (0,"debug","file now is " & $file )

2

you are using the wrong message box... there is no cancel button

.........

So, take a look at

SiTE > Tools > CodeWizard

it will make the message boxes for you...

also

i would use

FileOpenDialog ( "title", "init dir", "filter" [, options [, "default name"]] )

to get the file... not the InputBox you made

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

i have a button in my gui and when it press it i want i to go to a function how would i do this

thinks for fixing my code :D:D

check out in the help file:

Opt("GUIOnEventMode",1)

and

GUICtrlSetOnEvent()

i personally prefer event mode versus message loop mode, but that's just me... in the 'gui reference' category of the help file, there are examples for using such controls regardless of which behavior you prefer.

Link to comment
Share on other sites

check out in the help file:

Opt("GUIOnEventMode",1)

and

GUICtrlSetOnEvent()

i personally prefer event mode versus message loop mode, but that's just me... in the 'gui reference' category of the help file, there are examples for using such controls regardless of which behavior you prefer.

very true...

i just wanted to see how far he got by displaying code with the button he mentioned (effort)

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

very true...

i just wanted to see how far he got by displaying code with the button he mentioned (effort)

8)

sorry, i've been busy with work stuff for a few weeks, so i'm trying to catch up on my 'helping people' quota. i did refrain from writing out new examples myself though....
Link to comment
Share on other sites

this is my code

#region --- GuiBuilder code Start ---
; Script generated by AutoBuilder 0.6 Prototype

#include <GuiConstants.au3>

GuiCreate("MyGUI", 314, 237,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$destination = @TempDir & "\guipick.gif"
FileInstall("C:\Documents and Settings\Dakota\Desktop\pick\guipick.gif", $destination)
;$Input_1 = GuiCtrlCreateInput("Input1", 10, 170, 280, 20)
;$Label_2 = GuiCtrlCreateLabel("Path and FileName (include extention)", 10, 150, 200, 20)
$Button_3 = GuiCtrlCreateButton("Open Log", 120, 200, 80, 30)
$filec = GuiCtrlCreateButton("Change File", 20, 200, 80, 30)
    GUICtrlSetOnEvent(1, "changefile")
$Pic_5 = GuiCtrlCreatePic("guipick.gif", 10, 20, 280, 120)
$done = GuiCtrlCreateButton("Done", 220, 200, 70, 30)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
    ;;;
    EndSelect
WEnd
Exit
#endregion --- GuiBuilder generated code End ---

func changefile()
#Region --- CodeWizard generated code Start ---

;InputBox features: Title=Yes, Prompt=Yes, Default Text=Yes, Width=500, Height=130
If Not IsDeclared("sInputBoxAnswer") Then Dim $sInputBoxAnswer
$sInputBoxAnswer = InputBox("gui","Path and file name to log file:",$file," ","500","130","-1","-1")
Select
   Case @Error = 0;OK - The string returned is valid
$file = $sInputBoxAnswer
msgbox (0,"debug","file now is" & $file )
   Case @Error = 1;The Cancel button was pushed

   Case @Error = 3;The InputBox failed to open

EndSelect
#EndRegion --- CodeWizard generated code End ---
endfunc

what is wrong with my button when i press it it does nothing????

Link to comment
Share on other sites

remove this

GUICtrlSetOnEvent(1, "changefile")

(that is for on event mode search help for "opt")

then place it in the while loop

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $filec
        changefile()
    Case Else
   ;;;
    EndSelect
WEnd

do the other buttons the same way

8)

NEWHeader1.png

Link to comment
Share on other sites

ok i am very confused this is what i do get: put the line that is checking to see if the button has been pushed into my loop ok got that but im comfused on what to put in there what do i use to cheak if the button has been pushed

So this is what i want to happen i want to push a button and have an input box pop up what i put into the box would be the file name and path (set the input box to a variable ($file))

Link to comment
Share on other sites

  • Moderators

Please help :D:D

Read the help file under GUICtrlCreateButton() in Beta, it shows you what you need to do, and take the tutorial in Valuaters signature and you'll answer alot of your current and future questions.

Initiative + Trial and Error = Self Satisfaction

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

the tutorial does not work for me :D

What doesn't work? Did you report it to Valuater? Try this tutorial by LxP: http://www.autoitscript.com/forum/index.ph...topic=19434&hl=

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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