Sign in to follow this  
Followers 0
dakota

buttons easy noob question

15 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

Share this post


Link to post
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

Share this post


Link to post
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

always show code

8)


NEWHeader1.png

Share this post


Link to post
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.


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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....

1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
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????

Share this post


Link to post
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

Share this post


Link to post
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))

Share this post


Link to post
Share on other sites

Please help :D:D

Share this post


Link to post
Share on other sites

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


[center]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.[/center]

Share this post


Link to post
Share on other sites

the tutorial does not work for me :D

Share this post


Link to post
Share on other sites

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=

[center]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.[/center]

Share this post


Link to post
Share on other sites

the tutorial does not work for me :D

I would like to know why

?????

8)


NEWHeader1.png

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