Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/05/2016 in all areas

  1. Try something like this here: #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GDIPlus.au3> _GDIPlus_Startup() Global $bg1 = @ScriptDir&"\1.jpg", $bg2 = @ScriptDir&"\2.jpg" Global $guiw = 800, $guih = 600 $Form1 = GUICreate("Form1", $guiw, $guih, -1, -1,$WS_POPUP) $Button1 = GUICtrlCreateButton("Button1", 332, 328,100, 20) GUISetState(@SW_SHOW, $Form1) #EndRegion ### END Koda GUI section ### Global $hGfx = _GDIPlus_GraphicsCreateFromHWND($Form1) ;clip control elements Global $hRegion = _GDIPlus_RegionCreateFromRect(0, 0, $guiw, $guih) Global $hChild = _WinAPI_GetWindow($Form1, $GW_CHILD) Global $aRect Do $aRect = ControlGetPos($hChild, "", 0) _GDIPlus_RegionCombineRect($hRegion, $aRect[0], $aRect[1], $aRect[2], $aRect[3], 3) $hChild = _WinAPI_GetWindow($hChild, $GW_HWNDNEXT) Until Not $hChild _GDIPlus_GraphicsSetClipRegion($hGfx, $hRegion) _GDIPlus_RegionDispose($hRegion) Global $hBmp1 = _GDIPlus_ImageLoadFromFile($bg1), $hBmp2 = _GDIPlus_ImageLoadFromFile($bg2) _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp1, 0, 0, $guiw, $guih) $n = 1 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE _GDIPlus_ImageDispose($hBmp1) _GDIPlus_ImageDispose($hBmp2) _GDIPlus_GraphicsDispose($hGfx) _GDIPlus_Shutdown() GUIDelete() Exit Case $Button1 For $x = -$guiw To 0 Step 2 Switch Mod($n, 2) Case 0 _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp1, $x, 0, $guiw, $guih) Case Else _GDIPlus_GraphicsDrawImageRect($hGfx, $hBmp2, $x, 0, $guiw, $guih) EndSwitch Next $n += 1 EndSwitch WEnd
    3 points
  2. j0kky

    STUN UDF

    Hi guysssss, have you ever heard of STUN?! No? When you are under a NAT and you try to connect to an online server, you make the request using an internal port and your local IP. But when your request arrives to the router, it uses its own port list and it enstablishes the connection to the final server using a different port (which has a different port number, but it is associated to your internal port) and the public (external) IP. So, the server responds to your request using the couple external IP\port assigned by the router. Well, STUN is a protocol that permits you to know your external IP but, more interesting, your external port associated to your internal port. But, which is the point? Client/Server connections don't require to know these informations, but what about P2P connection? STUN UDF is the second step (the first was my winsock UDF, which is used in this script) to UDP Hole Punching technique: Here you are the function: ; #FUNCTION# ======================================================================================================================== ; Name...........: _STUN ; Description ...: Makes a STUN request and processes the response ; Syntax.........: _STUN($iLocalPort, $iStunServer = "", $iStunPort = "") ; Parameters ....: $iLocalPort - The local port to be tested ; |1 : 65535 ; $iStunServer - name of the STUN server [Default = ""] ; $iStunPort - STUN server port, used only if $iStunServer <> "" ; |1 : 65535 - [Default = 3478] ; Return values .: On success it returns an array: ; |[0] - The external IP address ; |[1] - The external port ; On failure it returns -1 and sets @error to non zero: ; |-1 - internal error ; |-2 - missing DLL (Ws2_32.dll) ; |-3 - Unable to connect to internet ; |-4 - $iLocalPort is not a valid port ; |-5 - can't bind to $iLocalPort, try a different port ; |-6 - problem with servers ; Remarks .......: This function is used by a client to know which external port/IP correspond to the indicated internal port. ; By default it is used a STUN server list composed by: ; stun.l.google.com:19302, stun1.l.google.com:19302, stun.ekiga.net:3478, stun.ideasip.com:3478, stun.schlund.de:3478 ; If $iStunServer is indicated, the first element of the list is replaced by $iStunServer:$iStunPort ; Author ........: j0kky ; Modified ......: 1.0.0 ; Links .........: STUN RFC 5389: https://tools.ietf.org/html/rfc5389 ; ==================================================================================================================================== #include "winsock.au3" Func _STUN($iLocalPort, $iStunServer = "", $iStunPort = "") $iLocalPort = Int($iLocalPort) If ($iLocalPort < 1) Or ($iLocalPort > 65535) Then Return SetError(-4, 0, -1) $iExtended = 0 If $iStunServer = Default Then $iStunServer = "" $iStunServer = String($iStunServer) If $iStunServer Then $iStunServer = StringRegExpReplace($iStunServer, "^http.?://", "") If StringRight($iStunServer, 1) = "/" Then $iStunServer = StringTrimRight($iStunServer, 1) If Not StringRegExp($iStunServer, ".+\..{2,}") Then $iStunServer = "" ; invalid parameter $iExtended = -1 EndIf EndIf $hWs2 = DllOpen("Ws2_32.dll") If @error Then Return SetError(-2, $iExtended, -1) $tHeader = DllStructCreate("ushort MessageType; ushort MessageLenght; ulong MagicCookie; byte TransactionID[12]") $aRet = DllCall($hWs2, "ushort", "htons", "ushort", 0x0001) If @error Then DllClose($hWs2) Return SetError(-1, $iExtended, -1) Else DllStructSetData($tHeader, "MessageType", $aRet[0]) ;MessageType EndIf DllStructSetData($tHeader, "MessageLenght", 0x0000) ;MessageLenght $aRet = DllCall($hWs2, "ulong", "htonl", "ulong", 0x2112A442) If @error Then DllClose($hWs2) Return SetError(-1, $iExtended, -1) Else DllStructSetData($tHeader, "MagicCookie", $aRet[0]) ;MagicCookie EndIf For $i = 1 To 12 DllStructSetData($tHeader, "TransactionID", Random(0x00, 0xff, 1), $i) ;TransactionID Next _UDPStartup() If @error Then DllClose($hWs2) Return SetError(-1, $iExtended, -1) EndIf $sLocalIP = _GetIPs() If @error Then _UDPShutdown() DllClose($hWs2) Return SetError(-3, $iExtended, -1) EndIf $sLocalIP = $sLocalIP[0] If $iStunServer Then $sFirstServer = $iStunServer If $iStunPort Then $nFirstPort = $iStunPort Else $nFirstPort = 3478 EndIf Else $sFirstServer = "stun.l.google.com" $nFirstPort = 19302 EndIf Local $aStunServer[5][2] = [[$sFirstServer, $nFirstPort], ["stun1.l.google.com", 19302], ["stun.ekiga.net", 3478], ["stun.ideasip.com", 3478], ["stun.schlund.de", 3478]] $nBindSocket = _UDPBind($sLocalIP, $iLocalPort) If @error Then Return SetError(-5, $iExtended, -1) For $j = 0 To 4 $iError = 0 $sServerName = $aStunServer[$j][0] $sServerIP = _TCPNameToIP($sServerName) If @error Then $iError = -6 If Not $iError Then ;RFC indicates that $nRcMaxValue should be equal to 7 and $nRm should be equal to 16, ;but, following those rules, if the server doesn't respond quickly, the script is blocked for more than 1 minute $tByteHeader = DllStructCreate("byte[" & DllStructGetSize($tHeader) & "]", DllStructGetPtr($tHeader)) Local $nRTO = 500, $hTime = TimerInit(), $nRTOTotal = 0, $nRc = 0, $nRcMaxValue = 2, $aRecv = "", $nRm = 2 Do If ($nRc < $nRcMaxValue) And (TimerDiff($hTime) >= $nRTOTotal) Then _UDPSendTo($sServerIP, $aStunServer[$j][1], DllStructGetData($tByteHeader, 1), $nBindSocket) If @error Then $iError = -1 $nRTOTotal += $nRTO * (2 ^ $nRc) $nRc += 1 If $nRc = $nRcMaxValue Then $hTime = TimerInit() EndIf $aRecv = _UDPRecvFrom($nBindSocket, 2048, 1) If @error Then $iError = -1 Sleep(100) Until ($aRecv <> -1) Or (($nRc = $nRcMaxValue) And (TimerDiff($hTime) >= $nRTO * $nRm)) If Not IsArray($aRecv) Then $iError = -1 EndIf If Not $iError Then $dResponse = $aRecv[0] $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", BinaryMid($dResponse, 3, 2)) ;MessageLenght If @error Then $iError = -1 Else $nMessageLenght = $aRet[0] EndIf If Not ($nMessageLenght > 0) Then $iError = -6 EndIf If Not $iError Then $dResponse = BinaryMid($dResponse, 1, $nMessageLenght + 20) ;message lenght plus header size $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", BinaryMid($dResponse, 1, 2)) ;MessageType If @error Then $iError = -1 Else $nMessageType = $aRet[0] If Not (($nMessageType = 0x0101) Or ($nMessageType = 0x0111)) Then $iError = -6 EndIf EndIf If Not $iError Then $nByteNumber = 1 If $nMessageType = 0x0101 Then ;Binding success response Do $iError = 0 $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", BinaryMid($dResponse, 20 + $nByteNumber, 2)) ;Attribute Type If @error Then $iError = -1 Else $nAttributeType = $aRet[0] EndIf If Not $iError And (($nAttributeType = 0x0001) Or ($nAttributeType = 0x0020)) Then ;MAPPED-ADDRESS or XOR-MAPPED-ADDRESS $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", BinaryMid($dResponse, 24 + $nByteNumber, 2)) ;Family If @error Then $iError = -1 Else $nFamily = $aRet[0] EndIf EndIf If Not $iError Then Local $aResult[2] If $nAttributeType = 0x0020 Then ;XOR-MAPPED-ADDRESS $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", BinaryMid($dResponse, 26 + $nByteNumber, 2)) ;Port If @error Then $iError = -1 Else $aResult[1] = BitXOR($aRet[0], 0x2112) ;Xored with the most significant 16 bit of Magic Cookie EndIf If Not $iError Then If $nFamily = 0x0001 Then ;IPv4 $dNBOIP = BinaryMid($dResponse, 28 + $nByteNumber, 4) $dNBOCookie = Binary("0x" & Hex(0x2112A442)) $tNBOXoredIP = DllStructCreate("byte[4]") For $i = 1 To 4 DllStructSetData($tNBOXoredIP, 1, BitXOR(BinaryMid($dNBOIP, $i, 1), BinaryMid($dNBOCookie, $i, 1)), $i) Next $aRet = DllCall($hWs2, "ptr", "inet_ntoa", "ulong", Int(DllStructGetData($tNBOXoredIP, 1))) If @error Then $iError = -1 ElseIf $aRet[0] = Null Then $iError = -6 Else $aResult[0] = DllStructGetData(DllStructCreate("char[15]", $aRet[0]), 1) ;IP address xored with Magic Cookie EndIf Else ;IPv6 $dNBOIP = BinaryMid($dResponse, 28 + $nByteNumber, 16) $dNBOConcatenation = BinaryMid($dResponse, 5, 16) $tNBOXoredIP = DllStructCreate("byte[16]") For $i = 1 To 16 DllStructSetData($tNBOXoredIP, 1, BitXOR(BinaryMid($dNBOIP, $i, 1), BinaryMid($dNBOConcatenation, $i, 1)), $i) Next $tIP = DllStructCreate("char[46]") $aRet = DllCall($hWs2, "ptr", "inet_ntop", _ "int", 23, "ptr", DllStructGetPtr($tNBOXoredIP), "ptr", DllStructGetPtr($tIP), "ULONG_PTR", DllStructGetSize($tIP)) If @error Then $iError = -1 ElseIf $aRet[0] = Null Then $iError = -6 Else $aResult[0] = DllStructGetData($tIP, 1) ;IP address EndIf EndIf EndIf ExitLoop 2 ElseIf $nAttributeType = 0x0001 Then ;MAPPED-ADDRESS $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", BinaryMid($dResponse, 26 + $nByteNumber, 2)) ;Port If @error Then $iError = -1 Else $aResult[1] = $aRet[0] EndIf If Not $iError Then If $nFamily = 0x0001 Then ;IPv4 $aRet = DllCall($hWs2, "ptr", "inet_ntoa", "ulong", BinaryMid($dResponse, 28 + $nByteNumber, 4)) If @error Then $iError = -1 ElseIf $aRet[0] = Null Then $iError = -6 Else $aResult[0] = DllStructGetData(DllStructCreate("char[15]", $aRet[0]), 1) ;IP address EndIf Else ;IPv6 $tNBOIP = DllStructCreate("byte[16]") DllStructSetData($tNBOIP, 1, BinaryMid($dResponse, 28 + $nByteNumber, 16)) $tIP = DllStructCreate("char[46]") $aRet = DllCall($hWs2, "ptr", "inet_ntop", _ "int", 23, "ptr", DllStructGetPtr($tNBOIP), "ptr", DllStructGetPtr($tIP), "ULONG_PTR", DllStructGetSize($tIP)) If @error Then $iError = -1 ElseIf $aRet[0] = Null Then $iError = -6 Else $aResult[0] = DllStructGetData($tIP, 1) ;IP address EndIf EndIf EndIf ExitLoop 2 Else $aRet = DllCall($hWs2, "ushort", "ntohs", "ushort", BinaryMid($dResponse, 22 + $nByteNumber, 2)) ;Attribute Lenght If @error Then $iError = -1 Else $nAttributeLenght = $aRet[0] If Not (Mod($nAttributeLenght, 4) = 0) Then $nAttributeLenght += 4 - Mod($nAttributeLenght, 4) ;padding $nByteNumber += 4 + $nAttributeLenght ;TLV EndIf EndIf EndIf Until $nByteNumber > $nMessageLenght Else ;0x0111 = Binding error response $iError = -6 EndIf EndIf Next _UDPCloseSocket($nBindSocket) _UDPShutdown() DllClose($hWs2) If $iError Then $aResult = -1 If $iStunServer And ($iStunServer <> $sServerName) Then $iExtended = -2 Return SetError($iError, $iExtended, $aResult) EndFunc ;==>_STUN Please test it (especially if you have an IPv6 interface) and report every bug you can try STUN.zip
    1 point
  3. Jos

    New Window | Browser

    seriously ... just learning? Not convinced ... and better not try this again. Maybe they have better support, but seems your are burning credit there as well. *click* Jos
    1 point
  4. water

    Excel activatesheet problem

    Global $xlCalculationAutomatic = -4105 ; Excel controls recalculation Global $xlCalculationManual = -4135 ; Calculation is done when the user requests it Global $xlCalculationSemiautomatic = 2 ; Excel controls recalculation but ignores changes in tables $g_oExcel.Calculation = $xlCalculateManual The calculation enumeration can be found here: https://msdn.microsoft.com/en-us/library/bb240978(v=office.12).aspx
    1 point
  5. AB, This will detect a single click on a listview item... #include <GUIConstantsEx.au3> #include <GuiListBox.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> Local $hGui = GUICreate("Example") $ListviewBannerDate = GUICtrlCreateListView("My Banner Dates", 200, 150, 160, 150, -1) ; dummy control actioned by notify routine when user clicks on control $dummy_lv = GUICtrlCreateDummy() GUISetState(@SW_SHOW) ; routine to recieve notification messages from listview GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") Local $sFilePath = @ScriptDir & "\test.txt" ; Read the current script file into an array using the filepath. Local $aDate = FileReadToArray($sFilePath) If @error Then MsgBox(0, "", "There was an error reading the file. @error: " & @error) ; An error occurred reading the current script file. Else For $i = 0 To UBound($aDate) - 1 ; Loop through the array. $iString = StringInStr($aDate[$i], "OPTION VALUE") $sMyString = StringMid($aDate[$i], 16, 9) If $iString > 1 Then GUICtrlCreateListViewItem($sMyString, $ListviewBannerDate) Else ContinueLoop EndIf Next EndIf Local $msg While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE Exit Case $dummy_lv ; ; this is where you would do your search and replace routine ; ConsoleWrite(_GUICtrlListView_GetItemTextString($ListviewBannerDate, -1) & @LF) EndSwitch WEnd Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) Local $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) Switch $tNMHDR.IDFrom Case $ListviewBannerDate Switch $tNMHDR.Code Case $nm_click GUICtrlSendToDummy($dummy_lv) ; action dummy control in the message loop EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY kylomas
    1 point
  6. thx this works like a charm $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ; Initialize a COM error handler $URL="http://localhost:17556/" $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") ;~ GET /status HTTP/1.1 ;~ Host: localhost:17556 ;~ Cache-Control: no-cache $restCMD="/status" $oHTTP.Open("GET", $URL & $restCMD, true) ;~ $oHTTP.setRequestHeader ("Cache-Control:","no-cache") ;~ $oHTTP.SetRequestHeader("Content-Type", "xml") $oHTTP.Send("") sleep(2000) ;~just wait a little $oReceived = $oHTTP.ResponseText $oStatusCode = $oHTTP.Status ;~ $objHTTP.open ("POST", "url", False) ;~ $objHTTP.setRequestHeader ("Content-Type", "text/xml;charset=UTF-8") ;~ $objHTTP.setRequestHeader("Content-Length",StringLen($YourXMLText)) ;~ $objHTTP.setRequestHeader("Connection","If is needed") ;~ $objHTTP.setRequestHeader("User-Agent","If is needed") ;~ $objHTTP.send ($YourXMLText) ConsoleWrite($oStatusCode & @CRLF) ConsoleWrite($oReceived & @CRLF) If $oStatusCode = 200 Then ;Process the response $oReceived ;ConsoleWrite(@CRLF & "Response" & @CRLF & $oReceived & @CRLF) Else MsgBox(16, "Error " & $oStatusCode, $oReceived, 7) EndIf ; This is my custom defined error handler Func MyErrFunc() Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc
    1 point
  7. Mbee, It does look very much as if the seangriffin UDF does not want to play nicely with your 64-bit system, but as I do not have access to such a beast I cannot investigate further. The Yasheid UDF works very nicely using the 32-bit DLL - which given his talent is hardly surprising. This is a sample output I get: 1 - M:\Program\Au3 Scripts\~TEST1~\fred1.au3 3 - M:\Program\Au3 Scripts\~TEST1~\fred1.au3 1 - M:\Program\Au3 Scripts\~TEST3~\fred1.au3.2.bak 3 - M:\Program\Au3 Scripts\~TEST3~\fred1.au3.2.bak 2 - M:\Program\Au3 Scripts\~TEST1~\fred1.au3 The codes seem to be the same as used in the seangriffin UDF - 1 = added, 2 = deleted, 3 = modified. So I would suggest trying to use Yashied's UDF and see how it works for you on x64. You will need to download the zip and place RDC.au3 and the RDC_x64.dll files in the script folder. M23
    1 point
  8. I have found an easy way to do things like run a program that deletes every index.dat file on the Windows system partition, using the RunOnce registry key. I wrote a small freeware to set it conveniently called RunItOnce. The program it runs will run before login. So it should not be interactive at all. You may download RunItOnce from my page It just so happens the utility is written in AutoIt3. Edit: The beauty of using the RunOnce key in the Registry is the system gets the info, then removes it from the Registry for you. You don't have to worry about cleaning up after yourself. RunItOnce will set the RunOnce key of the user whose account is active when RunItOnce is run. IOW, it uses the Users RunOnce Registry key, not Administrator. But it should work fine for deleting system files since they are not considered to be "in use by the system" prior to login. At least it had no problem running a program that deleted every index.dat file on C: for me. Try it and see. But I would definitely make an image backup first!!
    1 point
×
×
  • Create New...