Sign in to follow this  
Followers 0
meetrix

Inputbox

30 posts in this topic

Hi,

I am new to v3.I dont have much experience on how to do much. I have a project that I need help on. I need to know how many inputs can a window have? I need the user to input 3 difference piece of information all at the same time. Is this possible?

Share this post


Link to post
Share on other sites



Hi,

I am new to v3.I dont have much experience on how to do much. I have a project that I need help on. I need to know how many inputs can a window have? I need the user to input 3 difference piece of information all at the same time. Is this possible?

Yes, it is possible, but to my understanding you cannot do that without GUI (which unfortunatlyis my weakest Autoit area) check AutoIt 123 by valuator, that will help you

Also read the helpfile for GUIs

Share this post


Link to post
Share on other sites

I need to know how many inputs can a window have?

As many inputs that you can fit on the screen I guess.

What do you want the inputs to do?

#include <GuiConstants.au3>

GuiCreate("MyGUI", 178, 104,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("Input1", 10, 10, 130, 20)
$Input_2 = GuiCtrlCreateInput("Input2", 10, 40, 130, 20)
$Input_3 = GuiCtrlCreateInput("Input3", 10, 70, 130, 20)

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

Share this post


Link to post
Share on other sites

Welcome to the Forum! I got this information from the help file. It is loaded with helpful information on how to use AutoIt, and provides hunreds of examples.

Maximum length of a single script line: 4,095

Maximum string length: 2,147,483,647 characters

Number range (floating point): 1.7E308 to 1.7E+308 with 15-digit precision

Number range (integers): 64-bit signed integer

Hexadecimal numbers: 32-bit signed integer (0x80000000 to 0x7FFFFFFF)

Arrays: A maximum of 64 dimensions and/or a total of 16 million elements

Maximum depth of recursive function calls: 384 levels

Simultaneous open files: 64

Simultaneous active HotKeys: 64

Maximum number of variables in use at one time: No limit

Maximum number of user defined functions: No limit

Maximum number of GUI windows: 1024

Maximum number of GUI controls per window: 4096

Share this post


Link to post
Share on other sites

Hi bucky002,

Thank you for the information and example. What I need to do is set variables (strings) to capture the user input, than create a folder, sub-folder and save a file to that folders. Can you help? I would really appreciated. I will also do some homework on my one to try to figure it out. your example is a good start.

Thank you.

I need to know how many inputs can a window have?

As many inputs that you can fit on the screen I guess.

What do you want the inputs to do?

#include <GuiConstants.au3>

GuiCreate("MyGUI", 178, 104,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$Input_1 = GuiCtrlCreateInput("Input1", 10, 10, 130, 20)
$Input_2 = GuiCtrlCreateInput("Input2", 10, 40, 130, 20)
$Input_3 = GuiCtrlCreateInput("Input3", 10, 70, 130, 20)

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

Share this post


Link to post
Share on other sites

Thank you Paulie. I will check.

Yes, it is possible, but to my understanding you cannot do that without GUI (which unfortunatlyis my weakest Autoit area) check AutoIt 123 by valuator, that will help you

Also read the helpfile for GUIs

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

check out

Guictrlread

Dircreate

_filecreate

Filewrite and or Filewriteline

but u can make input boxes WITH OUT a gui

look up

inputbox in the help file

Edited by thatsgreat2345

Share this post


Link to post
Share on other sites

Thank you vollyman. I will refer to help files for a better understanding.

Welcome to the Forum! I got this information from the help file. It is loaded with helpful information on how to use AutoIt, and provides hunreds of examples.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Can give a little more information on what you want it to do?

I made this script, maybe it will help. What it does is whatever you type into the inputboxs it should save it to your desktop in an html in the subfolder of the folder.

#include <GuiConstants.au3>

GuiCreate("Inputs", 228, 103,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Input_1 = GuiCtrlCreateInput("", 10, 10, 130, 20)
$Input_2 = GuiCtrlCreateInput("", 10, 40, 130, 20)
$Input_3 = GuiCtrlCreateInput("", 10, 70, 130, 20)
$Send = GuiCtrlCreateButton("Send", 150, 40, 70, 20)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Send
        DirCreate(@DesktopDir & "\Folder")
        DirCreate(@DesktopDir & "\Folder\Subfolder")
        Sleep(500)
        $file = Fileopen(@DesktopDir & "\Folder\Subfolder\Inputs.html", 2)
        FileWriteLine($file, GUICtrlRead($Input_1))
        FileWriteLine($file, GUICtrlRead($Input_2) & @CRLF)
        FileWriteLine($file, GUICtrlRead($Input_3))
        FileClose($file)
        Exit
    Case Else
;;;
    EndSelect
WEnd
Exit
Edited by bucky002

Share this post


Link to post
Share on other sites

Hi bucky002,

Thank you for the script. I will try it and see if I can make it work with what I need it to do.

Here is what I need to do:

1. Have a window with tree inputs. The three inputs will be (Name, Company, and Serial Number).

2. Set a variable for each.(?) and when the variables are entered, I need them to verify them before they are save.

3. Once verified, I want to create a folder for the Name entered.

4. Once "Name" folder is created, I need to create a subfolder of the Company name.

5. Last I need to create a text log file of the Serial Number in the "Name\Company\Serial Number.log"

What do you think?

I have an example file attached for you to look at.

Thank,

Meetrix

Can give a little more information on what you want it to do?

I made this script, maybe it will help. What it does is whatever you type into the inputboxs it should save it to your desktop in an html in the subfolder of the folder.

#include <GuiConstants.au3>

GuiCreate("Inputs", 228, 103,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Input_1 = GuiCtrlCreateInput("", 10, 10, 130, 20)
$Input_2 = GuiCtrlCreateInput("", 10, 40, 130, 20)
$Input_3 = GuiCtrlCreateInput("", 10, 70, 130, 20)
$Send = GuiCtrlCreateButton("Send", 150, 40, 70, 20)

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Send
        DirCreate(@DesktopDir & "\Folder")
        DirCreate(@DesktopDir & "\Folder\Subfolder")
        Sleep(500)
        $file = Fileopen(@DesktopDir & "\Folder\Subfolder\Inputs.html", 2)
        FileWriteLine($file, GUICtrlRead($Input_1))
        FileWriteLine($file, GUICtrlRead($Input_2) & @CRLF)
        FileWriteLine($file, GUICtrlRead($Input_3))
        FileClose($file)
        Exit
    Case Else
;;;
    EndSelect
WEnd
Exit

UserInput.au3

Share this post


Link to post
Share on other sites

What do you mean by verify it? Make sure it's allowed or something? Or is this what you wanted?

#include <GuiConstants.au3>

GuiCreate("Arrow Electronics, INC.", 428, 190,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Name_1 = GuiCtrlCreateLabel("Scan Name:", 30, 50, 200, 20)
$Company_2 = GuiCtrlCreateLabel("Scan Company:", 30, 80, 210, 20)
$SN_3 = GuiCtrlCreateLabel("Scan Snum Number:", 30, 110, 220, 20)
$GetName_4 = GuiCtrlCreateInput("", 160, 50, 140, 20)
$GetCompany_5 = GuiCtrlCreateInput("", 160, 80, 140, 20)
$GetSN_6 = GuiCtrlCreateInput("", 160, 110, 140, 20)
$Group_7 = GuiCtrlCreateGroup("Customer Report Entry", 20, 20, 390, 140)
$ok = GUICtrlCreateButton ("Ok", 315,  50, 60, 20)
$exit = GUICtrlCreateButton ("Exit", 315, 80, 60, 20)

GUISetState () 

While 1 
    $msg = GUIGetMsg()
       Select
       Case $msg = $GUI_EVENT_CLOSE
           Exit
       Case $msg = $ok
        GUICtrlRead($GetCompany_5)
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4))
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5))
        Sleep(500)
        GUICtrlRead($GetSN_6)
        $file = Fileopen(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5) & "\" & GUICtrlRead($GetSN_6) & ".log", 2)
        Sleep(500)
        FileWriteLine($file, GUICtrlRead($GetName_4))
        FileWriteLine($file, GUICtrlRead($GetCompany_5) & @CRLF)
        FileWriteLine($file, GUICtrlRead($GetSN_6))
        FileClose($file)
        Exit
       Case $msg = $exit
         Exit  
       EndSelect
Wend

:think:

Share this post


Link to post
Share on other sites

Hi bucky002,

What I mean by verify, is that I want the user to verify that the data that they've entered is correct. Maybe they type the informatin instead of scanning, so if they mispelled their name, or entered the wrong serial number, I would like them to go back and edit their input.

For example:

- They enter the data, then click OK.

- I would like to add a message box that displays what they'd just enter and verify it.

- If data is correct, to click OK to proceed

- If data is incorrect, to go back and edit to make changes.

I would like the verification step to be first, before creating any folder or files.

Let me know what you think.

I appreciate all your help. With time I will learn and be able to help others.

Thank you,

Meetrix

What do you mean by verify it? Make sure it's allowed or something? Or is this what you wanted?

#include <GuiConstants.au3>

GuiCreate("Arrow Electronics, INC.", 428, 190,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Name_1 = GuiCtrlCreateLabel("Scan Name:", 30, 50, 200, 20)
$Company_2 = GuiCtrlCreateLabel("Scan Company:", 30, 80, 210, 20)
$SN_3 = GuiCtrlCreateLabel("Scan Snum Number:", 30, 110, 220, 20)
$GetName_4 = GuiCtrlCreateInput("", 160, 50, 140, 20)
$GetCompany_5 = GuiCtrlCreateInput("", 160, 80, 140, 20)
$GetSN_6 = GuiCtrlCreateInput("", 160, 110, 140, 20)
$Group_7 = GuiCtrlCreateGroup("Customer Report Entry", 20, 20, 390, 140)
$ok = GUICtrlCreateButton ("Ok", 315,  50, 60, 20)
$exit = GUICtrlCreateButton ("Exit", 315, 80, 60, 20)

GUISetState () 

While 1 
    $msg = GUIGetMsg()
       Select
       Case $msg = $GUI_EVENT_CLOSE
           Exit
       Case $msg = $ok
        GUICtrlRead($GetCompany_5)
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4))
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5))
        Sleep(500)
        GUICtrlRead($GetSN_6)
        $file = Fileopen(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5) & "\" & GUICtrlRead($GetSN_6) & ".log", 2)
        Sleep(500)
        FileWriteLine($file, GUICtrlRead($GetName_4))
        FileWriteLine($file, GUICtrlRead($GetCompany_5) & @CRLF)
        FileWriteLine($file, GUICtrlRead($GetSN_6))
        FileClose($file)
        Exit
       Case $msg = $exit
         Exit  
       EndSelect
Wend

:think:

Share this post


Link to post
Share on other sites

Well, I think I made the script you wanted, but there is an error in it I can't seem to get rid of. Hopefully someone with more experience will fix it.:think:

The error is $button_7 variable used without being declared. I'm so dumbfounded by it because the variable is declared as far as I know. It's probably an easy fix, but I couldn't figure it out.

#include <GuiConstants.au3>

GuiCreate("Arrow Electronics, INC.", 428, 190,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Name_1 = GuiCtrlCreateLabel("Scan Name:", 30, 50, 200, 20)
$Company_2 = GuiCtrlCreateLabel("Scan Company:", 30, 80, 210, 20)
$SN_3 = GuiCtrlCreateLabel("Scan Snum Number:", 30, 110, 220, 20)
$GetName_4 = GuiCtrlCreateInput("", 160, 50, 140, 20)
$GetCompany_5 = GuiCtrlCreateInput("", 160, 80, 140, 20)
$GetSN_6 = GuiCtrlCreateInput("", 160, 110, 140, 20)
$Group_7 = GuiCtrlCreateGroup("Customer Report Entry", 20, 20, 390, 140)
$ok = GUICtrlCreateButton ("Ok", 315,  50, 60, 20)
$exit = GUICtrlCreateButton ("Exit", 315, 80, 60, 20)

GUISetState () 

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $ok
        $Gui = GuiCreate("Verify", 329, 177,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
            GuiCtrlCreateLabel("Name:", 20, 20, 50, 20)
            GuiCtrlCreateLabel("Company:", 20, 60, 50, 20)
            GuiCtrlCreateLabel("Serial Number:", 20, 100, 70, 20)
            GuiCtrlCreateLabel(GUICtrlRead($GetName_4), 110, 20, 210, 20)
            GuiCtrlCreateLabel(GUICtrlRead($GetCompany_5), 110, 60, 210, 20)
            GuiCtrlCreateLabel(GUICtrlRead($GetSN_6), 110, 100, 210, 20)
            $Button_7 = GuiCtrlCreateButton("OK", 180, 140, 90, 30)
            $Button_8 = GuiCtrlCreateButton("Cancel", 60, 140, 90, 30)
            $msg = GuiGetMsg()
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_7
        GUICtrlRead($GetCompany_5)
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4))
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5))
        Sleep(500)
        GUICtrlRead($GetSN_6)
        $file = Fileopen(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5) & "\" & GUICtrlRead($GetSN_6) & ".log", 2)
        Sleep(500)
        FileWriteLine($file, GUICtrlRead($GetName_4))
        FileWriteLine($file, GUICtrlRead($GetCompany_5) & @CRLF)
        FileWriteLine($file, GUICtrlRead($GetSN_6))
        FileClose($file)
        Exit
    Case $msg = $Button_8
        GUIDelete($gui)
    Case Else
    ;;;
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

Hi Bucky002,

I appreciate all your help. I will run the script to test it. It has been an eye opener on how much I have left to learn about scripting. You have been a great help. Thank you for spending the time working on the script. I still have other things I have to add to it, but I think I will just to have try to learn it and try it. We will keep in touch.

Take care.

Meetrix

Well, I think I made the script you wanted, but there is an error in it I can't seem to get rid of. Hopefully someone with more experience will fix it.:think:

The error is $button_7 variable used without being declared. I'm so dumbfounded by it because the variable is declared as far as I know. It's probably an easy fix, but I couldn't figure it out.

#include <GuiConstants.au3>

GuiCreate("Arrow Electronics, INC.", 428, 190,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Name_1 = GuiCtrlCreateLabel("Scan Name:", 30, 50, 200, 20)
$Company_2 = GuiCtrlCreateLabel("Scan Company:", 30, 80, 210, 20)
$SN_3 = GuiCtrlCreateLabel("Scan Snum Number:", 30, 110, 220, 20)
$GetName_4 = GuiCtrlCreateInput("", 160, 50, 140, 20)
$GetCompany_5 = GuiCtrlCreateInput("", 160, 80, 140, 20)
$GetSN_6 = GuiCtrlCreateInput("", 160, 110, 140, 20)
$Group_7 = GuiCtrlCreateGroup("Customer Report Entry", 20, 20, 390, 140)
$ok = GUICtrlCreateButton ("Ok", 315,  50, 60, 20)
$exit = GUICtrlCreateButton ("Exit", 315, 80, 60, 20)

GUISetState () 

While 1
    $msg = GUIGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        Exit
    Case $msg = $ok
        $Gui = GuiCreate("Verify", 329, 177,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
            GuiCtrlCreateLabel("Name:", 20, 20, 50, 20)
            GuiCtrlCreateLabel("Company:", 20, 60, 50, 20)
            GuiCtrlCreateLabel("Serial Number:", 20, 100, 70, 20)
            GuiCtrlCreateLabel(GUICtrlRead($GetName_4), 110, 20, 210, 20)
            GuiCtrlCreateLabel(GUICtrlRead($GetCompany_5), 110, 60, 210, 20)
            GuiCtrlCreateLabel(GUICtrlRead($GetSN_6), 110, 100, 210, 20)
            $Button_7 = GuiCtrlCreateButton("OK", 180, 140, 90, 30)
            $Button_8 = GuiCtrlCreateButton("Cancel", 60, 140, 90, 30)
            $msg = GuiGetMsg()
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $msg = $Button_7
        GUICtrlRead($GetCompany_5)
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4))
        DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5))
        Sleep(500)
        GUICtrlRead($GetSN_6)
        $file = Fileopen(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5) & "\" & GUICtrlRead($GetSN_6) & ".log", 2)
        Sleep(500)
        FileWriteLine($file, GUICtrlRead($GetName_4))
        FileWriteLine($file, GUICtrlRead($GetCompany_5) & @CRLF)
        FileWriteLine($file, GUICtrlRead($GetSN_6))
        FileClose($file)
        Exit
    Case $msg = $Button_8
        GUIDelete($gui)
    Case Else
;;;
    EndSelect
WEnd

Share this post


Link to post
Share on other sites

#15 ·  Posted

Hi Bucky002,

I appreciate all your help. I will run the script to test it. It has been an eye opener on how much I have left to learn about scripting. You have been a great help. Thank you for spending the time working on the script. I still have other things I have to add to it, but I think I will just to have try to learn it and try it. We will keep in touch.

Take care.

Meetrix

Hi i'm wondering if you got the problem solved, if you did please post the result as i too have the same problem. Thanks

Share this post


Link to post
Share on other sites

#16 ·  Posted

The error you are getting is coming from this line

Case $msg = $Button_7

The reason for this is because $button7 is only created if the user first click okay, you're trying to check to see if the user clicks $Button_7 when it hasnt even been created yet. You have to move $Button_7 = GuiCtrlCreateButton("OK", 180, 140, 90, 30) out of the Case $msg = $ok block or else you will always receive this error.


_____________________________________________________"some people live for the rules, I live for exceptions"Wallpaper Changer - Easily Change Your Windows Wallpaper

Share this post


Link to post
Share on other sites

#17 ·  Posted (edited)

Fixed it. Thanks to Don N. :(

#include <GuiConstants.au3>
$gui = GUICreate("Arrow Electronics, INC.", 428, 190, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Name_1 = GUICtrlCreateLabel("Scan Name:", 30, 50, 200, 20)
$Company_2 = GUICtrlCreateLabel("Scan Company:", 30, 80, 210, 20)
$SN_3 = GUICtrlCreateLabel("Scan Snum Number:", 30, 110, 220, 20)
$GetName_4 = GUICtrlCreateInput("", 160, 50, 140, 20)
$GetCompany_5 = GUICtrlCreateInput("", 160, 80, 140, 20)
$GetSN_6 = GUICtrlCreateInput("", 160, 110, 140, 20)
$Group_7 = GUICtrlCreateGroup("Customer Report Entry", 20, 20, 390, 140)
$ok = GUICtrlCreateButton("Ok", 315, 50, 60, 20)
$exit = GUICtrlCreateButton("Exit", 315, 80, 60, 20)
$Gui2 = GUICreate("Verify", 329, 177, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), -1, $gui)
GUICtrlCreateLabel("Name:", 20, 20, 50, 20)
GUICtrlCreateLabel("Company:", 20, 60, 50, 20)
GUICtrlCreateLabel("Serial Number:", 20, 100, 70, 20)
GUICtrlCreateLabel(GUICtrlRead($GetName_4), 110, 20, 210, 20)
GUICtrlCreateLabel(GUICtrlRead($GetCompany_5), 110, 60, 210, 20)
GUICtrlCreateLabel(GUICtrlRead($GetSN_6), 110, 100, 210, 20)
$Button_7 = GUICtrlCreateButton("OK", 180, 140, 90, 30)
$Button_8 = GUICtrlCreateButton("Cancel", 60, 140, 90, 30)
GUISetState(@SW_SHOW, $gui)
GUISetState(@SW_HIDE, $Gui2)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $ok
            GUISetState(@SW_SHOW, $Gui2)
            GUICtrlCreateLabel(GUICtrlRead($GetName_4), 110, 20, 210, 20)
            GUICtrlCreateLabel(GUICtrlRead($GetCompany_5), 110, 60, 210, 20)
            GUICtrlCreateLabel(GUICtrlRead($GetSN_6), 110, 100, 210, 20)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_7
            GUICtrlRead($GetCompany_5)
            DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4))
            DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5))
            Sleep(500)
            GUICtrlRead($GetSN_6)
            $file = FileOpen(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5) & "\" & GUICtrlRead($GetSN_6) & ".log", 2)
            Sleep(500)
            FileWriteLine($file, GUICtrlRead($GetName_4))
            FileWriteLine($file, GUICtrlRead($GetCompany_5) & @CRLF)
            FileWriteLine($file, GUICtrlRead($GetSN_6))
            FileClose($file)
            Exit
        Case $msg = $Button_8
            GUISetState(@SW_HIDE, $Gui2)
        Case Else
    ;;;
    EndSelect
WEnd
:) Edited by bucky002

Share this post


Link to post
Share on other sites

Thank you. I almost lost hope with this script. I have been trying to make the another script work. With everyones help, I was able to put to this together, but the print section of the script is not working with the final setup. Can you take a look at it and let me know why it's giving me an ERROR: _FilePrint() already defined.

Func _FilePrint($File, $i_Show = @SW_HIDE)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

Here is what I have to far.

$Loop = 1

While $Loop = 1

$s_serial = InputBox("Kagoor Report File", "Scan Parent Serial Number."&@CRLF&"Then Click OK to proceed.")

If @error = 1 Then

$answer = MsgBox(4, "WARNING!", "You pressed 'Cancel', Do you want to Exit?")

If $answer = 6 Then

Exit

EndIf

Else

If $s_serial = "" Then

MsgBox(4096, "ERROR", "You Must Enter a Serial Number- try again!")

Else

$Loop = 0

EndIf

EndIf

WEnd

#include <file.au3>

#include <array.au3>

;Search for Serial Number and Create Report

$s_path = "C:\CustomerLogs\"

$a_filelist = _FileListToArray($s_path)

If (Not IsArray($a_filelist)) Then

MsgBox (0,"","No Files\Folders Found.")

Exit

EndIf

For $i = 0 to Ubound($a_filelist)-1

$a_searchresult = StringRegExp($a_filelist[$i],'('&$s_serial&'_[0-9]{1}_[0-9]{10}.log)',1)

If IsArray($a_searchresult) = 1 Then

MsgBox(0,"File Found!","File: "&$a_filelist[$i]&" Matches: "&$s_serial&@CRLF&"Copying to "&$s_path&$s_serial&".log",2)

FileCopy ( $s_path&$a_filelist[$i], $s_path&$s_serial&".log",1)

EndIf

Next

Exit

;$print = _FilePrint($s_path&$s_serial&".log")

;Print the Report file

$print = _FilePrint($s_path&$s_serial&".log")

;Print the Report file

Func _FilePrint($File, $i_Show = @SW_HIDE)

Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _

"hwnd", 0, _

"string", "print", _

"string", $File, _

"string", "", _

"string", "", _

"int", $i_Show)

If $a_Ret[0] > 32 And Not @error Then

Return 1

Else

SetError($a_Ret[0])

Return 0

EndIf

EndFunc

Again,

Thank you very much.

Fixed it. Thanks to Don N. :(

#include <GuiConstants.au3>
$gui = GUICreate("Arrow Electronics, INC.", 428, 190, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))
$Name_1 = GUICtrlCreateLabel("Scan Name:", 30, 50, 200, 20)
$Company_2 = GUICtrlCreateLabel("Scan Company:", 30, 80, 210, 20)
$SN_3 = GUICtrlCreateLabel("Scan Snum Number:", 30, 110, 220, 20)
$GetName_4 = GUICtrlCreateInput("", 160, 50, 140, 20)
$GetCompany_5 = GUICtrlCreateInput("", 160, 80, 140, 20)
$GetSN_6 = GUICtrlCreateInput("", 160, 110, 140, 20)
$Group_7 = GUICtrlCreateGroup("Customer Report Entry", 20, 20, 390, 140)
$ok = GUICtrlCreateButton("Ok", 315, 50, 60, 20)
$exit = GUICtrlCreateButton("Exit", 315, 80, 60, 20)
$Gui2 = GUICreate("Verify", 329, 177, -1, -1, BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS), -1, $gui)
GUICtrlCreateLabel("Name:", 20, 20, 50, 20)
GUICtrlCreateLabel("Company:", 20, 60, 50, 20)
GUICtrlCreateLabel("Serial Number:", 20, 100, 70, 20)
GUICtrlCreateLabel(GUICtrlRead($GetName_4), 110, 20, 210, 20)
GUICtrlCreateLabel(GUICtrlRead($GetCompany_5), 110, 60, 210, 20)
GUICtrlCreateLabel(GUICtrlRead($GetSN_6), 110, 100, 210, 20)
$Button_7 = GUICtrlCreateButton("OK", 180, 140, 90, 30)
$Button_8 = GUICtrlCreateButton("Cancel", 60, 140, 90, 30)
GUISetState(@SW_SHOW, $gui)
GUISetState(@SW_HIDE, $Gui2)
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            Exit
        Case $msg = $ok
            GUISetState(@SW_SHOW, $Gui2)
            GUICtrlCreateLabel(GUICtrlRead($GetName_4), 110, 20, 210, 20)
            GUICtrlCreateLabel(GUICtrlRead($GetCompany_5), 110, 60, 210, 20)
            GUICtrlCreateLabel(GUICtrlRead($GetSN_6), 110, 100, 210, 20)
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $Button_7
            GUICtrlRead($GetCompany_5)
            DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4))
            DirCreate(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5))
            Sleep(500)
            GUICtrlRead($GetSN_6)
            $file = FileOpen(@DesktopDir & "\" & GUICtrlRead($GetName_4) & "\" & GUICtrlRead($GetCompany_5) & "\" & GUICtrlRead($GetSN_6) & ".log", 2)
            Sleep(500)
            FileWriteLine($file, GUICtrlRead($GetName_4))
            FileWriteLine($file, GUICtrlRead($GetCompany_5) & @CRLF)
            FileWriteLine($file, GUICtrlRead($GetSN_6))
            FileClose($file)
            Exit
        Case $msg = $Button_8
            GUISetState(@SW_HIDE, $Gui2)
        Case Else
;;;
    EndSelect
WEnd
:)

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

1st. You forgot #include <File.au3> Edit: Saw you did put in File.au3. Sorry :)

2nd. You don't need to make

$print = _FilePrint($s_path&$s_serial&".log")
a variable. Because you never use $print in your code.

3rd. You do not need to put Func infront of

Func _FilePrint($File, $i_Show = @SW_HIDE)

If you look at the code File.au3 in your Include folder you would see that it is already has a func infront of it.

So what AutoIt saw was

Func Func _FilePrint($File, $i_Show = @SW_HIDE)
Hence getting your error. I think :(

Let me know if it works, because I never actually tried printing it, but there where no errors.

#include <File.au3>

$Loop = 1
While $Loop = 1
$s_serial = InputBox("Kagoor Report File", "Scan Parent Serial Number."&@CRLF&"Then Click OK to proceed.")
If @error = 1 Then
$answer = MsgBox(4, "WARNING!", "You pressed 'Cancel', Do you want to Exit?")
If $answer = 6 Then
Exit
EndIf
Else
If $s_serial = "" Then
MsgBox(4096, "ERROR", "You Must Enter a Serial Number- try again!")
Else
$Loop = 0
EndIf
EndIf
WEnd

#include <file.au3>
#include <array.au3>
;Search for Serial Number and Create Report
$s_path = "C:\CustomerLogs\"
$a_filelist = _FileListToArray($s_path)
If (Not IsArray($a_filelist)) Then
MsgBox (0,"","No Files\Folders Found.")
Exit
EndIf
For $i = 0 to Ubound($a_filelist)-1
$a_searchresult = StringRegExp($a_filelist[$i],'('&$s_serial&'_[0-9]{1}_[0-9]{10}.log)',1)
If IsArray($a_searchresult) = 1 Then
MsgBox(0,"File Found!","File: "&$a_filelist[$i]&" Matches: "&$s_serial&@CRLF&"Copying to "&$s_path&$s_serial&".log",2)
FileCopy ( $s_path&$a_filelist[$i], $s_path&$s_serial&".log",1)
EndIf
Next
Exit

;$print = _FilePrint($s_path&$s_serial&".log")
;Print the Report file
_FilePrint($s_path&$s_serial&".log")
;Print the Report file
_FilePrint($File, $i_Show = @SW_HIDE)
Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _
"hwnd", 0, _
"string", "print", _
"string", $File, _
"string", "", _
"string", "", _
"int", $i_Show)
If $a_Ret[0] > 32 And Not @error Then
Return 1
Else
SetError($a_Ret[0])
Return 0
EndIf

:D

Edited by bucky002

Share this post


Link to post
Share on other sites

When I run the script thi is what I get

C:\Program Files\AutoIt3\beta\Examples\ME.au3(42,17) : WARNING: $File: possibly used before declaration.

_FilePrint($File,

~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\beta\Examples\ME.au3(42,27) : WARNING: $i_Show: possibly used before declaration.

_FilePrint($File, $i_Show =

~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\beta\Examples\ME.au3(51,9) : ERROR: 'Return' not allowed from global scope.

Return 1

~~~~~~~~^

C:\Program Files\AutoIt3\beta\Examples\ME.au3(54,9) : ERROR: 'Return' not allowed from global scope.

Return 0

~~~~~~~~^

C:\Program Files\AutoIt3\beta\Examples\ME.au3(42,17) : ERROR: $File: undeclared global variable.

_FilePrint($File,

~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\beta\Examples\ME.au3(24,39) : ERROR: _FileListToArray(): undefined function.

$a_filelist = _FileListToArray($s_path)

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\beta\Examples\ME.au3(40,36) : ERROR: _FilePrint(): undefined function.

_FilePrint($s_path&$s_serial&".log")

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Program Files\AutoIt3\beta\Examples\ME.au3 - 5 error(s), 2 warning(s)

I will continue to try to see where the problem is. If anyone can help, I would appreciate.

Question for anyone:

When I post the scripts, it does not look organize, it looks all in line instead of a code. Why?

1st. You forgot #include <File.au3> Edit: Saw you did put in File.au3. Sorry :)

2nd. You don't need to make

$print = _FilePrint($s_path&$s_serial&".log")
a variable. Because you never use $print in your code.

3rd. You do not need to put Func infront of

Func _FilePrint($File, $i_Show = @SW_HIDE)

If you look at the code File.au3 in your Include folder you would see that it is already has a func infront of it.

So what AutoIt saw was

Func Func _FilePrint($File, $i_Show = @SW_HIDE)
Hence getting your error. I think :(

Let me know if it works, because I never actually tried printing it, but there where no errors.

#include <File.au3>

$Loop = 1
While $Loop = 1
$s_serial = InputBox("Kagoor Report File", "Scan Parent Serial Number."&@CRLF&"Then Click OK to proceed.")
If @error = 1 Then
$answer = MsgBox(4, "WARNING!", "You pressed 'Cancel', Do you want to Exit?")
If $answer = 6 Then
Exit
EndIf
Else
If $s_serial = "" Then
MsgBox(4096, "ERROR", "You Must Enter a Serial Number- try again!")
Else
$Loop = 0
EndIf
EndIf
WEnd

#include <file.au3>
#include <array.au3>
;Search for Serial Number and Create Report
$s_path = "C:\CustomerLogs\"
$a_filelist = _FileListToArray($s_path)
If (Not IsArray($a_filelist)) Then
MsgBox (0,"","No Files\Folders Found.")
Exit
EndIf
For $i = 0 to Ubound($a_filelist)-1
$a_searchresult = StringRegExp($a_filelist[$i],'('&$s_serial&'_[0-9]{1}_[0-9]{10}.log)',1)
If IsArray($a_searchresult) = 1 Then
MsgBox(0,"File Found!","File: "&$a_filelist[$i]&" Matches: "&$s_serial&@CRLF&"Copying to "&$s_path&$s_serial&".log",2)
FileCopy ( $s_path&$a_filelist[$i], $s_path&$s_serial&".log",1)
EndIf
Next
Exit

;$print = _FilePrint($s_path&$s_serial&".log")
;Print the Report file
_FilePrint($s_path&$s_serial&".log")
;Print the Report file
_FilePrint($File, $i_Show = @SW_HIDE)
Local $a_Ret = DllCall("shell32.dll", "long", "ShellExecute", _
"hwnd", 0, _
"string", "print", _
"string", $File, _
"string", "", _
"string", "", _
"int", $i_Show)
If $a_Ret[0] > 32 And Not @error Then
Return 1
Else
SetError($a_Ret[0])
Return 0
EndIf

:D

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