Jump to content

Fzz

Active Members
  • Posts

    24
  • Joined

  • Last visited

Everything posted by Fzz

  1. This looks like a lot of fun. I didn't see AddSphereSceneNode() but seems to be a function in some of the other examples on their site. Are these just a subset of the functions or am I missing something?
  2. Not sure what the etiquette is for reviving an old post but this look like exactly what I need but I'm having a problem with it. Sorry if this should be a new post but the code is here so here goes. The last post of the code works great unless two applications think it's their turn to create the semaphore at the same time. Then it appears the semaphore gets "corrupted" and can no longer be created once it has been released. I've added a few lines to simulate what I mean. Global $hSemaphoreGlobal Global $hSemaphoreGlobal2 ConsoleWrite("Semaphore Exists: " & (_SemaphoreExists("WDTCodeRunning") = 1) & @CRLF) $hSemaphoreGlobal = _CreateSemaphore("WDTCodeRunning") ConsoleWrite("Semaphore Created: " & $hSemaphoreGlobal & @CRLF) ConsoleWrite("Semaphore Exists: " & (_SemaphoreExists("WDTCodeRunning") = 1) & @CRLF) $hSemaphoreGlobal2 = _CreateSemaphore("WDTCodeRunning"); remove these 2 lines and it works fine ConsoleWrite("Semaphore Created: " & $hSemaphoreGlobal2 & @CRLF) ConsoleWrite("Semaphore Closed: " & (_CloseSemaphore($hSemaphoreGlobal) = 1) & @CRLF) ConsoleWrite("Semaphore Exists: " & (_SemaphoreExists("WDTCodeRunning") = 1) & @CRLF) ConsoleWrite("Semaphore Exists: " & (_SemaphoreExists("WDTCodeRunning") = 1) & @CRLF) $hSemaphoreGlobal = _CreateSemaphore("WDTCodeRunning") ConsoleWrite("Semaphore Created: " & $hSemaphoreGlobal & @CRLF) ConsoleWrite("Semaphore Exists: " & (_SemaphoreExists("WDTCodeRunning") = 1) & @CRLF) ConsoleWrite("Semaphore Closed: " & (_CloseSemaphore($hSemaphoreGlobal) = 1) & @CRLF) ConsoleWrite("Semaphore Exists: " & (_SemaphoreExists("WDTCodeRunning") = 1) & @CRLF) Func _SemaphoreExists($szSemaphoreName) Local $hSemaphore = DllCall("Kernel32.dll", "hwnd", "OpenSemaphore", "int", BitOR(0x1F0001, 0x0002), "int", 1, "str", $szSemaphoreName) If IsArray($hSemaphore) And $hSemaphore[0] Then DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $hSemaphore[0]) EndIf Local $aGLE = DllCall("Kernel32.dll", "int", "GetLastError") If IsArray($aGLE) And $aGLE[0] = 127 Then Return 1 Return 0 EndFunc;==>_SemaphoreExists Func _CreateSemaphore($szSemaphoreName, $nAllowMax = 1) Local $hSemaphore = DllCall("Kernel32.dll", "int", "CreateSemaphore", "int", 0, "long", 1, "long", $nAllowMax, "str", $szSemaphoreName) Local $aGLE = DllCall("Kernel32.dll", "int", "GetLastError") If (IsArray($aGLE) And $aGLE[0] = 183) Then Return 0 Return $hSemaphore[0] EndFunc;==>_CreateSemaphore Func _CloseSemaphore($hSemaphore) Local $aCH = DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $hSemaphore) ;Debug .... Local $aGLE = DllCall("kernel32.dll", "int", "GetLastError") ConsoleWrite("LastError on closing: " & $aGLE[0] & @CRLF) If IsArray($aCH) And $aCH[0] > 0 Then Return 1 Return 0 EndFunc;==>_ReleaseSemaphore I would think that the second global would fail as it does but then it should go on as usual and allow the semaphore to be released and recreated as usual. Thanks!
  3. Ran across this post when looking for a way to simply pull the date and time from an NTP server. Couldn't find a good example so I wrote this. Seems to work ok. #include <Date.au3> $ntpServer="pool.ntp.org" UDPStartup() Dim $socket = UDPOpen(TCPNameToIP($ntpServer), 123) If @error <> 0 Then MsgBox(0,"","Can't open connection!") Exit EndIf ;$status = UDPSend($socket, MakePacket("1b0e010000000000000000004c4f434ccb1eea7b866665cb00000000000000000000000000000000cb1eea7b866665cb ")) $status = UDPSend($socket, MakePacket("1b0e01000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ")) If $status = 0 Then MsgBox(0, "ERROR", "Error while sending UDP message: " & @error) Exit EndIf $data="" While $data="" $data = UDPRecv($socket, 100) sleep(100) WEnd UDPCloseSocket($socket) UDPShutdown() $unsignedHexValue=StringMid($data,83,8); Extract time from packet. Disregards the fractional second. ;MsgBox(0, "UDP DATA", $unsignedHexValue) $value=UnsignedHexToDec($unsignedHexValue) $TZinfo = _Date_Time_GetTimeZoneInformation() $TZoffset=$TZinfo[1]*-1 $UTC=_DateAdd("s",$value,"1900/01/01 00:00:00") MsgBox(0,"","Time from NTP Server UTC: "&$UTC&@CRLF& _ "Time from NTP Server Local Offset: "&_DateAdd("n",$TZoffset,$UTC)&@CRLF& _ "Time from Local Computer Clock: "&_NowCalc()) ;************************************************************************************************** ;** Fuctions ************************************************************************************** ;************************************************************************************************** Func MakePacket($d) Local $p="" While $d $p&=Chr(Dec(StringLeft($d,2))) $d=StringTrimLeft($d,2) WEnd Return $p EndFunc ;************************************************************************************************** Func UnsignedHexToDec($n) $ones=StringRight($n,1) $n=StringTrimRight($n,1) Return dec($n)*16+dec($ones) EndFunc ;**************************************************************************************************
  4. So awesome! Thank you Zedna! Used: http://www.autoitscript.com/forum/index.ph...hl=a2d&st=0 #include "A2D.au3";Include the A2D header $hWnd = GUICreate("Bounce", 1000, 700) GUISetState() _A2DStartup("a2d.dll") if (_A2DFailed(_A2DCreateDevice($hWnd, 1000, 700, $A2DFORMAT_A8R8G8B8))) Then MsgBox(0, "Error", "An error occurred while created the A2D Device!") _A2DShutdown("a2d.dll") Exit EndIf $x=20 $y=0 $vx=3 $vy=0 _A2DClear(0xFFECECEC);Clear the screen to blue. (AARRGGBB) While(GUIGetMsg() <> -3) ;_A2DClear(0xFFECECEC);Clear the screen to blue. (AARRGGBB) _A2DBeginScene() _A2DDrawRectangle($x-1, $y-1, 12, 12, 0xFF000000) _A2DDrawRectangle($x, $y, 10, 10, 0xFF00FF00) _A2DEndScene() _A2DPresentScene() MoveBall() WEnd _A2DReleaseDevice() _A2DShutdown("../a2d.dll") Func MoveBall() $vy=$vy+1 If $y+$vy>690 then $vy-=3 $vy*=-1 EndIf If $x+$vx>990 or $x+$vx<0 then $vx*=-1 EndIf $x=$x+$vx $y=$y+$vy if $y>690 then $y=690 ;if $y>685 and $x>985 then sleep(1000000) EndFunc Func CLOSEClicked() Exit EndFunc Uncomment ;_A2DClear(0xFFECECEC) in loop to remove trails. Thanks again! Fz
  5. Trying to start some stuff with graphics and I'm getting lots of problems with flicker. I saw a nice example using bitblit but I'm not sure if I can apply that to this example. I'm probably just doing something stupid. #include <GUIConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $mainwindow = GUICreate("Bounce", 1000, 730) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $graphic=GuiCtrlCreateGraphic(0, 30, 1000,730) GUISetState(@SW_SHOW) $x=20 $y=0 $vx=3 $vy=0 GUICtrlSetGraphic($graphic,$GUI_GR_COLOR, 0x0, 0x00ff00) GUICtrlSetGraphic($graphic,$GUI_GR_PENSIZE, 1) GUICtrlSetGraphic($graphic,$GUI_GR_ELLIPSE, $x,$y,11,11) GUICtrlSetGraphic($graphic,$GUI_GR_REFRESH) While 1 Sleep(10) MoveBall() WEnd Func MoveBall() $vy=$vy+1 If $y+$vy>690 then $vy-=3 $vy*=-1 EndIf If $x+$vx>990 or $x+$vx<0 then $vx*=-1 EndIf $x=$x+$vx $y=$y+$vy if $y>690 then $y=690 if $y>685 and $x>985 then sleep(1000000) GUICtrlSetGraphic($graphic,$GUI_GR_ELLIPSE, $x,$y,11,11) GUICtrlSetGraphic($graphic,$GUI_GR_REFRESH) EndFunc Func CLOSEClicked() Exit EndFunc Thanks for looking. Fz
  6. Your memory leak is probably because there is actually a memory leak in the FileReadLine function when using the unicode version of AutoIt against a non unicode version of data. Compiling your scirpt using the "Comiple for ANSI" option checked may help your problem. It did for me. Memory Leak with FileReadLine
  7. Wow, good find. That will certainly get my bot back in business. Timmy bot thanks you! And me too.
  8. Yep...shouldn't use much CPU. How about the RAM?
  9. Looking for some help on this. I have a chat bot that watches a log file for new entries. If the line is directed towards the bot it is acted on. This technique of FileReadLine() in a loop to watch the end of a file being written to has worked for me for a long time. Since the latest version I've been leaking memory to a max of 2 gig in about 2 hours. Here is an extremely over simplified version of the bot to demonstrate the leak. Normally I loop every 1/4 second but in this example I've sped it up for full effect. ; Leak example ; ; Create empty file for this test. $tmpFile=FileOpen("MyChatLog.txt",2) FileClose($tmpFile) Sleep(1000) ; Open File for reading $theLog=FileOpen("MyChatLog.txt",0) ; Watch for additions to the end of the file While 1 $NewData=FileReadLine($theLog) if $NewData<>"" then ParseData() EndIf Sleep(10) WEnd Func ParseData() If StringInStr($NewData,"hi") Then MsgBox(0,"","Hi to you too!") EndIf EndFunc You can watch with your favorite process manager as autoit chews through the memory. Thanks for anyone who can help me with this. Fz
  10. I can't register on the new site...not getting the confirmation e-mails. Is anyone able to get on?
  11. Well, I thought I might take a look at this since I found this cool site: http://ntlmaps.sourceforge.net/ and this cool site: http://www.innovation.ch/personal/ronald/ntlm.html I was definately able to tunnel out using the ntlmaps-setup-0.9.9.5.exe from the above site. Does Autoit no longer accept end user code contributions? Thanks, Fz
  12. Not to pile on...but I too am trying to get a file through an ISA proxy server. Manually, authenticating through IE works, but would like to use AutoIt. I haven't tried the beta but will gladly use that if it's known to work. Thanks! Fz
  13. ScriptKitty: No, ALL other text on that window does show up in Visible Window Text, but not what I need. Larry: I too Googled it yesterday and saw no hits. /cry I might try doing a search with a debugger in memory for the string and see if I can extract that same location when I need it. I'm starting to get out of my comfort zone though. =-) Thanks for everyone's help!
  14. Well, those are great ideas but they don't work. I was already using the hiddentext one but hadn't tried the child thing. Here's the dialog box: I can get all of the text on this dlg except what I really need at the top. Obviously the text is in memory somewhere. Anyway to get access to this info short of a debugger?
  15. Nope, it's just static text...although there is some color at the end of it...it's actually in a dialog box from an NWAdmin32 app for GroupWise. It looks like:
  16. No, I gave focus to the control and then ^A^C and tried to past the contents but it just had my previous contents in the clipboard. I also tried to... ControlSetText ( "Edit Membership", "", "THiStatic1", "Arrghh!" ) ...with no luck.
  17. Yes, spy show nothing as well. Showes the control name with no text. I have given focus to that control and tryied ^C but I didn't try ^A first. I'll try that next. Thanks!
  18. @error is 0 and it returns "" not NUL but I think you knew what I ment.
  19. I have a control that I want to get the text from. The control is THiStatic1. I know this is the right control because when I hide the control with... ControlHide ( "Edit Membership", "", "THiStatic1" ) ...the text I want disappears off the window. However, ControlGetText for this control returns NUL. My question is, Does ControlGetText do some error checking to prevent it from returning garbage or is there a way I can get the raw data from this control. Just not sure how ControlGetText gets it's text. Thanks, Fz
  20. Hehe. I didn't even notice. Thanks! Fz
  21. Hi, Can anyone point me to the Syntax file and Clip library for AutoIt v3. I know there were some available. Not a problem if they are out of date. Thanks! Fz
  22. I did a search for this and then realized...there's not much here. Nice new look though. I'm trying to do a search and replace on some registry files that I've exported. When I try to open the files with FileReadLine() it give me junk. Actually is give me this:ÿþW If I open the .reg file in notepad and then paste it into a new reg file it works fine. It looks like it's a problem with the file I exported with regedit. Also, when I open it with NotepadEx it says the format is "DOS / Unicode (UTF16-LE) If I just type it out from dos...it looks ok. Any ideas? Thanks Fz
×
×
  • Create New...