computergroove Posted May 23, 2008 Share Posted May 23, 2008 (edited) I have a program that I have been getting help with in these forums and I am not sure what some of the code does. Could someone please comment these lines to help me move along with this please. Also I would like some good links for autoit functions and progressive tutorials from beginner to more advanced users if anyone can recommend some. expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 400, 229, 193, 115) $edit_field = GUICtrlCreateInput("", 40, 52, 245, 21) $btn_test = GUICtrlCreateButton("btn_test", 308, 52, 75, 25, 0) GUISetState(@SW_SHOW) #EndRegion ### START Koda GUI section ### Form= ; Load the database.txt file if it exists or stop the script Local $f_in = @ScriptDir & "\database.txt"; $fh_in = FileOpen($f_in, 0) ; Check if file opened for reading OK If $fh_in = -1 Then MsgBox(0, "Error", "Unable to open file.") exit; EndIf While 1 $line = FileReadLine($fh_in) If @error = -1 Then ExitLoop If StringInStr($line, ";") > 0 Then ConsoleWrite($line & @CRLF) ; here use stringsplit for splitting line EndIf WEnd FileClose($fh_in) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn_test $t = GUICtrlRead($edit_field) MsgBox(0, "test", $t); If $t = "1" Then ;; use shell object with windows media player now ShellExecute(@ScriptDir & "\1.avi"); ElseIf $t = "2" Then ;; use shell object with windows media player now ShellExecute(@ScriptDir & "\2.avi"); EndIf EndSwitch WEnd What does "CASE" do? Edited May 23, 2008 by computergroove Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 23, 2008 Share Posted May 23, 2008 I have a program that I have been getting help with in these forums and I am not sure what some of the code does. Could someone please comment these lines to help me move along with this please. Also I would like some good links for autoit functions and progressive tutorials from beginner to more advanced users if anyone can recommend some. Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btn_test $t = GUICtrlRead($edit_field) MsgBox(0, "test", $t); If $t = "1" Then ;; use shell object with windows media player now ShellExecute(@ScriptDir & "\1.avi"); ElseIf $t = "2" Then ;; use shell object with windows media player now ShellExecute(@ScriptDir & "\2.avi"); EndIf EndSwitch What does "CASE" do? The Switch function selectively chooses what to do based on a given value. In this example, it chooses based on the value of $nMsg. In the case where the value is equal to $GUI_EVENT_CLOSE (a global constant that is inside the GUIConstants.au3 file) it executes that code, and in the case where it is equal to $btn_test it runs that code instead. When the value is neither, nothing gets executed and it just moves on to EndSwitch, and the loop around it continues. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now