Last active
December 31, 2015 02:09
-
-
Save opdo/e2ab6ff4f8c38835a77d to your computer and use it in GitHub Desktop.
Source Code Auto Say Sorry - Eck Op
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#cs | |
Tool Auto Say Sory - Opensource | |
Code by Ếck Ộp | |
Blog: http://eckop.tk | |
Thanks for using | |
#ce | |
#NoTrayIcon | |
#include <GUIConstantsEx.au3> | |
#include <ListViewConstants.au3> | |
#include <StaticConstants.au3> | |
#include <WindowsConstants.au3> | |
#include <GuiListView.au3> | |
Opt("GUIOnEventMode", 1) ; tuỳ chọn chạy chế độ event cho GUI | |
; set hot key cho tool | |
HotKeySet("^+s", "_Start") ; Shift-Ctrl-s | |
HotKeySet("^+q", "_Stop") ; Shift-Ctrl-q | |
; Khai báo một số thành phần | |
Global $start = False ; start / stop | |
Global $data = @ScriptDir&'\Data.txt' ; file data | |
Global $item[100][100] ; item to load gui | |
Global $word[100][100] ; item to random word (do làm giống như tutorial nên mình thêm array này, các bạn có thể xoá nó và tuỳ biến lại theo array item trên cho gọn | |
Global $sleep = Number(IniRead($data,'Setting','Sleep','')) | |
if $sleep = 0 then $sleep = 1000 | |
; GUI | |
$main = GUICreate("Auto Say Sorry - Ếck Ộp Blog - eckop.tk", 409, 262, -1, -1, -1, BitOR($WS_EX_TOOLWINDOW,$WS_EX_WINDOWEDGE)) | |
$MenuItem1 = GUICtrlCreateMenu("Dữ liệu") | |
$menu_addword = GUICtrlCreateMenuItem("Thêm từ", $MenuItem1) | |
GUICtrlSetOnEvent ( -1, "_AddWord" ) | |
$menu_addcol = GUICtrlCreateMenuItem("Thêm cột", $MenuItem1) | |
GUICtrlSetOnEvent ( -1, "_AddCol" ) | |
$menu_delword = GUICtrlCreateMenuItem("Xoá từ", $MenuItem1) | |
GUICtrlSetOnEvent ( -1, "_DelWord" ) | |
$menu_delcol = GUICtrlCreateMenuItem("Xoá cột", $MenuItem1) | |
GUICtrlSetOnEvent ( -1, "_DelCol" ) | |
$MenuItem2 = GUICtrlCreateMenu("Tool") | |
$menu_hotkey = GUICtrlCreateMenuItem("Tuỳ chỉnh", $MenuItem2) | |
GUICtrlSetOnEvent ( -1, "_Setting" ) | |
$menu_help = GUICtrlCreateMenuItem("Hướng dẫn", $MenuItem2) | |
GUICtrlSetOnEvent ( -1, "_Help" ) | |
$menu_about = GUICtrlCreateMenuItem("Giới thiệu", $MenuItem2) | |
GUICtrlSetOnEvent ( -1, "_About" ) | |
GUISetFont(10, 400, 0, "Tahoma") | |
$ListView = GUICtrlCreateListView("", 0, 0, 409, 209) | |
_GUICtrlListView_SetExtendedListViewStyle($ListView, $LVS_EX_FULLROWSELECT) | |
$text = GUICtrlCreateLabel("Tổng số câu ghép được: ", 8, 216, 235, 18) | |
GUICtrlSetFont(-1, 9, 800, 0, "Tahoma") | |
GUICtrlSetColor(-1, 0x000000) | |
GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") | |
_LoadGUI() | |
GUISetState(@SW_SHOW) | |
While 1 | |
Sleep(100) | |
WEnd | |
Func _LoadGUI() ; load các control trong gui | |
_RefeshArray() | |
Local $number = 1 | |
Local $col = Number(IniRead($data,'Col','Number','')) | |
$word[0][0] = $col | |
if $col = 0 Then $number = 0 | |
_GUICtrlListView_BeginUpdate($ListView) | |
_GUICtrlListView_DeleteAllItems($ListView) | |
for $i = 1 to $col | |
_GUICtrlListView_AddColumn($ListView,'Cột '&$i,80) | |
Local $read = IniRead($data,'Col'&$i,'Word','') | |
if $word <> '' Then | |
Local $temp = StringSplit($read,',') | |
$number *= $temp[0] | |
$word[$i][0] = $temp[0] | |
for $j = 1 to $temp[0] | |
$item[$j-1][$i-1] = $temp[$j] | |
$word[$i][$j] = $temp[$j] | |
Next | |
EndIf | |
Next | |
_GUICtrlListView_AddArray ($ListView,$item) | |
_GUICtrlListView_EndUpdate($ListView) | |
GUICtrlSetData($text,'Tổng số câu ghép được: '&$number) | |
EndFunc | |
; các func menu | |
Func _AddWord() | |
Local $input = InputBox('Nhập từ','Nhập từ muốn thêm vào đây, từ muốn thêm không được phép chứa dấu phẩy (dấu ",")') | |
if not @error Then | |
$input = StringRegExpReplace($input,',','.') ; chuyển toàn bộ dấu phẩy thành dấu chấm | |
Local $column = InputBox('Nhập cột','Nhập cột muốn thêm từ vào đầy') | |
if @error or Number($column) = 0 or Number($column) > Number(IniRead($data,'Col','Number','')) Then | |
MsgBox(16,'Thông báo','Cột không hợp lệ') | |
Else | |
if not _CheckWordExist($input,$column) Then | |
Local $temp = IniRead($data,'Col'&$column,'Word','') | |
if $temp = '' Then | |
IniWrite($data,'Col'&$column,'Word',$input) | |
Else | |
IniWrite($data,'Col'&$column,'Word',$temp&','&$input) | |
EndIf | |
_LoadGUI() | |
MsgBox(64,'Hoàn tất','Hoàn tất') | |
Else | |
MsgBox(16,'Thông báo','Từ đã tồn tại') | |
EndIf | |
EndIf | |
EndIf | |
EndFunc | |
Func _AddCol() | |
Local $input = InputBox('Nhập cột','Nhập thứ tự cột muốn thêm (ví dụ nhập 3 thì cột sẽ trở thành cột 3)') | |
Local $col = IniRead($data,'Col','Number','') | |
if @error or Number($input) = 0 or Number($input) > $col+1 Then | |
MsgBox(16,'Thông báo','Cột không hợp lệ') | |
Else | |
if Number($input) <= $col + 1 Then | |
for $i = $col to Number($input) Step -1 | |
IniRenameSection($data,'Col'&$i,'Col'&$i+1) | |
Next | |
EndIf | |
IniWrite($data,'Col','Number',$col + 1) | |
IniWrite($data,'Col'&Number($input),'Word','') | |
_LoadGUI() | |
MsgBox(64,'Hoàn tất','Hoàn tất') | |
EndIf | |
EndFunc | |
Func _DelCol() | |
Local $input = InputBox('Nhập cột','Nhập thứ tự cột muốn xoá (ví dụ nhập 3 thì cột 3 sẽ bị xoá)') | |
Local $col = IniRead($data,'Col','Number','') | |
if @error or Number($input) = 0 or Number($input) > $col Then | |
MsgBox(16,'Thông báo','Cột không hợp lệ') | |
Else | |
IniDelete($data,'Col'&Number($input)) | |
IniWrite($data,'Col','Number',$col - 1) | |
for $i = Number($input) to $col | |
IniRenameSection($data,'Col'&$i+1,'Col'&$i) | |
Next | |
_LoadGUI() | |
MsgBox(64,'Hoàn tất','Hoàn tất') | |
EndIf | |
EndFunc | |
Func _DelWord() | |
Local $string = '' | |
Local $input = InputBox('Nhập từ','Nhập từ muốn xoá vào đây, từ muốn xoá không được phép chứa dấu phẩy (dấu ",")') | |
if not @error Then | |
$input = StringRegExpReplace($input,',','.') ; chuyển toàn bộ dấu phẩy thành dấu chấm | |
Local $column = InputBox('Nhập cột','Nhập cột muốn xoá từ vào đầy') | |
if @error or Number($column) = 0 or Number($column) > Number(IniRead($data,'Col','Number','')) Then | |
MsgBox(16,'Thông báo','Cột không hợp lệ') | |
Else | |
$string = StringRegExpReplace(IniRead($data,'Col'&$column,'Word',''),$input&',','') | |
$string = StringRegExpReplace($string,','&$input,'') | |
$string = StringRegExpReplace($string,$input,'') | |
IniWrite($data,'Col'&$column,'Word',$string) | |
_LoadGUI() | |
MsgBox(64,'Hoàn tất','Hoàn tất') | |
EndIf | |
EndIf | |
EndFunc | |
Func _Start() | |
$start = True | |
_XinLoi() | |
EndFunc | |
Func _Stop() | |
$start = False | |
EndFunc | |
Func _Setting() | |
Local $input = InputBox('Nhập thời gian','Nhập thời gian đợi sau mỗi câu. Tính bằng mili giây (1000 mili giây = 1 giây)') | |
if not @error Then | |
if Number($input) < 100 Then | |
MsgBox(16,'Thông báo','Tối thiểu là 100 mili giây') | |
Else | |
IniWrite($data,'Setting','Sleep',Number($input)) | |
EndIf | |
EndIf | |
EndFunc | |
Func _About() | |
MsgBox(64,'About me','Tool Auto Say Sorry - OpenSource'&@CRLF&'Tool được viết bởi Ếck Ộp. Cám ơn bạn đã quan tâm'&@CRLF&'Mời bạn ghé thăm blog của mình để đọc các tutorial hoặc thủ thuật IT nhé ^_^'&@CRLF&'My blog: http://eckop.tk') | |
EndFunc | |
Func _Help() | |
MsgBox(64,'Help','Đặt con trỏ chuột vào notepad hoặc khung chat facebook rồi ấn hotkey để chạy'&@CRLF&'+ Ctrl + Shift + S : Bắt đầu chạy'&@CRLF&'+ Ctrl + Shift + Q : Dừng chương trình'&@CRLF&'Bạn có thể thiết lập thêm, bớt từ hoặc cột để ghép thành câu. Thiết lập giãn cách thời gian gửi tại Tool->Tuỳ chỉnh. Tool hoạt động dựa theo ý tưởng và thuật toán liệt kê theo một thứ tự nhất định, dùng đệ quy. Tham khảo và tìm hiểu thêm về tool tại http://eckop.tk') | |
EndFunc | |
Func _XinLoi($x = 1,$string = '') ; thuật toán đệ quy sắp xếp các ký tự theo trình tự nhất định | |
if not $start then Return 0 ; điều kiện dừng | |
if $x >= $word[0][0] Then | |
for $i = 1 to $word[$x][0] | |
Send($string&$word[$x][$i]) | |
Send("{enter}") | |
Sleep($sleep) | |
Next | |
Else | |
for $i = 1 to $word[$x][0] | |
$newstring = $string&$word[$x][$i]&' ' | |
_XinLoi($x+1,$newstring) | |
Next | |
EndIf | |
EndFunc | |
Func _CheckWordExist($w,$c) ; kiểm tra xem từ có tồn tại trong cột hay ko | |
Local $read = IniRead($data,'Col'&$c,'Word','') | |
Local $temp = StringSplit($read,',') | |
if $read = '' then Return False | |
for $i = 1 to $temp[0] | |
if $temp[$i] = $w then Return True | |
Next | |
Return False | |
EndFunc | |
Func _RefeshArray() | |
GUICtrlDelete($ListView) | |
$ListView = GUICtrlCreateListView("", 0, 0, 409, 209) | |
_GUICtrlListView_SetExtendedListViewStyle($ListView, $LVS_EX_FULLROWSELECT) | |
for $i = 0 to 99 | |
for $j = 0 to 99 | |
$item[$i][$j] = '' | |
$word[$i][$j] = '' | |
Next | |
Next | |
EndFunc | |
Func _Exit() | |
Exit | |
EndFunc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Setting] | |
Sleep=1000 | |
[Col] | |
Number=5 | |
[Col1] | |
Word=anh,tôi,tớ,chồng,mình | |
[Col2] | |
Word=xin lỗi,rất xin lỗi,vô cùng xin lỗi,thực sự xin lỗi,cúi đầu xin lỗi,dập gối xin lỗi,ngàn lần xin lỗi,trăm lần xin lỗi | |
[Col3] | |
Word=em,vợ,cậu,cưng,bé | |
[Col4] | |
Word=nha,nhiều,mà,yêu | |
[Col5] | |
Word=tha cho anh nha,hứa sẽ không tái phạm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment