Sign in to follow this  
Followers 0
nivek

Check Box not working

14 posts in this topic

What am I missing? :D BTW: first GUI Script..

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

Opt("TrayAutoPause",0)

$Form1 = GUICreate("Folder Maker", 250, 130, 378, 159)
$Checkbox1 = GUICtrlCreateCheckbox("contract", 8, 64, 89, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Leases", 104, 64, 89, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Misc", 200, 64, 41, 17)
$Input1 = GUICtrlCreateInput("", 120, 8, 121, 21)
$Input2 = GUICtrlCreateInput("", 120, 32, 121, 21)
$Label1 = GUICtrlCreateLabel("Enter Company Name", 8, 8, 107, 17)
$Label2 = GUICtrlCreateLabel("Enter ID#", 8, 32, 83, 17)
$Button1 = GUICtrlCreateButton("Run", 16, 96, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            Start()
    EndSwitch
WEnd

Func Start()
  If $Checkbox1 = 0 Then
   FileMove("\\server\scan\contract\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " Contract.pdf")
  EndIf

  If $Checkbox2 = 0 Then
    FileMove("\\server\scan\leases\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " leases.pdf")
  EndIf

  If $Checkbox3 = 0 Then
    FileMove("\\server\scan\misc\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " misc.pdf")
  EndIf
EndFunc

Share this post


Link to post
Share on other sites



You are testing the ControlHandle in stead of the "value" of the Control. Use GuiCtrlRead().

Jos

Jos

I have gone back to the autoit help and forums, I am still confused on this.

can you give a little more help on this? :D

Share this post


Link to post
Share on other sites

Jos

I have gone back to the autoit help and forums, I am still confused on this.

can you give a little more help on this? :D

I meant something like this:

If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then

Does that make it any clearer ? :huggles:


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

nivek,

When you create a control in AutoIt, the control is given a unique identity - called the ControlID, This is what AutoIt uses to distinguish between all the controls on your GUI. We can go into a lot more detail but that is the short version. :D

So when you try and use what is in your inputs:

FileMove("\\server\scan\contract\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " Contract.pdf")

you are currently using the ControIDs of the input controls - not what is in them.

What you should do is this:

FileMove("\\server\scan\contract\*.pdf", GUICtrlRead($Input1) & "/" & GUICtrlRead($Input2) & "/" & GUICtrlRead($Input2) & " Contract.pdf")

Does that make sense? Please ask if you are still not sure - that is why we are here. :huggles:

M23


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

#6 ·  Posted (edited)

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

Opt("TrayAutoPause",0)

$Form1 = GUICreate("Folder Maker", 250, 130, 378, 159)
$Checkbox1 = GUICtrlCreateCheckbox("contract", 8, 64, 89, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Leases", 104, 64, 89, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Misc", 200, 64, 41, 17)
$Input1 = GUICtrlCreateInput("", 120, 8, 121, 21)
$Input2 = GUICtrlCreateInput("", 120, 32, 121, 21)
$Label1 = GUICtrlCreateLabel("Enter Company Name", 8, 8, 107, 17)
$Label2 = GUICtrlCreateLabel("Enter ID#", 8, 32, 83, 17)
$Button1 = GUICtrlCreateButton("Run", 16, 96, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            Start()
    EndSwitch
WEnd


Func Start()
    DirCreate($Input1)
    DirCreate($Input1 & "/" & $Input2)
    FileCopy("*.xlsx", $Input1 & "/" & $Input2 & "/Notes for " & $Input2 & ".xlsx")

    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then FileMove("\\server\scan\contract\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " Contract.pdf")
    If GUICtrlRead($Checkbox2) = $GUI_CHECKED Then FileMove("\\service-manager\scan\leases\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " leases.pdf")
    If GUICtrlRead($Checkbox3 = $GUI_CHECKED Then FileMove("\\service-manager\scan\misc\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " misc.pdf")

EndFunc

With this I get a folder called 6 with a folder called 7 inside.

Edited by nivek

Share this post


Link to post
Share on other sites

With this I get a folder called 6 with a folder called 7 inside.

Same issue as also Melba23 pointed out in the post above your last. :D

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

You got some fine replies from the Pros. That might have solved your problem already.

Being a beginner, too, I sometimes need to see Code snippets in a more 'step-by-step' like style.

So I hope you don't mind if I use your code with some addition just to make clear what you'll need to do.

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

Opt("TrayAutoPause", 0)

$Form1 = GUICreate("Folder Maker", 250, 130, 378, 159)
$Checkbox1 = GUICtrlCreateCheckbox("contract", 8, 64, 89, 17)
$Checkbox2 = GUICtrlCreateCheckbox("Leases", 104, 64, 89, 17)
$Checkbox3 = GUICtrlCreateCheckbox("Misc", 200, 64, 41, 17)
$Input1 = GUICtrlCreateInput("", 120, 8, 121, 21)
$Input2 = GUICtrlCreateInput("", 120, 32, 121, 21)
$Label1 = GUICtrlCreateLabel("Enter Company Name", 8, 8, 107, 17)
$Label2 = GUICtrlCreateLabel("Enter ID#", 8, 32, 83, 17)
$Button1 = GUICtrlCreateButton("Run", 16, 96, 75, 25, $WS_GROUP)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            Start()
    EndSwitch
WEnd


Func Start()
    
    ;Check state of your checkboxes, values are stored in these variables
    $ischecked1 = GUICtrlRead($Checkbox1)
    $ischecked2 = GUICtrlRead($Checkbox2)
    $ischecked3 = GUICtrlRead($Checkbox3)
    

    If $ischecked1 = 4 Then ;will return 4 if unchecked, 1 if checked, now you use the variables, not the ControlIDs
        MsgBox(0, "", "First Action")
        FileMove("\\server\scan\contract\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " Contract.pdf")
    EndIf

    If $ischecked2 = 4 Then
        FileMove("\\server\scan\leases\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " leases.pdf")
    EndIf

    If $ischecked3 = 4 Then
        FileMove("\\server\scan\misc\*.pdf", $Input1 & "/" & $Input2 & "/" & $Input2 & " misc.pdf")
    EndIf
EndFunc   ;==>Start

Regards,

Mike

Share this post


Link to post
Share on other sites

@mikesch,

Your snippet doesn't read the $inputx Controls and also still puts in the handles in the FileMove() commands.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

Mikesch,

You forgot about the Inputs....... :D

M23

P.S. But do not be put off - please help where you can. That is why we are all here, after all! :huggles:


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

$input1, $input2, $input3 are the names of your buttons and check boxes and stuff.

For autoit to use what a user enters, clicks and checks use GuictrlRead() to read what was entered into the control. The name of the button ($input1, $input2, $input3, etc.) goes inside of the ()

an example would be you have an input named $variablebox

user enters "duh" into the input.

you want to read the input of $variablebox (what the user entered)

GuictrlRead($variablebox) will return "duh"

however just $variableblebox (without the GuictrlRead) will return the internal number of the input.


010101000110100001101001011100110010000001101001011100110010000

001101101011110010010000001110011011010010110011100100001

My Android cat and mouse game
https://play.google.com/store/apps/details?id=com.KaosVisions.WhiskersNSqueek

We're gonna need another Timmy!

Share this post


Link to post
Share on other sites

Mikesch,

You forgot about the Inputs....... :D

M23

P.S. But do not be put off - please help where you can. That is why we are all here, after all! :huggles:

I'm not put off at all, just missed the last half hour's posts and thus a lot of meantime 'development', was busy on the phone ;-)

Mike

Share this post


Link to post
Share on other sites

This is the NON-GUI version And it works..

If Not IsDeclared("sInputBoxAnswer") Then Local $sInputBoxAnswer
$sInputBoxAnswer = InputBox("Folder Maker", "Enter Company Name", "", " M", "-1", "-1", "-1", "-1")
Select
    Case @error = 0
    Case @error = 1
    Case @error = 3

EndSelect

If Not IsDeclared("sInputBoxAnswer2") Then Local $sInputBoxAnswer2
$sInputBoxAnswer2 = InputBox("Folder Maker", "Enter Copier ID#", "", " M", "-1", "-1", "-1", "-1")
Select
    Case @error = 0 
    Case @error = 1 
    Case @error = 3 
EndSelect

DirCreate($sInputBoxAnswer)
DirCreate($sInputBoxAnswer & "/" & $sInputBoxAnswer2)
FileCopy("*.xlsx", $sInputBoxAnswer & "/" & $sInputBoxAnswer2 & "/Notes for " & $sInputBoxAnswer2 & ".xlsx")
FileMove("\\service-manager\scan\contract\*.pdf", $sInputBoxAnswer & "/" & $sInputBoxAnswer2 & "/" & $sInputBoxAnswer2 & " Contract.pdf")
FileMove("\\service-manager\scan\leases\*.pdf", $sInputBoxAnswer & "/" & $sInputBoxAnswer2 & "/" & $sInputBoxAnswer2 & " leases.pdf")
FileMove("\\service-manager\scan\misc\*.pdf", $sInputBoxAnswer & "/" & $sInputBoxAnswer2 & "/" & $sInputBoxAnswer2 & " misc.pdf")

It creates a folder with company name

then creates a folder with the id number as the name

then copies and renames the xlsx file to the id number folder

and so on...

Am I makeing this to complicated?

I just want to select if the script run one of the file moves or not...

Share this post


Link to post
Share on other sites

Hey..

Thank you for all of your help... You Guys are :D than me..

This morning my :) changed his mind :D on how he wanted the program to work...

YEA!!!! :

Thanks again,

nivek

PS: :huggles: was still having trouble with the check boxes...

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