Jump to content

DavidKarner

Active Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by DavidKarner

  1. I found issues using this UDF when the remote file was in a subfolder. It was not in the request but in the writing out the response. I changed a line in _TFTP_DATA: $WriteOutTo = FileOpen($FileLocalPath & "\" & $TFTPGetFilename, 2) to $WriteOutTo = FileOpen($FileLocalPath & "\" & StringMid( $TFTPGetFilename, StringInStr( $TFTPGetFilename, "\", 0, -1 ) + 1 ), 2) So downloading the remote file: subfolder\filetoget.txt will download in your local target path as filetoget.txt. Otherwise, you would have had to pre-created the subfolder in your local target path to make it work.
  2. #include <WinAPI.au3> MsgBox(0,_WinAPI_GetFirmwareEnvironmentVariable(),0) Func _WinAPI_GetFirmwareEnvironmentVariable() Local $sName = "" Local $sGUID = "{00000000-0000-0000-0000-000000000000}" Local $aRet = DllCall("Kernel32.dll", "dword", _ "GetFirmwareEnvironmentVariableW", "wstr", $sName, _ "wstr", $sGUID, "wstr", "", "dword", 4096) ; ERROR_INVALID_FUNCTION 1 (0x1) ; ERROR_NOACCESS 998 (0x3E6) Local $LastError = _WinAPI_GetLastError() If $LastError == 1 Then Return "Legacy" ElseIf $LastError == 998 Then Return "UEFI" Else Return "Unknown" EndIf EndFunc
  3. This was very helpful and I thought I would add my comments. The reason why the $lpExitCode was not updated was because the function expects a pointer (not a value). Here is another example using your logic which also works. $PROCESS_QUERY_INFORMATION = 1024 $Process = Run( "XCOPY.EXE A B", @SystemDir ) If ProcessExists( $Process ) Then ; Open Handle to retrieve return code later Local $ProcessHandle = DllCall('kernel32.dll','hwnd','OpenProcess','int',$PROCESS_QUERY_INFORMATION,'int',0,'int',$Process) ProcessWaitClose( $Process ) ; Retrieve return code from call Local $ReturnCode = DllStructCreate("int") DllCall("kernel32","hwnd","GetExitCodeProcess","int",$ProcessHandle[0],"int_ptr",DllStructGetPtr($ReturnCode,1)); Here we get the code DllCall("kernel32","hwnd","CloseHandle","int",$ProcessHandle[0]); Supposed to close something. DllStructGetData($ReturnCode,1) ConsoleWrite( "Got it - " & DllStructGetData($ReturnCode,1) ) Else ConsoleWrite( "Missed it" ) EndIf This should return the expected error code of '4' for xcopy not finding the files specified. (Assuming you don't have files called 'A' and 'B')
  4. You do not need to use the ScreenCapture function to do this as it is designed to create a file. Simply use a SEND command to send PrtSc to the system which windows will then copy the screen image to the clipboard. Then after you open your word document, just paste it with a Ctrl-V. Send("^v")
  5. ZenMaster, There is no "EnvDelete" because you still use EnvSet to perform this action. EnvSet("FOO","BAR") ; Set FOO = BAR EnvSet("FOO") ; Deletes FOO from environment. From the AutoIt help file... EnvSet ( "envvariable" [, "value"] ) envvariable - Name of the environment variable to set. value - [optional] Value to set the environment variable to. If a value is not used the environment variable will be deleted.
  6. Umm, so in your original post the invite.txt just contained a list of numbers incrementing by 1? $Index = 100000000 While 1 $usercode = FileReadLine($file) if @error = -1 then exitloop Run(@ProgramFilesDir&"\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_inv...er_code=("&$Index&")") WinWaitActive("[CLASS:MozillaUIWindowClass]") sleep(5000) ControlSend("[CLASS:MozillaUIWindowClass]","","","^{F4}") $Index = $Index + 1 wend
  7. Just update your Gstart function Func Gstart() While 1 MouseMove(525,452) MouseDown("left") MouseUp("left") sleep(500) MouseDown("left") MouseUp("left") sleep(500) MouseDown("left") MouseUp("left") $var = PixelGetColor(525,452) if $var = 14869218 then GLast() elseif Not $var = 16777023 then ExitLoop EndIf Wend Endfunc BTW, you might want to put a sleep(1000) or something in your main loop to keep the CPU utilization a low.
  8. Because that is exactly what it was coded to do. =) If you want to read the entire file and process each line, then you need to change your loop logic. Look at the AutoIt help for FileReadLine. It gives pretty good examples, but basically it is something like... $file = FileOpen("c:\Backup\invite.txt", 0) while 1 $usercode = FileReadLine($file) if @error = -1 then exitloop Run(@ProgramFilesDir&"\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_inv...er_code=("&$usercode&")") WinWaitActive("[CLASS:MozillaUIWindowClass]") sleep(5000) ControlSend("[CLASS:MozillaUIWindowClass]","","","^{F4}") wend FileClose($file)
  9. I think you could do something like... Dim $Array[2] = {$oIE1,$oIE2} For $Index = 0 To Ubound( $Array) -1 $oFrame = _IEFrameGetObjByName ($Array[$Index], "up") $sHTML = _IEDocReadHTML ($oFrame) $result = StringLeft($shtml, 18) If $result = "<HTML><HEAD><Meta" Then sleep(2*1000) else $link=FileReadLine ("bannerlinks.txt", $i ) _IENavigate ($oIE1, $link) $i = $i + 1 EndIF Sleep(2 * 1000) Next Not sure if my array initialization is correct, but this should do what you want.
  10. I did see that thread. I am not sure what dll/call in windows I could leverage. I do have a functional python script which works. I just prefer using AutoIt as it is easy to read, compile, and everyone in my work environment is very familar with updating AutoIt scripts.
  11. You need to build the string for the run command. (@ProgramFilesDir& '\mozilla firefox\firefox.exe http://www.reefmonkey.com/network/send_inv...ser_code=(' & $usercode & ')')
  12. I have searched the forums and there are several discussions on this and I from what I gather AutoIt does not seem to allow one to send UDP packets from the same port it is listening on. I.E. I want to listen on port 4011 for incoming UDP packets and respond to them from port 4011. My question is does anyone know of a DLL call I can make from within AutoIt to allow me to specify the source port for the UDP packet? Scenario: I PXE boot Windows Vista WinPE. When BOOTMGR.EXE is TFTP'd down it calls back to the TFTP server on port 4011 looking for an DHCP ACK to confirm which TFTP server it should pull the BCD from. After 16 seconds (8 tries, 2 seconds a piece) it will time out and proceeding with pulling the BCD file from the TFTP server. Normally WDS or RIS has this Proxy DHCP service running on port 4011, but I am using TFTPD32.EXE. I am trying to write a Proxy DHCP server for PXE booting Windows Vista WinPE using AutoIt to answer back so that it immediately starts loading the BCD instead of waiting for the 16 second time out. I know that the AutoIt UDP functions will use a dynamic source port and that no one should care where the packets come from. However, BOOTMGR.EXE does seem to care. The only differences I have between a working ACK and the failing ACK from AutoIt is the source port. Thanks
  13. Yes. I was able to add another HotKetSet HotKeySet( "^{BREAK}","ControlBreak" ) And I changed the code as well to send the event. Func ControlBreak() If WinActive( $Handle, "" ) Then ConsoleWrite( "You hit Control-Break" & @CRLF ) DllCall( "Kernel32.dll","int","GenerateConsoleCtrlEvent","dword",1,"dword",0) Else HotKeySet( "^{BREAK}" ) Send( "^{BREAK}" ) HotKeySet( "^{BREAK}","ControlBreak" ) EndIf EndFunc
  14. I was able to do the following which traps CTRL-C (but not CTRL-Break). Still hoping to find a way to get the GetConsoleMode/SetConsoleMode calls working. #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** Local $DllValue, $Handle $DllValue = DllCall( "Kernel32.dll","hwnd","GetConsoleWindow") $Handle = $DllValue[0] HotKeySet( "^c","ControlC" ) While True Sleep(10000) Wend Func ControlC() If WinActive( $Handle, "" ) Then ConsoleWrite( "You hit Control-C" & @CRLF ) Else HotKeySet( "^c" ) Send( "^c" ) HotKeySet( "^c","ControlC" ) EndIf EndFunc
  15. I have a console mode script which I need trap CTRL-C so that my program can perform some cleanup before exiting. The OnAutoItExist() function does not trigger on CTRL-C or CTRL-Break events. Per some comments from Valik, he indicated that I could work around this issue by using DLLCall and changing the way the console processes CTRL-C. However, I am struggling with implementing this technique and was hopping someone could offer some assistance. I am trying to use the Kernel32.dll call "GetConsoleMode" to determine to current mode so I can modify it to disable the ENABLE_PROCESSED_INPUT option. In the script below I am trying both GetConsoleWindow and GetStdHandle to return a handle and query GetConsoleMode but in both cases the GetConsoleMode returns a failure and reports that it is an invalid handle. Does anyone know how to determine the correct ConsoleHandle that is required to pass into the GetConsoleWindow function? #Region;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Change2CUI=y #EndRegion;**** Directives created by AutoIt3Wrapper_GUI **** Const $STD_INPUT_HANDLE = -10 Local $DllValue $DllValue = DllCall( "Kernel32.dll","hwnd","GetConsoleWindow") ConsoleWrite("Handle: " & $DllValue[0] & " ConsoleMode: " & _GetConsoleMode( $DllValue[0] ) & @CRLF ) $DllValue = DllCall( "Kernel32.dll","hwnd","GetStdHandle","dword",$STD_INPUT_HANDLE) ConsoleWrite("Handle: " & $DllValue[0] & " ConsoleMode: " & _GetConsoleMode( $DllValue[0] ) & @CRLF ) Func _GetConsoleMode( $Handle ) ; Create Key Structure Local $DllStructure = DllStructCreate( "Dword iConsoleMode" ) DllCall( "Kernel32.dll","int","GetConsoleMode","hwnd",$Handle,"ptr",DllStructGetPtr( $DllStructure)) Return DllStructGetData( $DllStructure, "iConsoleMode" ) EndFunc
  16. I just download the game and tried it out. Works fairly well. In case you were looking for some feedback.... One is allowed to change the bet during a hand. I believe the "Bet" menu should be disabled unless the "Deal" button is available. One is allowed to bet more than they have and one can play with negative money; however, maybe that is intentional.
  17. I believe that the modification date/time stamp of a directory (at least for windows filesystems) matches the date/time stamp of the last change to the file contents of a directory. You might simply be able to track in a log file that last modification time of the directory and check it's current modification time against the log to see if it has changed. This can help identify if files have been added or removed, but if an existing file is modified it will not detect that change. However, I am not sure if that is sufficient for your needs.
  18. I had the same problem this morning. The latest round of Symantec updates falsely detected virus on all my compiled 3.2.8.1 scripts. It thought they contained the following virus: W32.Blastclan I was able to install the latest autoit 3.2.10 today and compile the same scripts and they were not detected as viruses. In addition, I found the compiling those scripts with an earlier versin of autoit 3.2.4.9 also worked fine. Hope this helps you out. David
  19. You need to keep a loop around the case statement checking for the exit button. Have the loop exit on your two conditions: One, a user clicks exit. Two, the imagex PID has terminated. You probably do not need the splashtexton at all and can include that information as part of your GUI
×
×
  • Create New...