반응형
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- EnvDiv
- SetEnv
- if
- EnvSub
- IF (식)
- Threads
- 식의 설명
- SetMouseDelay
- IfWinExist
- ControlGetText
- EnvSet
- if(식)
- DetectHiddenWindows
- 함수
- SetKeyDelay
- EnvMult
- ControlSend
- 식
- SetTitleMatchMode
- API
- autohotkey
- 배열
- Menu
- EnvAdd
- Var:=식
- StringGetPos
- MouseClick
- Blocks
- IfInString
- SetControlDelay
Archives
- Today
- Total
ㄴrㅎnㅂrㄹrㄱi
AHK Chat (Another Method) 본문
반응형
-
#Persistent
-
start:
-
Gui, Add, Edit, x76 y10 w100 h20 vusername ,
-
Gui, Add, Text, x6 y10 w70 h20 , User Name:
-
Gui, Add, Button, x43 y40 w100 h30 glogin +default, Login
-
Gui, Show, h83 w188, Login
-
Return
-
-
login:
-
gui submit
-
gui destroy
-
URLDownloadToFile, http://jon2s.com/ahkchat/chat.php?event=login&loggedusername=%username%, %A_Temp%\login.txt
-
FileReadLine, loginresult, %A_Temp%\login.txt, 1
-
if loginresult = success
-
{
-
URLDownloadToFile, http://jon2s.com/ahkchat/chat.php?event=userlist, %A_Temp%\userlist.txt
-
URLDownloadToFile, http://jon2s.com/ahkchat/chat.php?event=chat&loggedusername=%username%, %A_Temp%\chat.txt
-
FileReadLine, userlist, %A_Temp%\userlist.txt, 1
-
StringReplace, userlist, userlist, &(), `n, 1
-
FileReadLine, chat, %A_Temp%\chat.txt, 1
-
StringReplace, chat, chat, &(), `n, 1
-
SetTimer, updatechat, 5000
-
goto displaychat
-
}
-
if loginresult <> success
-
{
-
msgbox,,Warning, There was a problem logging in. Please try again.
-
goto start
-
}
-
-
displaychat:
-
Gui, Add, Edit, x6 y310 w350 h20 vsendtext,
-
Gui, Add, Button, x366 y310 w100 h20 gsend +default, Send
-
Gui, Add, Edit, x6 y10 w350 h290 +readonly vchat,
-
Gui, Add, Edit, x366 y10 w100 h290 +readonly vuserlist, %userlist%
-
Gui, Show, h342 w477, AHK Chat
-
Return
-
-
send:
-
gui submit, nohide
-
SetTimer, updatechat, off
-
URLDownloadToFile, http://jon2s.com/ahkchat/chat.php?event=sendtext&loggedusername=%username%&msg=%sendtext%, %A_Temp%\sendtxt.txt
-
gosub, updatechat
-
guicontrol,, sendtext,
-
SetTimer, updatechat, on
-
return
-
-
updatechat:
-
URLDownloadToFile, http://jon2s.com/ahkchat/chat.php?event=chat&loggedusername=%username%, %A_Temp%\chat.txt
-
FileReadLine, chatnew, %A_Temp%\chat.txt, 1
-
if chatnew <> ''
-
{
-
chat = %chatnew% %chat%
-
}
-
StringReplace, chat, chat, &(), `n, 1
-
guiControl,, chat, %chat%
-
chatnew =
-
URLDownloadToFile, http://jon2s.com/ahkchat/chat.php?event=userlist, %A_Temp%\userlist.txt
-
FileReadLine, userlist, %A_Temp%\userlist.txt, 1
-
StringReplace, userlist, userlist, &(), `n, 1
-
guicontrol,, userlist, %userlist%
-
return
-
-
GuiClose:
-
URLDownloadToFile, http://jon2s.com/ahkchat/chat.php?event=logout&loggedusername=%username%, %A_Temp%\logout.txt
-
FileDelete, %A_Temp%\logout.txt
-
FileDelete, %A_Temp%\userlist.txt
-
FileDelete, %A_Temp%\chat.txt
-
FileDelete, %A_Temp%\login.txt
-
FileDelete, %A_Temp%\send.txt
-
ExitApp
MySQL Table ahkchat
-
CREATE TABLE `ahkchatchat` (
-
`msgid` int(11) NOT NULL AUTO_INCREMENT,
-
`username` varchar(50) NOT NULL DEFAULT '',
-
`date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
-
`msg` text NOT NULL,
-
PRIMARY KEY (`msgid`)
-
) ENGINE=MyISAM AUTO_INCREMENT=72 DEFAULT CHARSET=latin1 AUTO_INCREMENT=72 ;
MySQL Table
-
CREATE TABLE `ahkchatusers` (
-
`userid` int(11) NOT NULL AUTO_INCREMENT,
-
`username` varchar(50) NOT NULL DEFAULT '',
-
`loggedin` char(3) NOT NULL DEFAULT '',
-
`ip` varchar(50) NOT NULL DEFAULT '',
-
`lastmsg` int(11) NOT NULL DEFAULT '0',
-
PRIMARY KEY (`userid`)
-
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1 AUTO_INCREMENT=8 ;
PHP Script
-
<?php
-
/* Warning codes, put to errorlog
-
W001: Username already in use
-
-
-
*/
-
-
-
$event = $_GET['event'];
-
$msg = $_GET['msg'];
-
$username = $_GET['loggedusername'];
-
$loggedusername = $_GET['loggedusername'];
-
-
//echo 'Connected to the database.';
-
} else {
-
}
-
-
-
if ($event == 'chat') {
-
$sql_events = mysql_query("SELECT * FROM ahkchatusers where username='$loggedusername' and loggedin='yes'") or die ( mysql_error());
-
$lastmsg = $row["lastmsg"];
-
}
-
$sql_events2 = mysql_query("SELECT * FROM ahkchatchat where msgid>$lastmsg order by msgid desc") or die ( mysql_error());
-
$username = $row["username"];
-
$date = $row["date"];
-
$msg = $row["msg"];
-
$msgid = $row["msgid"];
-
if ($username <> "SERVER_MSG") {
-
}
-
else {
-
}
-
-
}
-
if ($msgid != '') {
-
$query = "UPDATE ahkchatusers SET lastmsg='$msgid' where username='$loggedusername' and loggedin='yes'";
-
}
-
}
-
-
if ($event == 'login') {
-
$sql_events3 = mysql_query("SELECT * FROM ahkchatusers where username='$username' limit 1") or die ( mysql_error());
-
$loggedin = $row["loggedin"];
-
}
-
if ($loggedin == 'yes') {
-
echo "Warning: W001";
-
}
-
if ($loggedin == 'no') {
-
$query2 = "UPDATE ahkchatusers SET loggedin='yes', ip='$ip' where username='$username'";
-
echo "success";
-
}
-
if ($loggedin == '') {
-
$query3 = "INSERT INTO ahkchatusers (username, loggedin, ip) VALUES ('$username', 'yes', '$ip')";
-
echo "success";
-
}
-
$query4 = "UPDATE ahkchatusers SET lastmsg='$num_rows'";
-
}
-
-
if ($event == 'logout') {
-
$query5 = "UPDATE ahkchatusers SET loggedin='no' where username='$username'";
-
}
-
-
if ($event == 'sendtext') {
-
$query6 = "INSERT INTO ahkchatchat (username, msg) VALUES ('$username', '$msg')";
-
}
-
-
if ($event == 'userlist') {
-
$sql_events4 = mysql_query("SELECT * FROM ahkchatusers where loggedin='yes'") or die ( mysql_error());
-
$username = $row["username"];
-
echo $username;
-
echo ' &()';
-
}
-
}
-
-
if ($event == 'ping') {
-
mysql_query("UPDATE ahkchatusers SET lastping=CURRENT_TIMESTAMP WHERE username='$username'") or die('Error, insert query failed');
-
}
-
-
if ($event == 'whoisactive') {
-
$query_myping = mysql_query("SELECT * FROM ahkchatusers where username='$username' limit 1") or die ( mysql_error());
-
$myping = $row["lastping"];
-
}
-
$query_username = mysql_query("SELECT * FROM ahkchatusers where loggedin='yes'") or die ( mysql_error());
-
$username = $row["username"];
-
-
$query_userping = mysql_query("SELECT * FROM ahkchatusers where username='$username' limit 1") or die ( mysql_error());
-
$theirping = $row["lastping"];
-
}
-
-
$diff = $mytime-$theirtime;
-
-
if ($diff >= 30) {
-
mysql_query("UPDATE ahkchatusers SET loggedin='no' where username='$username'") or die('Error, insert query failed');
-
mysql_query("INSERT INTO ahkchatchat (username, msg) VALUES ('SERVER_MSG', 'Quits: $username (Connection timed out)')") or die('Error, insert query failed');
-
}
-
}
-
}
-
-
-
//username ='$username'
-
//$query5 = "UPDATE ahkchatusers SET loggedin='no' where username='$username'";
-
//UPDATE ahkchatusers SET lastping = CURRENT_TIMESTAMP WHERE userid =2 LIMIT 1 ;
-
-
-
//2006-11-12 20:21:11
-
-
?>
ahkusers mysql table
-
CREATE TABLE `ahkchatusers` (
-
`userid` int(11) NOT NULL AUTO_INCREMENT,
-
`username` varchar(50) NOT NULL DEFAULT '',
-
`loggedin` char(3) NOT NULL DEFAULT '',
-
`ip` varchar(50) NOT NULL DEFAULT '',
-
`lastping` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
-
`lastmsg` int(11) NOT NULL DEFAULT '0',
-
PRIMARY KEY (`userid`)
-
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
chat.php
-
<?php
-
/* Warning codes, put to errorlog
-
W001: Username already in use
-
-
-
*/
-
-
-
$event = $_GET['event'];
-
$msg = $_GET['msg'];
-
$username = $_GET['loggedusername'];
-
$loggedusername = $_GET['loggedusername'];
-
-
//echo 'Connected to the database.';
-
} else {
-
}
-
-
-
if ($event == 'chat') {
-
$sql_events = mysql_query("SELECT * FROM ahkchatusers where username='$loggedusername' and loggedin='yes'") or die ( mysql_error());
-
$lastmsg = $row["lastmsg"];
-
}
-
$sql_events2 = mysql_query("SELECT * FROM ahkchatchat where msgid>$lastmsg order by msgid desc") or die ( mysql_error());
-
$username = $row["username"];
-
$date = $row["date"];
-
$msg = $row["msg"];
-
$msgid = $row["msgid"];
-
if ($username <> "SERVER_MSG") {
-
}
-
else {
-
}
-
-
}
-
if ($msgid != '') {
-
$query = "UPDATE ahkchatusers SET lastmsg='$msgid' where username='$loggedusername' and loggedin='yes'";
-
}
-
}
-
-
if ($event == 'login') {
-
$sql_events3 = mysql_query("SELECT * FROM ahkchatusers where username='$username' limit 1") or die ( mysql_error());
-
$loggedin = $row["loggedin"];
-
}
-
if ($loggedin == 'yes') {
-
echo "Warning: W001";
-
}
-
if ($loggedin == 'no') {
-
$query2 = "UPDATE ahkchatusers SET loggedin='yes', ip='$ip' where username='$username'";
-
echo "success";
-
}
-
if ($loggedin == '') {
-
$query3 = "INSERT INTO ahkchatusers (username, loggedin, ip) VALUES ('$username', 'yes', '$ip')";
-
echo "success";
-
}
-
$query4 = "UPDATE ahkchatusers SET lastmsg='$num_rows'";
-
}
-
-
if ($event == 'logout') {
-
$query5 = "UPDATE ahkchatusers SET loggedin='no' where username='$username'";
-
}
-
-
if ($event == 'sendtext') {
-
$query6 = "INSERT INTO ahkchatchat (username, msg) VALUES ('$username', '$msg')";
-
}
-
-
if ($event == 'userlist') {
-
$sql_events4 = mysql_query("SELECT * FROM ahkchatusers where loggedin='yes'") or die ( mysql_error());
-
$username = $row["username"];
-
echo $username;
-
echo ' &()';
-
}
-
}
-
-
if ($event == 'ping') {
-
mysql_query("UPDATE ahkchatusers SET lastping=CURRENT_TIMESTAMP WHERE username='$username'") or die('Error, insert query failed');
-
}
-
-
if ($event == 'whoisactive') {
-
$query_myping = mysql_query("SELECT * FROM ahkchatusers where username='$username' limit 1") or die ( mysql_error());
-
$myping = $row["lastping"];
-
}
-
$query_username = mysql_query("SELECT * FROM ahkchatusers where loggedin='yes'") or die ( mysql_error());
-
$username = $row["username"];
-
-
$query_userping = mysql_query("SELECT * FROM ahkchatusers where username='$username' limit 1") or die ( mysql_error());
-
$theirping = $row["lastping"];
-
}
-
-
$diff = $mytime-$theirtime;
-
-
if ($diff >= 30) {
-
mysql_query("UPDATE ahkchatusers SET loggedin='no' where username='$username'") or die('Error, insert query failed');
-
mysql_query("INSERT INTO ahkchatchat (username, msg) VALUES ('SERVER_MSG', 'Quits: $username (Connection timed out)')") or die('Error, insert query failed');
-
}
-
}
-
}
-
-
-
//username ='$username'
-
//$query5 = "UPDATE ahkchatusers SET loggedin='no' where username='$username'";
-
//UPDATE ahkchatusers SET lastping = CURRENT_TIMESTAMP WHERE userid =2 LIMIT 1 ;
-
-
-
//2006-11-12 20:21:11
-
-
?>
반응형
'AUTOHOTKEY > 스크립트' 카테고리의 다른 글
HTML 태그 적용 시키기. (0) | 2007.12.22 |
---|---|
글자를 포함한 스크린 샷을 찍습니다. (0) | 2007.12.22 |
XML 관련 함수 (0) | 2007.11.13 |
ado com (0) | 2007.11.10 |
AHK BBCodeWriter v7.0.2 - An offline BBCode Editor (0) | 2007.11.04 |
Comments