Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/12/2013 in all areas

  1. Set the workdir parameter in the Run() statement to the location the files are located. Jos
    1 point
  2. mikell

    GUI keeps running

    It looks like when the code is running something makes the menu items remain disabled while buttons are not, but it's impossible to know why without seeing the whole script
    1 point
  3. water

    GUI keeps running

    Without seeing your code it is impossible to help
    1 point
  4. Okay, I made it. I used Ws2_32.dll's functions. Here is my code: UDPStartup() $hWs2_32 = DllOpen("ws2_32.dll") $hSocket = _WinsockCreateSocket(2, 2, 17) _WinsockBind($hSocket, "192.168.178.20", 53); The source address and port for the Socket. The IP must be your LAN IP. I've found that 127.0.0.1 does not work. _WinsockConnect($hSocket, "192.168.178.22", 65432); The destination IP and port. _WinsockSend($hSocket, "This UDP Packet came from Port 53!") Func _WinsockCreateSocket($Address_Family, $Socket_Type, $Protocol) $iRet = DllCall($hWs2_32, "int", "socket", "int", $Address_Family, "int", $Socket_Type, "int", $Protocol) Return $iRet[0] EndFunc Func _WinsockBind($hSocket, $IP, $Port) $hAddr = _SocketAddr($IP, $Port) $iRet = DllCall($hWs2_32, "int", "bind", "uint", $hSocket, "ptr", DllStructGetPtr($hAddr), "int", DllStructGetSize($hAddr)) Return $iRet[0] EndFunc Func _WinsockConnect($hSocket, $IP, $Port) $hAddr = _SocketAddr($IP, $Port) $iRet = DllCall($hWs2_32, "int", "connect", "uint", $hSocket, "ptr", DllStructGetPtr($hAddr), "int", DllStructGetSize($hAddr)) EndFunc Func _WinsockSend($hSocket, $data) $hBuf = DllStructCreate("byte[" & BinaryLen($data) & "]") DllStructSetData($hBuf, 1, $data) $iRet = DllCall($hWs2_32, "int", "send", "uint", $hSocket, "ptr", DllStructGetPtr($hBuf), "int", DllStructGetSize($hBuf), "int", 0) EndFunc Func _SocketAddr($IP, $Port, $Address_Family = 2) $stAddress = DllStructCreate("short; ushort; uint; char[8]") DllStructSetData($stAddress, 1, $Address_Family) $iRet = DllCall($hWs2_32, "ushort", "htons", "ushort", $Port) DllStructSetData($stAddress, 2, $iRet[0]) $iRet = DllCall($hWs2_32, "uint", "inet_addr", "str", $IP) DllStructSetData($stAddress, 3, $iRet[0]) Return $stAddress EndFunc ;==>_SocketAddr Func _WSAGetLastError() $iRet = DllCall($hWs2_32, "int", "WSAGetLastError") Return $iRet[0] EndFunc ;==>_WSAGetLastError On the other computer, there was an AutoIt UDP listener running. It said the source port of the packet received is indeed 53. There is PLENTY of room to expand this and make it into an excellent UDF. I only implemented the functions I need for now, but you probably see where to expand this. Here's the list of functions that could potentially be adapted in the UDF: http://msdn.microsoft.com/en-us/library/windows/desktop/ms741394(v=vs.85).aspx
    1 point
  5. @timmy2: you can do it e.g. this way: #include <WindowsConstants.au3> #include <GUIConstantsEx.au3> #include "_GDIPlus_StripProgressbar.au3" _GDIPlus_Startup() Global Const $STM_SETIMAGE = 0x0172, $IMAGE_BITMAP = 0 Global $iW = 400, $iH = 25, $iBGColor = 0xFFFFFF Global Const $hGUI = GUICreate("Strip Progressbar", $iW, $iH, -1, -1, $WS_POPUPWINDOW, $WS_EX_TOPMOST) GUISetBkColor($iBGColor) Global Const $iPic = GUICtrlCreatePic("", 0, 0, $iW, $iH) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState() Global $hHBmp_BG, $hB, $iSleep = 20, $hTooltip Global $fPerc = 0, $aPos, $iPosX, $iPosY $aPos = WinGetPos($hGUI) $iPosX = $aPos[0] $iPosY = $aPos[1] + $aPos[3] Global $iTimer = TimerInit(), $iSeconds = 10, $iMSeconds = $iSeconds * 1000 GUIRegisterMsg($WM_TIMER, "PlayAnim") DllCall("user32.dll", "int", "SetTimer", "hwnd", $hGUI, "int", 0, "int", $iSleep, "int", 0) Do Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _Exit() EndSwitch Until False Func PlayAnim() $hHBmp_BG = _GDIPlus_StripProgressbar($fPerc, $iW, $iH, 0xFF000000 + $iBGColor, 0xFFEE5F5B, 0xFFF07673, "IP Release/Renew") $hB = GUICtrlSendMsg($iPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBmp_BG) If $hB Then _WinAPI_DeleteObject($hB) _WinAPI_DeleteObject($hHBmp_BG) $fPerc = TimerDiff($iTimer) / $iMSeconds * 100 If $fPerc >= 100 Then _Exit() EndIf ToolTip(StringFormat("%.2f seconds", TimerDiff($iTimer) / 1000), $iPosX + $fPerc / 100 * $iW - 1, $iPosY, "", "", 3) $hTooltip = WinGetHandle(StringFormat("%02d %", $fPerc)) EndFunc ;==>PlayAnim Func _Exit() ToolTip("") GUIRegisterMsg($WM_TIMER, "") _WinAPI_DeleteObject($hHBmp_BG) _GDIPlus_Shutdown() GUIDelete() Exit EndFunc Btw, I reuploaded the archive from post#1 because _GDIPlus_StripProgressbar Example3.au3 was broken (sorry). Br, UEZ
    1 point
  6. smashly

    Update Progress Bar

    You could try and do a recursive filelist to array then step through the file copy setting the progress along the way. Here's a long winded example. $Source = @HomeDrive & "\AutoIt Stuff\#AutoIt Projects Misc\" ; directory to copy (2.7GB) $Destination = @HomeDrive & "\Copy Test\" ; copied to here $FLTAR = _FileListToArrayR($Source, "", 0, 1) ProgressOn("Copying...", "Copy Progress") For $i = 1 To $FLTAR[0] If StringInStr(FileGetAttrib($FLTAR[$i]), "D") Then DirCreate($Destination & StringReplace($FLTAR[$i], $Source, "")) Else FileCopy($FLTAR[$i], $Destination & StringReplace($FLTAR[$i], $Source, ""), 9) EndIf ProgressSet((100/$FLTAR[0]) * $i, "Copied: " & StringMid($FLTAR[$i], StringInStr($FLTAR[$i], "\", 0, -1) + 1) & _ @CRLF & "Completed: " & Round((100/$FLTAR[0]) * $i) & "%") Next Func _FileListToArrayR($sPath, $sExFilter = "", $iFlag = 0, $iRecurse = 0, $iDepth = 0) Local $hSearch, $sFile, $sRxpFilter, $asFileList If Not $iDepth Then Global $sHoldFiles = '' If Not FileExists($sPath) Then Return SetError(1, 1, "") If StringRegExp($sExFilter, "[\\/<>:*?]", 0) Then Return SetError(2, 2, "") If Not ($iFlag = 0 Or $iFlag = 1 Or $iFlag = 2) Then Return SetError(3, 3, "") If Not ($iRecurse = 0 Or $iRecurse = 1) Then Return SetError(4, 4, "") EndIf If StringRight($sPath, 1) <> "\" Then $sPath &= "\" If $sExFilter = "" Then $sRxpFilter = "." Else $sRxpFilter = "(?i)\.(" & $sExFilter & ")" EndIf $hSearch = FileFindFirstFile($sPath & "*") If $hSearch = -1 Then Return SetError(5, 5, "") While 1 $sFile = FileFindNextFile($hSearch) If @error Then ExitLoop If StringInStr(FileGetAttrib($sPath & $sFile), "D") Then If Not $iRecurse And $iFlag = 1 Then ContinueLoop If $iRecurse Then _FileListToArrayR($sPath & $sFile, $sExFilter, $iFlag, $iRecurse, $iDepth + 1) If $iFlag <> 1 Then $sHoldFiles &= $sPath & $sFile & "|" Else $sHoldFiles &= $sPath & $sFile & "|" EndIf ElseIf StringRegExp($sFile, $sRxpFilter, 0) And $iFlag <> 2 Then $sHoldFiles &= $sPath & $sFile & "|" EndIf WEnd FileClose($hSearch) If Not $iDepth Then $asFileList = StringSplit(StringTrimRight($sHoldFiles, 1), "|") $sHoldFiles = "" Return $asFileList EndIf EndFunc ;==>_FileListToArrayRThere's quite a few good recursive filelist to array functions floating around the forums. Cheers
    1 point
×
×
  • Create New...