Jump to content

Using This And Using That To Make Something


Recommended Posts

But can't say I'm having to much luck .

I have this from a post and then added the last part on to try and save it to a file and open in notepad but get a error after the search ?

;Generated with AutoBuilder 0.3

Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)

GuiCreate("MyGUI", 484,439,10,10,0x04CF0000)
$button_1 = GUISetControl("button", "test b", 20,20, 70,20)
$button_2 = GUISetControl("button", "Button 2", 20,50, 70,20)
$button_3 = GUISetControl("button", "Button 3", 20,90, 70,20)
$input_1 = GUISetControl("input", "Input 1", 210,30, 250,310)
$input_2 = GUISetControl("input", "Input 2", 210,350, 250,30)
$date_1 = GUISetControl("date", "Date 1", 340,400, 90,20)
$date_2 = GUISetControl("date", "Date 2", 30,440, 0,0)
$pic_1 = GUISetControl("Pic1", "Pic1.bmp", 20,140, 170,240)
GuiShow()

While 1
    sleep(100)
    $msg = GuiMsg(0)
    Select
    Case $msg = -3
  Exit
    Case $msg = $button_1
    ProgressOn("Progress Meter", "Increments every second", "0 percent")
For $i = 10 to 100 step 10
    sleep(1000)
    ProgressSet( $i, $i & " percent")
Next
ProgressSet(100 , "Done", "Complete")
sleep(500)
ProgressOff()

    ;;;
    Case $msg = $button_2
    $file = FileOpen("results.txt", 0)

; Check if file opened for reading OK
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
Func _ColorGetGreen( $nColor )
  Return BitAnd( BitShift( $nColor, 8 ), 0xff )
EndFunc
; Read in 1 character at a time until the EOF is reached
While 1
    $chars = FileRead($file,2000)
    If @error = -1 Then ExitLoop
    $input_1(0, "Char read:", $chars)
Wend

FileClose($file)
    ;;;
    Case $msg = $button_3
Run("search.exe", "", @SW_MAXIMIZE)
    ;;;
    Case $msg = $input_1
    $file = FileOpen("results.txt", 0)

    ;;;
    Case $msg = $input_2
    ;;;
    Case $msg = $date_1
    ;;;
    Case $msg = $date_2
    ;;;
    Case $msg = $pic_1
    ;;;
    EndSelect
WEnd
Exit

Ok what I did was made a search.exe and that runs and makes a results.txt

so i want to read that in to the $input_1 box but I get this error ? How can I fix this so I can learn how this code works as I have read almost every back post here in support and the help file too . but I'm not having a very good time with this .

help please .

---------------------------

AutoIt Error

---------------------------

Line 42 (File "E:\Programs\AutoIt3\Examples\English\gui_test2three_buttons.au3"):

Func _ColorGetGreen( $nColor )

Error: "While" statement has no matching "Wend" statement.

Edited by bobheart
Link to comment
Share on other sites

you should check out Tidy, it's a cool little app that someone here wrote to cleanup code, it also points out some errors when you run it... check out the lines beginning with ";### Tidy Error"

edit: that someone is JdeB and you could check it out and also check out SciTE over in Scripts and Scraps or use this search like I did

;Generated with AutoBuilder 0.3

Opt("GUICoordMode", 1)
Opt("GUINotifyMode", 1)

GuiCreate("MyGUI", 484,439,10,10,0x04CF0000)
$button_1 = GUISetControl("button", "test b", 20,20, 70,20)
$button_2 = GUISetControl("button", "Button 2", 20,50, 70,20)
$button_3 = GUISetControl("button", "Button 3", 20,90, 70,20)
$input_1 = GUISetControl("input", "Input 1", 210,30, 250,310)
$input_2 = GUISetControl("input", "Input 2", 210,350, 250,30)
$date_1 = GUISetControl("date", "Date 1", 340,400, 90,20)
$date_2 = GUISetControl("date", "Date 2", 30,440, 0,0)
$pic_1 = GUISetControl("Pic1", "Pic1.bmp", 20,140, 170,240)
GuiShow()

While 1
   sleep(100)
   $msg = GuiMsg(0)
   Select
      Case $msg = -3
         Exit
      Case $msg = $button_1
         ProgressOn("Progress Meter", "Increments every second", "0 percent")
         For $i = 10 to 100 step 10
            sleep(1000)
            ProgressSet( $i, $i & " percent")
         Next
         ProgressSet(100 , "Done", "Complete")
         sleep(500)
         ProgressOff()
         
        ;;;
      Case $msg = $button_2
         $file = FileOpen("results.txt", 0)
         
        ; Check if file opened for reading OK
         If $file = -1 Then
            MsgBox(0, "Error", "Unable to open file.")
            Exit
         EndIf
;### Tidy Error: Level error -> Func cannot be inside any IF/Do/While/For/Case/Func statement.
         Func _ColorGetGreen( $nColor )
            Return BitAnd( BitShift( $nColor, 8 ), 0xff )
         EndFunc  ;==>_ColorGetGreen
        ; Read in 1 character at a time until the EOF is reached
         While 1
            $chars = FileRead($file,2000)
            If @error = -1 Then ExitLoop
            $input_1(0, "Char read:", $chars)
         Wend
         
         FileClose($file)
        ;;;
         Case $msg = $button_3
            Run("search.exe", "", @SW_MAXIMIZE)
          ;;;
         Case $msg = $input_1
            $file = FileOpen("results.txt", 0)
            
          ;;;
         Case $msg = $input_2
          ;;;
         Case $msg = $date_1
          ;;;
         Case $msg = $date_2
          ;;;
         Case $msg = $pic_1
          ;;;
;### Tidy Error: Level error -> EndSelect is closing previous Case
      EndSelect
;### Tidy Error: Level error -> WEnd is closing previous Select
   WEnd
   Exit
Edited by emmanuel

"I'm not even supposed to be here today!" -Dante (Hicks)

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