Jump to content

Koda and playing avi files from an internal database


Recommended Posts

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=C:\Documents and Settings\user\Desktop\AVI Template 1.kxf
$Form1 = GUICreate("Form1", 1025, 769, 190, 108)
$Button1 = GUICtrlCreateButton("Button1", 256, 688, 489, 33, 0)
$Avi1 = GUICtrlCreateAvi("No File", -1, 0, 0, 1024, 768)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

    EndSwitch
WEnd

I am new to Koda. I am making a program that will play a file by scanning a bar code into the computer. So I come to the computer and use a UPC Hand Scanner and Scan an item and I want an avi file to play on the screen. My hand scanner is like a keyboard. It reads a UPS and automatically hits enter after the end of the last number. After its done playing I want to be able to scan another item without having to change anything (like the position of the cursor). I am looking at the code and I have never created anything that made a database so I have a few questions.

I would like to be able to hit a key during the running of this program that will allow me to enter (through a noob friendly GUI) the bar code number and tie that bar code to an avi file (f9). I would like that bar code, when entered, to play the avi file tied to it. I am envisioning a database of sorts.

Question 1: I've heard of autoit being able to use an external notepad file to store data. Could I make a notepad file that would look something like:

12345,avi1.avi

12346,avi2.avi

12347,avi3.avi

etc.

Would this make an effective data storage solution for autoit to reference like a database? What would you use?

What code do I use in autoit to play my avi file in the avi player window in koda?

How do I send the information from the hand scanner to my program? I want to leave the avi window in full screen all the time preferably with a black background.

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

hi

How do I send the information from the hand scanner to my program

good question - is there any output data file being produced , or is it just an input box or something?

you would need to figure out some sort of work process . maybe

setup mode

scan all items first -> associate barcode to movie in db

regular mode:

(0) scan one item -> check Database -> play movie -> go to stop (0)

a database can be mostly anything, an ascii file e.g.

barcode;movie

122345;test1.avi

67671345;test2.mpg

for playing the movies you could just call external media player , or if you want it controlled you can use an embedded wmplayer.control

the "koda" is the gui designer - you will need to fill some code by hand with "scite" to make the buttons and controls do something..

Link to comment
Share on other sites

The Scanner is just an optical keyboard. It plugs into the ps2 keyboard port and if you go into notepad and scan an item you will see the numbers show up in notepad followed by a carriage return.

I thought that Koda had a way to control the avi file being played. Do I need to specify an external player to play within the avi movie window created in Koda?

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

hi

try to do this

use the following code - type something in the edit field - press button. a mesage should appear with the entry

try the same to focus the edit field with the mouse and use your barcode - see if it works

#include <GUIConstants.au3>

#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("AForm1", 400, 229, 193, 115)
$edit_1 = GUICtrlCreateInput("edit_1", 40, 52, 245, 21)
$btn_test = GUICtrlCreateButton("btn_test", 308, 52, 75, 25, 0)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
            
        case $btn_test
            $t = GUICtrlRead($edit_1)
            MsgBox(0,"test", $t);

    EndSwitch
WEnd
Edited by nobbe
Link to comment
Share on other sites

Thank You Noobe. That showed me how to at least call an AVI file. I need the end user to be able to enter barcode numbers and tie them to an avi file. I don't have a problem with having him opening notepad and having him enter something like:

12345;avi1.avi

12346;avi2.avi

12347;avi3.avi

Can I have a script read a line from a txt file and store it as a value (e.g. 12345;avi1.avi) and then have the script read until it hits a ";" and store that value (e.g. $1 = 12345) and then have the script skip the ";" in the same line and store it as a value (e.g. $1a = avi1.avi)? After its done can I have the script go to the next line and do the same thing until it reaches the end of the txt file?

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

yes

try something like

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)

Link to comment
Share on other sites

I wrote this much so far:

#Region;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_outfile=fireworks beta 1.exe
#EndRegion;**** Directives created by AutoIt3Wrapper_GUI ****
;Final code

#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("Submit", 308, 52, 75, 21, 0)
GUISetState(@SW_SHOW)
#EndRegion ### START Koda GUI section ### Form=

Func Wait_for_user_input()
While 1; loop get user input 
    $user_input = GUIGetMsg(); get input from the user and declare the data as $user_input
    Switch $user_input
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd
EndFunc

; search for and scan database.txt for validity
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 1", "Can't find database.txt.") 
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)

After I compile this I get a text input box and a button that says Submit. When I manually enter a value from my database.txt file and hit enter the submit button doesnt move and I get no messages even if I hit submit. Can I tie the $edit_field to $btn_test so when I hit enter it triggers an play avi file event? Also I need an example of stringsplit. Currently the order of operations is going to be as follows:

1. Get user input - $user_input = GUIGetMsg

2. Open database.txt and scan for validity

3. Scan database.txt for $user_input, If $user_input = $line then string split and store all data after ";" as $video

4. Call Windows Media Player to play $video and maximize the screen (ctrl+enter)

5. Scan the screen for a pixel in the lower right hand corner of the screen isn't the color of the desktop then loop the screen scan and wait for 2 seconds. If the screen is the color of the desktop then call Wait_for_user_input() and reset $line read to scan from the top of the database.txt file again during the next read

If I am going to rely on a txt input box to get the user input then I need to move it off the screen or disguise it somehow. I want to remove all the icons off of the desktop and hide the task bar and make a desktop background that has instructions on it like "Scan barcode to view a video of the product in use". Is there a function other than GUIGetMsg that just listens for user input but doesn't require a GUI? Maybe just GetMsg?

Edited 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

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