Code : Tout sélectionner
#Region ;**** Directives created by AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_UseX64=n
#AutoIt3Wrapper_Res_Language=1036
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
#AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#include <GUIConstantsEx.au3>
#include <SQLite.au3>
Opt("GUIOnEventMode", 1)
Global $hGUI
Global $mem
Global $MemoriserGui
Global $QuestionLabel
Global $ReponseLabel
Global $sqlite = @ScriptDir & "\base.sqlite" ; /!\ /!\ /!\ CREER MANUELLEMENT CE FICHIER AVANT DE LANCER LE PROGRAMME /!\ /!\ /!\
Global $sLocalSQLiteDll = @ScriptDir & "\sqlite3.dll"
Global $Base_SQLite
InitSql()
InitBase()
InitGuis()
GUISetState(@SW_SHOW, $hGUI)
While 1
Sleep(1000)
WEnd
Func InitMemoriser()
GUISetState(@SW_SHOW, $MemoriserGui)
AdlibRegister("Memoriser", 3000)
EndFunc
Func Memoriser()
Local $Reponse = ""
Local $aRow, $hQuery
_SQLite_Query(-1, "SELECT * FROM liste ORDER BY Random() LIMIT 1;", $hQuery)
If(_SQLite_FetchData($hQuery, $aRow, False, False) = $SQLITE_OK) Then
GUICtrlSetData($QuestionLabel,$aRow[0])
$Reponse = ""
$Reponse = $aRow[1]
EndIf
sleep(3000)
GUICtrlSetData($ReponseLabel,$Reponse)
sleep(2000)
GUICtrlSetData($ReponseLabel,"")
GUICtrlSetData($QuestionLabel, "")
GUICtrlSetData($ReponseLabel, "")
EndFunc
Func arret()
GUISetState(@SW_HIDE, $MemoriserGui)
AdlibUnRegister("Memoriser")
EndFunc
Func exit_sqlite()
_SQLite_Close()
_SQLite_Shutdown()
EndFunc
Func InitSql()
_SQLite_Startup($sLocalSQLiteDll, False, 1)
If @error Then
MsgBox(0, "Fichier manquant", "Le fichier SQLite3.dll est introuvable !")
Exit
EndIf
$Base_SQLite = _SQLite_Open($sqlite)
If @error > 0 Then
MsgBox(16, "SQLite Erreur", "La base ne peut être chargée !")
Exit
EndIf
OnAutoItExitRegister("exit_sqlite")
EndFunc
Func InitBase()
;CREATION DE LA BASE-ESSAI A LA PREMIERE OUVERTURE DU PROGRAMME
; à COMMENTER PAR LA SUITE
_SQLite_Exec($Base_SQLite, "CREATE TABLE IF NOT EXISTS liste (latin,francais);")
_SQLite_Exec($Base_SQLite, "INSERT INTO liste VALUES ('cum','quand');")
_SQLite_Exec($Base_SQLite, "INSERT INTO liste VALUES ('dum', 'pendant que');")
_SQLite_Exec($Base_SQLite, "INSERT INTO liste VALUES ('sicut','comme');")
_SQLite_Exec($Base_SQLite, "INSERT INTO liste VALUES ('pater','père');")
_SQLite_Exec($Base_SQLite, "INSERT INTO liste VALUES ('mater', 'mère');")
_SQLite_Exec($Base_SQLite, "INSERT INTO liste VALUES ('sed','mais');")
EndFunc
Func InitGuis()
$hGUI = GUICreate("Exemple")
GUISetOnEvent($GUI_EVENT_CLOSE, "quitter", $hGUI)
$mem = GUICtrlCreateButton("Mémoriser", 100, 100, 85, 25)
GUICtrlSetOnEvent($mem,"InitMemoriser")
$MemoriserGui = GUICreate("Mémorisation", 600, 600, (@DesktopWidth/2) - 300, (@DesktopHeight/2) - 300)
GuiSetOnEvent($GUI_EVENT_CLOSE, "arret", $MemoriserGui)
$QuestionLabel = GUICtrlCreateLabel("",20,20,400,40)
$ReponseLabel = GUICtrlCreateLabel("",20,60,400,40)
EndFunc
Func quitter()
Exit
EndFunc