Jump to content

Recommended Posts

Hello,

I've created a script for a Bingo / Lottery kind of game in PHP.

Now I want to make this a standalone application in AutoIT.

I really dont know how to do that as i´m just a Autoit-beginner.

Can you help me with it?

In general I have the following files:

data.csv - the "database" where the bingo-numbers are stored, together with the name of the candidate

index.htm - to show the 'program' in a browser

input.php - to take care of input

results.php - to show the winners

numbers.txt - the winning numbers to compare with

I have the following files:

Input.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
body {  font-family:Times New Roman, Verdana,Geneva; font-size:12px; color:#000000;
    margin-left:20px; background:#F7F5DF; width: 300px; }
H2 { font-family:Times New Roman, Geneva; font-size:16pt; color:#840018; text-align:center; }
</style>
<link rel=stylesheet href="style.css" TYPE="text/css">
<title>Input</title>
<?php
$sepsign   = '/;/';
$text     = '';
$wnumbers = '';
$counter    = 0;
$filed     = "data.csv";
$fileg     = "numbers.txt";
$in_numbers = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);

if ($_SERVER['REQUEST_METHOD'] == 'POST') {
  $name = $_POST['name'];
  $in_numbers = $_POST['$in_numbers'];
}

$fd        = fopen($fileg,"r") or die ("Unable to open $file.");
$text     = fread($fd,filesize($fileg));
$wnumbers = preg_split($sepsign,$text); // wnumbers is an array with winning numbers
Fclose($fd);

for ($j = 0; $j < 10; $j++) {
   for ($i = 0; $i < 10; $i++) {
      if ($wnumbers[$i] == $in_numbers[$j])  { $counter++; }
   }
}   // $counter will contain the number of matches on the input

# Append and write the line in a file <number of matches>;<name>;<number 1>;<number 2>; etc

$fdb = fopen($filed,"a+");
fwrite($fdb,$counter . ";" . $name);
for ($i = 0; $i < 10; $i++) {
   fwrite($fdb,";" . $in_numbers[$i]);
}
fwrite($fdb,"\r\n");
fclose($fdb); 
?>
<h2><br>Your input has been stored successfully!</h2>
</body></html>

Results.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML><head>
<meta http-equiv="Content-Type" content="text/HTML; charset=iso-8859-1">
<style>
body {  font-family:Times New Roman, Verdana,Geneva; font-size:12px; color:#000000;
    margin-left:20px; background:#F7F5DF; width: 300px; }
H2 { font-family:Times New Roman, Geneva; font-size:16pt; color:#840018; text-align:center; }
</style>
<title>Result</title>
</head><BODY>
<h2>Result of the draw</h2><hr><br>
<?php
$sepsign   = '/;/';
$text     = '';
$filed     = "data.csv";
$fileg     = "numbers.txt";

$fd = fopen($filed,"r") or die ("unable to open $file.");
$text = fread($fd,filesize($filed));
$lines = preg_split("/\r\n/",$text);    // Will split the file data.csv in lines
$count_reg = count($lines);
fclose($fd);
sort ($lines);
reset($lines);

for ($i = ($count_reg - 1); $i>($count_reg-4); $i--) {  // The three highest scores are showed
   $collums = preg_split($sepsign,$lines[$i]);
   print "<b>Name: " . $collums[1] . "<br>";
   print "Number of matches: " . $collums[0] . "</b><br>";
   print "Input: ";
   for ($j = 2; $j < 12; $j++) {
     print $collums[$j];
     if ($j <> 11 ) { print ", "; }  // to prevent the "," to appear after the last number
   }
   print "<br><br>";
}
$fd    = fopen($fileg,"r") or die ("Unable to open $file.");
$text = fread($fd,filesize($fileg));
$wnumbers = preg_split($sepsign,$text);
Fclose($fd);

print "<br><b>Bingo numbers</b><br><hr>";
for ($j = 0; $j < 11; $j++) {
   print $wnumbers[$j];
   if ($j < 9 ) { print ", "; }  // to prevent the "," to appear after the last number 
}
?>
</body></html>

Index.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style>
body {  font-family:Times New Roman, Verdana,Geneva; font-size:12px; color:#000000;
    margin-left:20px; background:#F7F5DF; width: 300px; }
H2 { font-family:Times New Roman, Geneva; font-size:16pt; color:#840018; text-align:center; }
</style>
<title>Bingo game, input numbers.</title>
</head><body>
<form action="input.php" method="post" name="form">
<center>
<h2>Input numbers</h2>
lines  &nbsp; <input type="text" name="lines" size=20 maxlength=50><br><br>
Number &nbsp;1 &nbsp;<input type="text" name="$in_numbers[0]" size=4><br>
Number &nbsp;2 &nbsp;<input type="text" name="$in_numbers[1]" size=4><br>
Number &nbsp;3 &nbsp;<input type="text" name="$in_numbers[2]" size=4><br>
Number &nbsp;4 &nbsp;<input type="text" name="$in_numbers[3]" size=4><br>
Number &nbsp;5 &nbsp;<input type="text" name="$in_numbers[4]" size=4><br>
Number &nbsp;6 &nbsp;<input type="text" name="$in_numbers[5]" size=4><br>
Number &nbsp;7 &nbsp;<input type="text" name="$in_numbers[6]" size=4><br>
Number &nbsp;8 &nbsp;<input type="text" name="$in_numbers[7]" size=4><br>
Number &nbsp;9 &nbsp;<input type="text" name="$in_numbers[8]" size=4><br>
Number 10&nbsp;<input type="text" name="$in_numbers[9]" size=4><br><br>
<input type="submit" value="Submit..."></FORM>
</center>
<p />&nbsp;<p />
</body></html>
Link to post
Share on other sites
  • 1 month later...

Hello friend! Welcome to autoit. While I don't have the time currently to write an example code for you, I can make some reccomendations which you can look up in the help file.

Depending on if you want the app to work offline, there's two different options I see that you have

The first option is to simply embed the webpage into a gui. (create a GUI then use _IECreateEmbedded) This will allow anyone with an internet connection to access the game.

If you don't wish to require an active internet connection, you can start your job by looking up the following information.

1)To store data (data.cvs and numbers.txt) it's reccomended you use SQLite [_SQLite_Open()], although INI files may work, depending on how much data you plan to store [iniwrite()].

2)Use a InputBox() to request input from the user

3)Process the information the same way you did with php.

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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By HoangDung
      This is the function that returns the result from cmd, initially i connect to the network wait then i make a call to the above _GetDOSOutput($sCommand) function i want to wait 1 period of time netsh wlan connect name="name" actually but after starting to execute the netsh wlan show interfaces command i tried adding a timeout command it seems to have ignored the timeout command?
      #include <WindowsConstants.au3> #include <Constants.au3> Func _GetDOSOutput($sCommand) Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) Local $sOutput = '' Local $iPID = Run('"' & @ComSpec & '" /c ' & $sCommand, "", @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) While 1 $sOutput &= StdoutRead($iPID, False, False) If @error Then ExitLoop EndIf Sleep(10) WEnd Return $sOutput EndFunc Local $sCommand= 'netsh wlan delete profile name="wait" & netsh wlan connect name="name" interface="Wi-fi" & netsh wlan show interfaces' MsgBox(0,0,_GetDOSOutput($sCommand))  
    • By D3fr0s7
      I'm trying to make one tray item delete another, but when I do this, all tray items that were created after the deleted item don't work as intended, as if their controlID's were all shifted down one value, and their corresponding tray items now (after deletion) run the code of the tray item before it. Am I missing something? Is there a better way to accomplish what I'm trying to do?
      #include <TrayConstants.au3> #include <Array.au3> HotKeySet ( "{ESC}", "Abort" ) Opt ( "TrayMenuMode", 3 ) TraySetState($TRAY_ICONSTATE_SHOW) ; Show the tray menu. Global $aTray[8] ; Defines array to hold tray items. $aTray[0] = TrayCreateItem ( "Test 1 (Name Test 5)" ) $aTray[1] = TrayCreateItem ( "Test 2 (Delete Test 5)" ) $aTray[2] = TrayCreateItem ( "Test 3 (Restore Test 5)" ) $aTray[3] = TrayCreateItem ( "Test 4 (Check if Test 5 is blank or space)" ) $aTray[4] = TrayCreateItem ( "Test 5 Delete Me" ) $aTray[5] = TrayCreateItem ( "Test 6 (Check Test 5 Text)" ) $aTray[6] = TrayCreateItem ( "Test 7 (Read Values)" ) $aTray[7] = TrayCreateItem ( "Test 8 (Count Blanks)" ) While 1 Switch TrayGetMsg() Case $aTray[0] ; "Test 1" Change Test 5 Text. If TrayItemGetText ( $aTray[0] ) <> "" Then Global $TrayText = InputBox ( "Test", "Choose text for Test 5", "Test 5 Delete Me" ) TrayItemSetText ( $aTray[4], $TrayText) EndIf Case $aTray[1] ; "Test 2" Deletes "Test 5". If TrayItemGetText ( $aTray[1] ) <> "" Then Global $TrayDeletedName = TrayItemGetText ( $aTray[4] ) TrayItemDelete ( $aTray[4] ) _ArrayInsert ( $aTray, 4 ) EndIf Case $aTray[2] ; "Test 3" Restores "Test 5". If TrayItemGetText ( $aTray[2] ) <> "" Then $aTray[4] = TrayCreateItem ( $TrayDeletedName ) EndIf Case $aTray[3] ; "Test 4" Check if Test 5 value is blank, space, or filled. If TrayItemGetText ( $aTray[3] ) <> "" Then If TrayItemGetText ( $aTray[4] ) = "" Then MsgBox ( 0, "Test", "Test 5 is blank" ) ElseIf TrayItemGetText ( $aTray[4] ) = " " Then MsgBox ( 0, "Test", "Test 5 is not blank (space)" ) Else MsgBox ( 0, "Test", "Test 5 is assigned a value" ) EndIf EndIf Case $aTray[4] ; "Test 5" (Item to test for, during, and after deletion). If TrayItemGetText ( $aTray[4] ) <> "" Then MsgBox ( 0, "Test", "I'm here!" ) EndIf Case $aTray[5] ; "Test 6" Displays Text from Test 5 item. If TrayItemGetText ( $aTray[5] ) <> "" Then $Test5Text = TrayItemGetText ( $aTray[4] ) MsgBox ( 0, "Test", "Test 5 Text: " & $Test5Text ) EndIf Case $aTray[6] ; "Test 7" Displays all item values. If TrayItemGetText ( $aTray[6] ) <> "" Then MsgBox ( 0, "Test", "$aTray[0]: " & $aTray[0] & @CRLF & _ "$aTray[1]: " & $aTray[1] & @CRLF & _ "$aTray[2]: " & $aTray[2] & @CRLF & _ "$aTray[3]: " & $aTray[3] & @CRLF & _ "$aTray[4]: " & $aTray[4] & @CRLF & _ "$aTray[5]: " & $aTray[5] & @CRLF & _ "$aTray[6]: " & $aTray[6] & @CRLF & _ "$aTray[7]: " & $aTray[7] & @CRLF ) EndIf Case $aTray[7] ; "Test 8" Counts all blanks in tray values. If TrayItemGetText ( $aTray[7] ) <> "" Then Global $blankCount = _ArrayFindAll ( $aTray, "" ) If $blankCount = -1 Then If @error = 6 Then MsgBox ( 0, "Test", "Error, No blanks present") EndIf Else MsgBox ( 0, "Test", "# of blanks: " & $blankCount ) EndIf EndIf EndSwitch WEnd Func Abort() Exit EndFunc Here is a test script I created to try to troubleshoot the problem on my own, with no luck. pay specific attention to "Test 2" ($aTray[1]), "Test 5" ($aTray[4]), and how every tray item after "Test 5" ($aTray[4]) behaves after deletion. Clicking "Test 2" will delete tray item "Test 5", after deletion every item runs the code of the tray item that was established before it (ex. "Test 3" and "Test 4" run their respective code, "Test 5" no longer exists, "Test 6" runs "Test 7", "Test 7" runs "Test 8"), and the last item ("Test 8" $aTray[7]) has no effect when the tray item is clicked. 

      I understand that deleting the tray item changes the controlID, but I don't know in what way it does, and therefore how I can fix it to be able to achieve what I want it to. I appreciate any help or guidance with this problem.

      To clarify, what I'm ultimately trying to do is create a 'while' loop with switch case functions that can exist without necessarily being linked to a tray item, so that I can add and delete them at liberty using the script's functions, without having to differentiate switch case functions with if functions (if $aTray[x] exists, then use this set of switch case functions, etc.). 

      Please, I am in pain. Water come school me again pls
    • By PeterVerbeek
      This topic give you access to an AutoIt functions library I maintain which is called PAL, Peter's AutoIt Library. The latest version 1.26 contains 214 functions divided into these topics:
      window, desktop and monitor GUI, mouse and color GUI controls including graphical buttons (jpg, png) GUI numberbox controls for integer, real, binary and hexadecimal input logics and mathematics include constants string, xml string and file string dialogues and progress bars data lists: lists, stacks, shift registers and key maps (a.ka. dictionaries) miscellaneous: logging/debugging, process and system info Change log and files section  on the PAL website (SourceForge).
      A lot of these functions were created in the development of Peace, Peter's Equalizer APO Configuration Extension, which is a user interface for the system-wide audio driver called Equalizer APO.
    • By Zaoka
      HI,
      for couple of years I'm using  Jos script for sending reports, email with excel attachment. But from last week i'm getting this error when sending excel or word attachment
      message has lines too long for transport jpeg, pdf works with no problems, any sugestion ?
    • By diepfeile
      I'm using the following:
      Autoit 3.3.14.5
      newly installed Beta 3.3.15.5
      SQlite version 3380000 aka 3.38.0
      I put sqlite3.dll and sqlite3_x64.dll in C:\Windows\System32 since many scripts depend on them.


      I extended the output of _SQLite_Startup()
      with:
      ConsoleWrite("@AutoItX64 " & @AutoItX64 & @CRLF) ConsoleWrite("$sDll_Filename " & $sDll_Filename & @CRLF) ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF)

      Also using the script from https://www.autoitscript.com/autoit3/docs/libfunctions/_SQLite_Startup.htm for testing.

       
      >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(3.3.14.5):C:\Program Files (x86)\AutoIt3\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0 >Running:(3.3.15.5):C:\Program Files (x86)\AutoIt3\Beta\autoit3.exe "R:\Download\aasdf.au3" @AutoItX64 0 $sDll_Filename sqlite3.dll _SQLite_LibVersion=0 >Running:(3.3.15.5):C:\Program Files (x86)\AutoIt3\Beta\autoit3_x64.exe "R:\Download\aasdf.au3" @AutoItX64 1 $sDll_Filename sqlite3_x64.dll _SQLite_LibVersion=3.38.0


      Why doesn't it work in 32bit, despite me having the 32bit sqlite.dll? Autoit urges running scripts in 32bit mode and Scite starts scripts just in 32bit mode without the flag?
      With #AutoIt3Wrapper_UseX64=Y it just works, both normal Autoit and beta!
      sqlite3.dll sqlite3_x64.dll
×
×
  • Create New...