Jump to content

Gene

Active Members
  • Posts

    478
  • Joined

  • Last visited

Everything posted by Gene

  1. In one of my scripts I have a space 371p X 371p. All graphics displayed must fit in that space. Here is the code I use to resize any sized graphic to fit that space without changing the aspect ratio. $iX is the original width $iY is the original height $iW is the displayed width $iH is the displayed height This makes them larger or smaller as needed. It uses cross multiplication and division to determine the unknown dimension. $iX = Number($iX) $iY = Number($iY) If $iX > $iY Then $iW = 371 $iH = Int(((371*$iY)/$iX)) EndIf If $iX = $iY Then $iW = 371 $iH = 371 EndIf If $iY > $iX Then $iH = 371 $iW = Int(((371*$iX)/$iY)) EndIf Gene
  2. While I was making dinner I had a better idea. This one is a little more elegant and about a factor of 10 faster than the one I posted above. I considered adding code to eliminate duplicates of the text of interest, but decided against it. Gene A ZIP of the improved .Au3 and the INI file is attached. Global $sWorkVar, $sCodeStr, $var, $i $sFilePath = FileOpenDialog("Select HTML file to strip.", "My Computer", "HTML (*.html)|HTM (*.htm)", 1) $begin = TimerInit() $sFileContent = FileRead($sFilePath) $sWorkVar = $sFileContent $var = IniReadSection(@ScriptDir & "\Strip HTML.ini", "BoilerPlate") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0][0] $sWorkVar = StringReplace($sWorkVar, $var[$i][1], "") Next While StringInStr($sWorkVar, ">:<") $sWorkVar = StringReplace($sWorkVar, ">:<", "><") WEnd While StringInStr($sWorkVar, @CRLF) Or StringInStr($sWorkVar, @CR) Or StringInStr($sWorkVar, @LF) $sWorkVar = StringReplace($sWorkVar, @CRLF, "") $sWorkVar = StringReplace($sWorkVar, @CR, "") $sWorkVar = StringReplace($sWorkVar, @LF, "") WEnd EndIf While 1 $iBegin = StringInStr($sWorkVar, "<") $iEnd = StringInStr($sWorkVar, ">") + 1 If $iBegin = 0 And $iEnd = 1 Then ExitLoop EndIf $sCodeStr = StringMid($sWorkVar, $iBegin, $iEnd - $iBegin) While StringInStr($sWorkVar, $sCodeStr) $sWorkVar = StringReplace($sWorkVar, $sCodeStr, "") WEnd $sCodeStr = "" WEnd FileWrite(@ScriptDir & "\Stripped.TXT", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & $sWorkVar & @CRLF) $dif = Round((TimerDiff($begin) / 1000), 4) MsgBox(0, "Time To Process The File", $dif & " seconds...", 5) MsgBox(0, "Result", "The stripped data is " & $sWorkVar, 5) Exit
  3. Hi @zerocool60544, This one is a brute force method, and and can be used as a general purpose HTML Code stripper too. It isn't elegant, but it is quick and writes the results to a timestamped log. It uses an INI file to take care of current Boiler Plate items and if any new ones turn up you can easily add them. There is a ZIP file attached. Gene Edit: I used the $char var in debugging and forgot to take it out. Global $sWorkVar, $sWorkVar2, $iCodeFlag, $var, $i, $char $char = 0 $sFilePath = FileOpenDialog ( "Select HTML file to strip.", "My Computer", "HTML (*.html)|HTM (*.htm)" , 1 ) $begin = TimerInit() $sFileContent = FileRead($sFilePath) $sWorkVar = $sFileContent While 1 If StringLeft($sWorkVar, 1) = "<" Then $iCodeFlag = 1 EndIf If StringLeft($sWorkVar, 1) = ">" Then $iCodeFlag = 0 $sWorkVar = StringTrimLeft($sWorkVar, 1) EndIf While $iCodeFlag = 1 If StringLeft($sWorkVar, 1) = ">" Then ExitLoop $sWorkVar = StringTrimLeft($sWorkVar, 1) WEnd While $iCodeFlag = 0 If StringLeft($sWorkVar, 1) = "<" Then ExitLoop If Not StringInStr($sWorkVar, ">") Then ExitLoop $sWorkVar2 = $sWorkVar2 & StringLeft($sWorkVar, 1) $sWorkVar = StringTrimLeft($sWorkVar, 1) WEnd If Not StringInStr($sWorkVar, ">") Then $sWorkVar2 = $sWorkVar2 & $sWorkVar ExitLoop EndIf WEnd $var = IniReadSection(@ScriptDir & "\Strip HTML.ini", "BoilerPlate") If @error Then MsgBox(4096, "", "Error occured, probably no INI file.") Else For $i = 1 To $var[0][0] $sWorkVar2 = StringReplace($sWorkVar2,$var[$i][1],"") ;StringReplace ( "string", "searchstring", "replacestring") Next While StringInStr($sWorkVar2,@CRLF) Or StringInStr($sWorkVar2,@CR) Or StringInStr($sWorkVar2,@LF) $sWorkVar2 = StringReplace($sWorkVar2,@CRLF,"") $sWorkVar2 = StringReplace($sWorkVar2,@CR,"") $sWorkVar2 = StringReplace($sWorkVar2,@LF,"") WEnd EndIf FileWrite ( @ScriptDir & "\Stripped.TXT", @YEAR & "/" & @MON & "/" & @MDAY & " " & @HOUR & ":" & @MIN & ":" & @SEC & $sWorkVar2 & @CRLF ) $dif = Round ( (TimerDiff($begin)/1000) , 4 ) MsgBox(0,"Time To Process The File",$dif & " seconds...", 5) MsgBox(0,"Result","The stripped data is " & $sWorkVar2, 5 ) Exit
  4. Thanks, I'm sure a number of other people will appreciate this too! Gene
  5. He's Danish trying English, but miserably. From reading his other posts I ?think? he means that it is a good program, but he is not interested in it himself. Or something like that. Any way that was one of his more readable posts. There are several that even other Danish people can't figure out. Gene
  6. How about #include <File.au3> ; at the top of the script _FileWriteLog( $sLogPath, $sLogMsg ) Gene
  7. This is a large task, voices are somewhat like finger prints in terms of being relativly unique,there are many variations on a theme. You would have to analyze not the sound files per se, but the wave patterns in the sound streams from both sources separately. Next you would need to compare them as if you had plotted both on pieces of graph paper, put one over the other, then hold them up to a light and slide them back and forth to see if they match. That would be the physicality of it. In the software you would need to record the wave patterns at say every 1/60th of a second for the duration of the sound of interest. 1-- Once you have done that for each sound source, you would average the first 5 points in the second source and compare that average with that of the first 5 points of the original source. If it matches... 2-- Compare the averages of the next 5 points from each source, and so on, if you match for a second or more that definately be an area of interest. If it doesn't match... 3-- Then compare the average of the first 5 points of the second source with the 2nd - 6th points of the original source. Then compare the 3rd - 8th points' average from the second source with the 5 point average of the original source stepping through 1 point at a time. 4-- Repeat the steps above all the way through the original source. Whether or not you find matches switch the sources and repeat the steps above. then you will have compared each source with the other. While doing the comparisons I wouldn't look for exact matches, instead I would start matching if they were within 20% of each other, if that shows that everything matches anything, I would reduce the percentage to 19 and run the test again. Once you get the software to recognize the same word(s) in different recordings of the same person, you can begin to work on recognizing the same word from different people, then you can work on regional accents X as a second language and other issues. Of course I have assumed in the foregoing that both recordings are from the same person and that no attempt has been made to disguise one of the sources. I have necessarily symplified this in order to finish the response today. Gene Edit: Of, course if you or some one else knows of a specific com source for functions to perform the tasks above it would be easier.
  8. This is on a Tab. All the code on the Tab works as expected, except the 2nd and 3rd fields from the end. I can enter data in any of the 3, I can tab to any of the 3, I can mouse click in the last field, but not in the 2 before it. In the first 2 and last field I can get an I-beam cursor and click the insertion point into those fields, but the 2 next to last only show an arrow cursor. The problem all ready existed before I changed the colors. The kicker is, I copied the 2nd field, made it shorter, then copied it twice more to create the last 3 fields. All the code on the Tab is in the snippet below. Suggestions are appreciated. $SaveNewActBtn = GUICtrlCreateButton("Save Activity", 280, 270, 89, 25) GUICtrlSetFont($SaveNewActBtn, $iFontSize, $iFontWt, 0, $sFontFace) $Label7 = GUICtrlCreateLabel("New activities are added to the Current", 280, 232, 300, 25, $SS_CENTERIMAGE) $Label7a = GUICtrlCreateLabel("Name displayed in the upper left corner.", 280, 247, 300, 25, $SS_CENTERIMAGE) GUICtrlSetFont($Label7, $iFontSize, $iFontWt, 0, $sFontFace) $NewActivity = GUICtrlCreateInput("", 389, 270, 145, 25) GUICtrlSetFont($NewActivity, $iFontSize, $iFontWt, 0, $sFontFace) GUICtrlSetTip(-1, "Enter a new activity?") $Label7b = GUICtrlCreateLabel("Set time for", 280, 300, 300, 25, $SS_CENTERIMAGE) $Label7c = GUICtrlCreateLabel("this activity.", 280, 315, 300, 25, $SS_CENTERIMAGE) ;$Label7d = GUICtrlCreateLabel("Min:", 365, 307, 25, 25, $SS_CENTERIMAGE) $MinTime = GUICtrlCreateInput("", 395, 307, 45, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0x00FF00) GUICtrlSetTip(-1, "Minimum Time") ;$Label7e = GUICtrlCreateLabel("Max:", 451, 307, 26, 25, $SS_CENTERIMAGE) $MaxTime = GUICtrlCreateInput("", 481, 307, 45, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFFFF00) GUICtrlSetBkColor(-1, 0xFF0000) GUICtrlSetTip(-1, "Warning Time") ;$Label7f = GUICtrlCreateLabel("Warn:", 523, 307, 34, 25, $SS_CENTERIMAGE) $WarnTime = GUICtrlCreateInput("", 560, 307, 45, 25) GUICtrlSetFont(-1, 8, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0xFF0000) GUICtrlSetBkColor(-1, 0xFFFF00) GUICtrlSetTip(-1, "Maximum Time") Gene
  9. Look it up in the History page of the help file. Don't use the Help Search Tab, go to the History page click the right side of the page then use the Ctrl+F search to find it. DllStructDelete is obsolete when you find it you will also find the replacement. Gene
  10. Toggle Beta will do, but you will REALLY benefit from the AutoIt version of SciTe! Gene
  11. I don't know if you can or not. A couple of places to start looking...Try LARRY's posts for a new progress bar he created, second, look in GAFROST's posts for code to get and set the sound level. I don't know if it has provision for checking specific input's or not. From your question, I assume you have software to switch inputs and set volumes. Given that, you can probably use AutoIt to manipulate its controls. If I can remember the names of LARRY's and GAFROST's posts, I'll post the links to them. Gene
  12. What is PortPlay.EXE? Could you share the source? Gene
  13. I continue to pursue and modify Nuffilein's Chat Client. Messages are now timestamped when they arrive. I added the buttons I mentioned before for a "Wait a minute..." message and "Away from the PC now." I added a button to toggle message logging to a file On and Off. And one more button to allow the user to view the message log file. I don't remember if I talked about it last time but I also added code to put the Client window on top when a message arrives and to sound a weird beep. As with the issues below that works some of the time. I am still having some problems... part of the time the messages go zipping back and forth just as you would expect, the rest of the time it is inconsistent, I haven't been able to see a pattern. My PC is running Win2K 256Mb on a 1400+ AMD CPU, the other client is running on a 300Mhz, 192Mb Win98se PC, the chat server is running on a 233Mhz, 256Mb Win2K Server PC. The Win2K Server only does logons for 2 people, DNS for itself and 2 PCs runs the chat server and runs a compiled AutoIt script to check that the Internet connection is up about every half a minute. It isn't a speed demon, but that seems a very slight load to me. I'd really like to have comments critical or otherwise... Here is the code with the changes mintioned. ;client for 100client-server ;made by Marten Zimmermann #Include <Date.au3> #include <guiconstants.au3> Opt("WinTitleMatchMode",2) Global $connect_port = 34000 Global $fHandle, $iLogFlg, $sLogVar, $edit $LogMsg = "" $iLogFlg = 0 $sFileName = IniRead(@ScriptDir & "\client.ini", "File", "Name", "") $ip = "" $ip = IniRead(@ScriptDir & "\client.ini", "Server", "IPaddr", "") If $ip = "" Then $ip = InputBox("IP-Adress", "Gimme the IP-Adress of the Server", @IPAddress1) IniWrite(@ScriptDir & "\client.ini", "Server", "IPaddr", $ip) EndIf TCPStartup() $socket = TCPConnect($ip, $connect_port) If $socket = -1 Then Exit EndIf Do Do $user = "" $user = IniRead(@ScriptDir & "\client.ini", "Client", "User", "") If $user = "" Then $user = InputBox("Connected", "Connection established please type in your desired Username") IniWrite(@ScriptDir & "\client.ini", "Client", "User", $user) EndIf If @error = 1 Then $end = MsgBox(4, "End client", "Sure you want to exit?") If $end = 6 Then Exit EndIf EndIf Until StringLen($user) > 2 And StringLen($user) < 12 TCPSend($socket, "~~us:" & $user) Do $recv = TCPRecv($socket, 512) If $recv = "~~password" Then $pw = InputBox("Password required", "Please type in the password for " & $user, "", "*") TCPSend($socket, "~~pw:" & $pw) EndIf Until $recv = "~~accepted" Or $recv = "~~rejected" Or @error = 1 Until $recv = "~~accepted" Or $recv = "~~rejected" If $recv = "~~rejected" Then MsgBox(0, "Failure", "Maximum number of users reached or Server currently not availible, please try again later") Exit EndIf $CCT = "Chat Client - Connection established: " & $user $main = GUICreate($CCT, 500, 200) $input = GUICtrlCreateInput("", 10, 10, 280) $edit = GUICtrlCreateEdit("", 10, 40, 280, 110, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) ;$userlist = GUICtrlCreateEdit ("", 300, 10, 190, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) $userlist = GUICtrlCreateEdit("", 300, 10, 95, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) $send = GUICtrlCreateButton("Send", 10, 160, 280, 20, $BS_DEFPUSHBUTTON) $Wait = GUICtrlCreateButton("Wait a Moment", 406, 10, 85, 41, BitOR($BS_CENTER, $BS_MULTILINE)) $Away = GUICtrlCreateButton("Away from PC", 406, 55, 85, 41, BitOR($BS_CENTER, $BS_MULTILINE)) $LogMsg = GUICtrlCreateButton("", 406, 100, 80, 41, BitOR($BS_CENTER, $BS_MULTILINE)) GUICtrlSetData($LogMsg, "Msg Log Off") $ViewLog = GUICtrlCreateButton("View Log", 406, 145, 85, 41, BitOR($BS_CENTER, $BS_MULTILINE)) GUICtrlSetState($input, $GUI_FOCUS) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then $CCT = "Chat - Client shutting down in 5 seconds." If $iLogFlg = 1 Then _MsgLogging($fHandle, $CCT) Sleep(100) FileClose($fHandle) EndIf GUICtrlSetData($edit, $CCT) TCPSend($socket, "~~bye") Sleep(5000) TCPShutdown() Exit EndIf If $msg = $LogMsg Then If $iLogFlg = 0 Then $sFileName = IniRead(@ScriptDir & "\client.ini", "File", "Name", "") If $sFileName = "" Then $sFileName = FileSaveDialog( "Choose a log file.", @ScriptDir, "All Log Files (*.log)") IniWrite(@ScriptDir & "\client.ini", "File", "Name", $sFileName) EndIf $fHandle = FileOpen($sFileName, 1) $iLogFlg = 1 GUICtrlSetData($LogMsg, "Msg Log On") Else If $iLogFlg = 1 Then $iLogFlg = 0 GUICtrlSetData($LogMsg, "Msg Log Off") FileClose($fHandle) EndIf EndIf EndIf If $msg = $ViewLog Then If $sFileName <> "" Then If FileExists( $sFileName) Then Run( "Notepad.exe" & " " & $sFileName) Else $sFileName = "" EndIf Else MsgBox(0,"Help","A Client Chat Log has not been established. Click the" & @CRLF & "'Msg Log Off' button to establish a Client Chat Log file.") EndIf EndIf If $msg = $send Or $msg = $Wait Or $msg = $Away Then $sLogVar = GUICtrlRead($input) Select Case $msg = $send If GUICtrlRead($input) <> "" Then TCPSend($socket, GUICtrlRead($input)) ;TCPSend($socket, "~~pm:Gene " & _Now() & GUICtrlRead($input)) GUICtrlSetData($edit, _Now() & @CRLF & GUICtrlRead($input) & @CRLF & GUICtrlRead($edit)) If $iLogFlg = 1 Then _MsgLogging($fHandle, $sLogVar) EndIf GUICtrlSetData($input, "") EndIf Case $msg = $Wait $sMsg = IniRead(@ScriptDir & "\client.ini", "Messages", "Wait", "") TCPSend($socket, $sMsg) ;TCPSend($socket, "~~pm:Gene " & _Now() & @CRLF & $sMsg) GUICtrlSetData($edit, _Now() & @CRLF & $sMsg & @CRLF & GUICtrlRead($edit)) If $iLogFlg = 1 Then _MsgLogging($fHandle, $sLogVar) EndIf GUICtrlSetData($input, "") Case $msg = $Away $sMsg = IniRead(@ScriptDir & "\client.ini", "Messages", "Away", "") TCPSend($socket, _Now() & @CRLF & $sMsg) ;TCPSend($socket, "~~pm:Gene " & _Now() & @CRLF & $sMsg) GUICtrlSetData($edit, _Now() & @CRLF & $sMsg & @CRLF & GUICtrlRead($edit)) If $iLogFlg = 1 Then _MsgLogging($fHandle, $sLogVar) EndIf GUICtrlSetData($input, "") EndSelect EndIf $recv = TCPRecv($socket, 512) $err = @error If $recv = "~~bye" Then GUICtrlSetData($edit, "~~Connection Lost" & @CRLF & GUICtrlRead($edit)) TCPShutdown() ExitLoop EndIf If StringInStr($recv, "~~kick:") And StringInStr($recv, $user, 1) Then TCPSend($socket, "~~bye") GUICtrlSetData($edit, "You have been kicked!" & @CRLF & GUICtrlRead($edit)) Sleep(2000) TCPShutdown() ExitLoop EndIf $priv = 0 If StringInStr($recv, "~~pm:") And StringInStr($recv, $user) Then $user1 = $user & " " If StringInStr($recv, $user1) Then $recv = StringReplace($recv, "~~pm:", "", 1) $recv = StringReplace($recv, $user & " ", "", 1) GUICtrlSetData($edit, _Now() & @CRLF & $recv & " (private)" & @CRLF & GUICtrlRead($edit)) WinSetState ( $CCT, "", @SW_ENABLE ) WinSetState ( $CCT, "", @SW_RESTORE ) WinSetState ( $CCT, "", @SW_SHOW ) WinSetOnTop ( $CCT, "", 1) WinActivate ( $CCT) Sleep(200) WinSetOnTop ( $CCT, "", 0) _Beeper() $priv = 1 EndIf EndIf If StringInStr($recv, "~~accepted") Then $recv = "" EndIf If $recv <> "" And $err = 0 And Not StringInStr($recv, "~~users:") And Not StringInStr($recv, "~~accepted") And Not StringInStr($recv, "~~pm:") And Not StringInStr($recv, "~~kick:") And $priv = 0 Then GUICtrlSetData($edit, _Now() & @CRLF & $recv & @CRLF & GUICtrlRead($edit)) WinSetState ( $CCT, "", @SW_ENABLE ) WinSetState ( $CCT, "", @SW_RESTORE ) WinSetState ( $CCT, "", @SW_SHOW ) WinSetOnTop ( $CCT, "", 1) WinActivate ( $CCT) Sleep(200) WinSetOnTop ( $CCT, "", 0) _Beeper() EndIf If StringInStr($recv, "~~users:") Then $users = StringTrimLeft($recv, 8) $users = StringReplace($users, "|", @CRLF) GUICtrlSetData($userlist, $users) EndIf WEnd Func _Beeper() For $i = 720 To 360 Step - 2 $pi = 3.14159265358979 ;$x = sin($pi / 4) ;returns 0.707106781186547 which you should recognize as sqrt(2)/2 $degToRad = $pi / 180 $y = (Sin($i * $degToRad) * 700) Beep($y, 11+ (5 / 7)) Next EndFunc ;==>_Beeper Func _MsgLogging(ByRef $fHandle,$sLogVar) FileWrite($fHandle, @YEAR & "-" & @MON & "-" & @MDAY & "--" & @HOUR & ":" & @MIN & ":" & @SEC & " " & $sLogVar & @CRLF) EndFunc ;==>_MsgLogging Func OnAutoItExit() $CCT = "Chat - Client shutting down." If $iLogFlg = 1 Then _MsgLogging($fHandle, $CCT) Sleep(100) FileClose($fHandle) EndIf GUICtrlSetData($edit, $CCT & @CRLF & GUICtrlRead($edit)) TCPSend($socket, "~~bye") TCPCloseSocket($socket) TCPShutdown() EndFunc ;==>OnAutoItExit
  14. Search the Forum for _MEMRead. You will find several posts with examples and discussion. Gene
  15. You might still have the drive issue to deal with, if you do, you could use the concept at thread to write a small script to edit the Scite config file and then open Scite. Oh, now that I'm thinking about it, I hope you are backing up that flash drive every time it hits the home PC. I remember a year or two ago another AutoIter lost every thing recent and much that wasn't when their flash drive got scrambled. Gene
  16. JS, Here is a WAG aka Wild A__ed Guess. As long as you are not going to compile them, shouldn't a construct like this work? Since, as I look at it, its using literal strings, it might even compile. I realize it has a certain kludge factor to it, but if it works, that might be more important. On the other hand, I'm a little annoyed with anyone who flaunts a 4GB flash drive. Gene $InclDriveD = "D" $InclDriveE = "E" $InclDriveF = "F" $InclDriveG = "G" $InclDriveH = "H" $InclDriveI = "I" $InclDriveJ = "J" $InclDriveK = "K" If StringLeft(@ScriptDir,1) = $InclDriveD Then #include "D:\AutoIt3\Include\GUIConstants.au3" #include "D:\AutoIt3\Include\Arrays.au3.au3" EndIf If StringLeft(@ScriptDir,1) = $InclDriveE Then #include "E:\AutoIt3\Include\GUIConstants.au3" #include "E:\AutoIt3\Include\Arrays.au3.au3" EndIf If StringLeft(@ScriptDir,1) = $InclDriveF Then #include "F:\AutoIt3\Include\GUIConstants.au3" #include "F:\AutoIt3\Include\Arrays.au3.au3" EndIf If StringLeft(@ScriptDir,1) = $InclDriveG Then #include "G:\AutoIt3\Include\GUIConstants.au3" #include "G:\AutoIt3\Include\Arrays.au3.au3" EndIf If StringLeft(@ScriptDir,1) = $InclDriveH Then #include "H:\AutoIt3\Include\GUIConstants.au3" #include "H:\AutoIt3\Include\Arrays.au3.au3" EndIf If StringLeft(@ScriptDir,1) = $InclDriveI Then #include "I:\AutoIt3\Include\GUIConstants.au3" #include "I:\AutoIt3\Include\Arrays.au3.au3" EndIf If StringLeft(@ScriptDir,1) = $InclDriveJ Then #include "J:\AutoIt3\Include\GUIConstants.au3" #include "J:\AutoIt3\Include\Arrays.au3.au3" EndIf If StringLeft(@ScriptDir,1) = $InclDriveK Then #include "K:\AutoIt3\Include\GUIConstants.au3" #include "K:\AutoIt3\Include\Arrays.au3.au3" EndIf
  17. JS, Valik has written several times on the problem of where AutoIt does/should look for includes when installed via .ZIP. I'd search for his posts if I were in your circumstances. Gene
  18. Thank you for a thoughtful and thought provoking response. Gene
  19. Speaking of MemStat A.I. Smith, I tried that out too. It is a very good idea. I did modify the presentation presentation a bit to be a little neater and easier to read. Thank you for sharing it with us. The revised code is below. ; F12 Show, F11 Hide, Esc Close ;Written by AutoIt Smith, revised by Gene #include <GUIConstants.au3> ;#NoTrayIcon Local $Gui Local $MemStats Local $Mem Local $MemBuffer Local $Msg $Gui = GUICreate("MemStat", 350, 150, (@DesktopWidth - 300) / 2, (@DesktopHeight - 140) / 2, 0xCF0000 + 0x10000000 + 0x04000000) $MemStats = GUICtrlCreateLabel("", 10, 10, 320, 130, $SS_CENTER) ; The font set in the next line must be a fixed pitch font to maintain the format. GUICtrlSetFont($MemStats, 8, 400, 0, "Lucida Sans Typewriter") GUISetState() WinSetState("MemStat", "", @SW_SHOW) WinSetOnTop("MemStat", "", 1) $sUnit = " MB" $iOutLen = 36 $sCaption1 = "Total Physical RAM:" $sCaption2 = "Available Physical RAM:" $sCaption3 = "Total Pagefile:" $sCaption4 = "Available Pagefile:" $sCaption5 = "Total virtual:" $sCaption6 = "Available virtual:" While 1 $Msg = GUIGetMsg() $Mem = MemGetStats() $Mem[0] = "Memory Load (% of Memory currently in use): " & $Mem[0] & "%" & @CRLF While StringLen(StringFormat ( "%s" & "%.3f",$sCaption1, ($Mem[1]/1000) ) & $sUnit) < $iOutLen $sCaption1 = $sCaption1 & "-" WEnd $Mem[1] = StringFormat ( "%s" & "%.3f",$sCaption1, ($Mem[1]/1000) ) & $sUnit & @CRLF While StringLen(StringFormat ( "%s" & "%.3f",$sCaption2, ($Mem[2]/1000) ) & $sUnit) < $iOutLen $sCaption2 = $sCaption2 & " " WEnd $Mem[2] = StringFormat ( "%s" & "%.3f",$sCaption2, ($Mem[2]/1000) ) & $sUnit & @CRLF While StringLen(StringFormat ( "%s" & "%.3f",$sCaption3, ($Mem[3]/1000) ) & $sUnit) < $iOutLen $sCaption3 = $sCaption3 & "-" WEnd $Mem[3] = StringFormat ( "%s" & "%.3f",$sCaption3, ($Mem[3]/1000) ) & $sUnit & @CRLF While StringLen(StringFormat ( "%s" & "%.3f",$sCaption4, ($Mem[4]/1000) ) & $sUnit) < $iOutLen $sCaption4 = $sCaption4 & " " WEnd $Mem[4] = StringFormat ( "%s" & "%.3f",$sCaption4, ($Mem[4]/1000) ) & $sUnit & @CRLF While StringLen(StringFormat ( "%s" & "%.3f",$sCaption5, ($Mem[5]/1000) ) & $sUnit) < $iOutLen $sCaption5 = $sCaption5 & "-" WEnd $Mem[5] = StringFormat ( "%s" & "%.3f",$sCaption5, ($Mem[5]/1000) ) & $sUnit & @CRLF While StringLen(StringFormat ( "%s" & "%.3f",$sCaption6, ($Mem[6]/1000) ) & $sUnit) < $iOutLen $sCaption6 = $sCaption6 & " " WEnd $Mem[6] = StringFormat ( "%s" & "%.3f",$sCaption6, ($Mem[6]/1000) ) & $sUnit & @CRLF $Mem = $Mem[0] & $Mem[1] & $Mem[2] & $Mem[3] & $Mem[4] & $Mem[5] & $Mem[6] Select Case $Msg = -3 Or _IsPressed("0D") = 1 Exit Case $MemBuffer <> $Mem GUICtrlSetData($MemStats, $Mem) $MemBuffer = $Mem Case _IsPressed("7B") = 1 GUISetState(@SW_SHOW, $Gui) Case _IsPressed("7A") = 1 GUISetState(@SW_HIDE, $Gui) EndSelect WEnd Func _IsPressed($s_hexKey, $v_dll = 'user32.dll') Local $a_R = DllCall($v_dll, "int", "GetAsyncKeyState", "int", '0x' & $s_hexKey) If Not @error And BitAND($a_R[0], 0x8000) = 0x8000 Then Return 1 Return 0 EndFunc ;==>_IsPressed
  20. The main thing, inthewayboy, is that your scripting idea can be adapted to any zip tool syntax, and it is simple. Gene
  21. It was new to me. Gene I didn't realize there was a time limit.
  22. Hi Nuffilein, I tried your server and client and liked them. I have no interest in Internet Chat, I am interested in Intranet Chat. Mine and my wife's PCs are in different rooms on different floors. Not only that, but I have some hearing loss too. I hope to use a modified version of your server & client to communicate more directly than shouting up/down the stairs. I added an INI file to the client so they remember the IP address and user names. The server is running on my server which only provides DNS services and supports an AutoIt script that tracks my DSL uptime. I modified the client to write both outgoing and incoming messages to the on screen message log so you could see the dialog content. I thought it would be more useful if it POPPED to the top every time a message arrived so we would be sure to notice so I added that. I made the user list narrower so I could add acouple buttons, I plan to add a button to minimize the client and reply "Wait a minute, I'm in the middle of a thought." and another to toggle a flag on and off that will reply to any message "I've gone to the kitchen or the bathroom or I'm taking a nap." So, why am I telling you all this you ask. I'm having a problem and I'm not sure if it was already there, or if I caused it. On my wife's PC the running client only has the INI mods. The same on my PC. I'm running the most modified version from a separate folder on my PC, its UserId is Test1, my UI is GS, my wife's UI is CS. When I send a plain message from GS it sometimes appears on CS's window, it never appears on the Test1 window. If I send a ~~pm:Test1 message it appears on the Test1 window. When I send a ~~pm:GS message from Test1 it never appears on the GS window. If I send a plain message from Test1 it sometimes appears on the CS window, but never on the GS window. Is that clear as mud? Below is the modified version of the client script. I hope you can help me with this. Gene Client Code with several mods ;client for 100client-server ;made by Marten Zimmermann #include <guiconstants.au3> global $connect_port = 34000 $ip = "" $ip = IniRead(@ScriptDir & "\client.ini","Server","IPaddr", "") If $ip = "" Then $ip = InputBox ("IP-Adress", "Gimme the IP-Adress of the Server", @IPAddress1) IniWrite(@ScriptDir & "\client.ini","Server","IPaddr",$ip) EndIf tcpstartup() $socket = tcpconnect ($ip, $connect_port) if $socket = -1 then Exit EndIf Do Do $user = "" $user = IniRead(@ScriptDir & "\client.ini","Client","User", "") If $user = "" Then $user = InputBox ("Connected", "Connection established please type in your desired Username") IniWrite(@ScriptDir & "\client.ini","Client","User",$user) EndIf if @error = 1 Then $end = msgbox (4, "End client", "Sure you want to exit?") if $end = 6 Then Exit EndIf EndIf until StringLen ($user) > 2 and StringLen ($user) < 12 tcpsend ($socket, "~~us:" & $user) Do $recv = tcprecv ($socket, 512) if $recv = "~~password" Then $pw = InputBox ("Password required", "Please type in the password for " & $user, "", "*") tcpsend ($socket, "~~pw:" & $pw) EndIf until $recv = "~~accepted" or $recv = "~~rejected" or @error = 1 until $recv = "~~accepted" or $recv = "~~rejected" if $recv = "~~rejected" Then msgbox (0, "Failure", "Maximum number of users reached or Server currently not availible, please try again later") Exit EndIf $CCT = "Chat Client - Connection established: " & $user $main = GUICreate ($CCT, 500, 200) $input = GUICtrlCreateInput ("", 10, 10, 280) $edit = GUICtrlCreateEdit ("", 10, 40, 280, 110, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) ;$userlist = GUICtrlCreateEdit ("", 300, 10, 190, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) $userlist = GUICtrlCreateEdit ("", 300, 10, 95, 180, $ES_READONLY + $ES_MULTILINE + $WS_VSCROLL + $ES_AUTOVSCROLL) $send = GUICtrlCreateButton ("Send", 10, 160, 280, 20, $BS_DEFPUSHBUTTON) GUICtrlSetState ($input, $GUI_FOCUS) GUISetState(@SW_SHOW) while 1 $msg = GUIGetMsg() if $msg = $GUI_EVENT_CLOSE Then $CCT = "Chat - Client shutting down in 5 seconds." GUICtrlSetData ($edit, $CCT) tcpsend ($socket, "~~bye") sleep (5000) tcpshutdown() Exit EndIf ; The mods just below were temporary while checking if ~~pm: could be used to force delivery/aceptance if $msg = $send Then if guictrlread ($input) <> "" Then If @IPAddress1 = "192.168.0.180" Then ;MsgBox(0,"Info.","guictrlread($input) = " & guictrlread($input) & " " & @IPAddress1, 2) tcpsend ($socket, "~~pm:test1 " & guictrlread($input)) Sleep(100) tcpsend ($socket, "~~pm:CS " & guictrlread($input)) EndIf If @IPAddress1 = "192.168.0.183" Then ;MsgBox(0,"Info.","guictrlread($input) = " & guictrlread($input) & " " & @IPAddress1, 2) tcpsend ($socket, "~~pm:GS " & guictrlread($input)) tcpsend ($socket, "~~pm:test1 " & guictrlread($input)) EndIf ;tcpsend ($socket, guictrlread($input)) ;MsgBox(0,"Info.","guictrlread($input) = " & guictrlread($input)) GUICtrlSetData ($edit, guictrlread($input) & @crlf & guictrlread ($edit)) GUICtrlSetData ($input, "") EndIf EndIf $recv = tcprecv ($socket, 512) $err = @error if $recv = "~~bye" Then GUICtrlSetData ($edit, "~~Connection Lost" & @CRLF & GUICtrlRead($edit)) tcpshutdown() ExitLoop EndIf if StringInStr ($recv, "~~kick:") and stringinstr($recv, $user, 1) then TCPSend ($socket, "~~bye") GUICtrlSetData ($edit, "You have been kicked!" & @crlf & guictrlread($edit)) sleep (2000) TCPShutdown() ExitLoop EndIf $priv = 0 if StringInStr ($recv, "~~pm:") and stringinstr($recv, $user) then $user1 = $user & " " if StringInStr ($recv, $user1) Then $recv = StringReplace ($recv, "~~pm:", "", 1) $recv = StringReplace ($recv, $user & " ", "", 1) GUICtrlSetData ($edit, $recv & " (private)" & @crlf & guictrlread($edit)) WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 1 ) WinActivate ( "Chat Client - Connection established: " & $user) Sleep(200) WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 0 ) $priv = 1 EndIf EndIf if stringinstr ($recv, "~~accepted") then $recv = "" EndIf if $recv <> "" and $err = 0 and not StringInStr ($recv, "~~users:") and not StringInStr ($recv, "~~accepted") and not StringInStr($recv, "~~pm:") and not stringinstr($recv, "~~kick:") and $priv = 0 Then GUICtrlSetData ($edit, $recv & @CRLF & GUICtrlRead($edit)) WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 1 ) WinActivate ( "Chat Client - Connection established: " & $user) Sleep(200) WinSetOnTop ( "Chat Client - Connection established: " & $user, "", 0 ) EndIf if StringInStr($recv, "~~users:") then $users = StringTrimLeft ($recv, 8) $users = StringReplace ($users, "|", @crlf) GUICtrlSetData ($userlist, $users) EndIf WEnd Func OnAutoItExit() $CCT = "Chat - Client shutting down." GUICtrlSetData ($edit, $CCT & @CRLF & GUICtrlRead($edit)) TCPSend( $socket, "~~bye" ) TCPCloseSocket( $socket ) TCPShutDown() EndFunc
  23. OK, it just looked that way. Gene
  24. Why do you think he should only look at one thread out of several that address the same or similar issues" Gene
×
×
  • Create New...