Leaderboard
Popular Content
Showing content with the highest reputation on 05/21/2020 in all areas
-
Unblocker Script
Exit and one other reacted to seadoggie01 for a topic
Recently I stumbled across this again and got frustrated, so I wrote a script to fix it (because that's what heroes do?). Every time I download a file from the internet or my email, the file gets marked as being from the internet. When I open the properties, there's a fancy checkbox to "Unblock" the file. I've experienced issues with this, especially when trying to download a Visual Studio project and import it for school. I learned a ton about FileStreams because I dove into PowerShell's UnblockFile source code. I'm still not very clear on what or why FileStreams, but I did manage to find out that unblocking a file is as simple as making a WinAPI FileDelete call with ":Zone.Information" appended to the file path. Func _File_Unblock($sFilePath) Local $hFile = FileOpen($sFilePath & ":Zone.Identifier", 2) If $hFile = -1 Then Return SetError(1, 0, False) FileWrite($hFile, "") FileClose($hFile) Return True EndFunc I think the script is pretty self-explanatory, but I thought I'd share in case anyone else runs into this issue Edit: So I found a bit more about this, mostly because a comment somewhere mentioned that this Zone.Identifier was actually an Ini file. This website showed how to open and edit the file, so I found that the format of the IniFile is something like this: (I used a copy of my UDF that I downloaded) [ZoneTransfer] ZoneId=3 ReferrerUrl=https://www.autoitscript.com/forum/topic/202026-acroau3-udf/ HostUrl=https://www.autoitscript.com/forum/applications/core/interface/file/attachment.php?id=63984 It appears that File Explorer deletes the entire stream when you click "Unblock". Setting the ZoneId to 0, 1, or 2 doesn't appear to make any changes and "Unblock" is still visible. I also found FileOpen allows Reading/Writing to FileStreams, so _WinAPI_FileDelete isn't needed.2 points -
WebDriver UDF - Help & Support (II)
boomingranny and one other reacted to JLogan3o13 for a topic
So are you the security admin for your organization? Just curious as it seems not a best practice way to go about things.2 points -
Is there a non-brute force way to separate files on clipboard?
FrancescoDiMuro reacted to mikell for a topic
The very first time I provide help so easily. Glad I could do so !1 point -
Could you provide an example of such a list ?1 point
-
WebDriver UDF - Help & Support (II)
nooneclose reacted to Danp2 for a topic
@nooneclose Pretty sure that it is a "virtual" mouse pointer that is moved. You will need to find a way to programmatically trigger the menu. Another option to try would be to retrieve the href of the link and then use _WD_ExecuteScript to execute the javascript code.1 point -
Because browser handles other stuff while loading the page, using InetRead you load raw page data. This is how we can get titles in this case: #Include <Array.au3> #Include <INET.au3> $sSource = _INetGetSource('http://www.google.com/search?q=autoit') $aTitles = StringRegExp($sSource, '<a href="/url\?q=.+?><div class=".*?"><span dir=".*?">(.*?)</span>', 3) _ArrayDisplay($aTitles)1 point
-
Works fine: #include <IE.au3> #include <Array.au3> Local $oIE = _IECreate("https://www.google.com/search?q=autoit") Local $oItems = _IETagNameGetCollection($oIE, "h3") Local $aTitle_Table[3] Local $iUbound = UBound($aTitle_Table) Local $iCount = 0 For $oItem In $oItems If StringLeft($oItem.ClassName, 2) <> 'LC' Then ContinueLoop EndIf $aTitle_Table[$iCount] = $oItem.InnerText $iCount += 1 If $iCount >= $iUbound Then ExitLoop EndIf Next _IEQuit($oIE) _ArrayDisplay($aTitle_Table)1 point
-
https://www.autoitscript.com/autoit3/docs/libfunctions/_IETagNameGetCollection.htm if you saw the help file's example for the _IETagNameGetCollection function, then you must have seen that they used $oIE as the first parameter. Being new to AutoIt, why did you choose to use some none existent object instead of trying to follow the example? In your _IETagNameGetCollection function, change $findH3 to $oIE (like the help file's example) and see if that works.1 point
-
Extract text from HTML
Nina reacted to FrancescoDiMuro for a topic
@Nina Always check for errors in your code, and you were missing a round parenthesis in INetGetSource() function, and the three dots in the function were definitely not helping the research. The code below shows how to see if there are errors returned by the functions you are using; by the way, the string <h3> is not in the HTML source code, so it will always returns error 1: #include <Inet.au3> #include <String.au3> Global $strHTLM = _INetGetSource('http://www.google.com/search?q=autoit') If @error Then ConsoleWrite("_INetGetSource ERR: " & @error & @CRLF) Exit Else ConsoleWrite($strHTLM & @CRLF) $strHTLM = _StringBetween($strHTLM, '<h3>', '</h3>') If @error Then ConsoleWrite("_StringBetween ERR: " & @error & @CRLF) Else MsgBox(0, "", $strHTLM[0]) EndIf EndIf1 point -
Extract text from HTML
FrancescoDiMuro reacted to Jos for a topic
First of all I like to state it is somewhat impolite to crosspost questions (posting them multiple times). As to your question: 1: The posted line has an error in the syntax so will not run: $html = _StringBetween(_INetGetSource('http://www.google.com/search?q=autoit', '<h3 ….>', '</h3>') ; --- should be $html = _StringBetween(_INetGetSource('http://www.google.com/search?q=autoit'), '<h3 ….>', '</h3>') MsgBox(0, "title", $html[0]) 2: When you run this code it tells you what is wrong with the _StringBetween(): #Include <String.au3> #Include <INET.au3> $html = _StringBetween(_INetGetSource('http://www.google.com/search?q=autoit'), '<h3 ….>', '</h3>') ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') >Error code: ' & @error & @CRLF) ;### Debug Console As that returns "Error code: 1" and the helpfile tell you that in that case: "@error: 1 - No strings found. " So what exactly were you expecting this start parameter to find: '<h3 ….>' ? Jos1 point -
Oh yes, that is because two groups are used, was my first thought, but this behavior can not be prevented. Now I'm a little disappointed by regex101.com ... because everything looked perfect there. Well, because of this problem and your good explanation, especially thanks to your great table, I am now a big step ahead. Big thanks!1 point
-
I know why but I'm not sure I can explain it in a way that others can understand. You had 2 capture groups, let's call them G1 & G2. In general, when the regex engine finds a match, it will stop processing the rest of that match. So when it found a "lat" it put that value in the array and stopped processing. When it was on a "lon" line, It looked for G1 but didn't find it, so it put a blank in the array and then it went on to look for that alternate match ("lon") on that line and put it in the array. So as you can see below, every "lon" line had an empty G1 entry. I hope I was able to explain it in a way that was understandable. Regex: <lat>(.+)<\/lat>|<lon>(.+)<\/lon> G1 G2 <lat>10.0</lat> 10.0 stopped <lon>1.10</lon> blank 1.10 <lat>20.0</lat> 20.0 stopped <lon>2.20</lon> blank 2.20 <lat>40.0</lat> 40.0 stopped <lon>4.40</lon> blank 4.401 point
-
Code running slow after FileOpenDialog
boomingranny reacted to argumentum for a topic
ConsoleWrite ("- " & @OSVersion& ' ( FileGetVersion("WinVer.exe") = ' & FileGetVersion("WinVer.exe") & " )"& @CRLF) ConsoleWrite("- @AutoItVersion = " & @AutoItVersion & @CRLF) CodeSpeedTest() FileOpenDialog("Select file",Default,"All files (*.*)") CodeSpeedTest() Func CodeSpeedTest() $timer = TimerInit() for $i = 1 to 1000000 Next ConsoleWrite("- TimeMS: " &TimerDiff($timer)&@CRLF) EndFunc ;~ - WIN_10 ( FileGetVersion("WinVer.exe") = 10.0.18362.1 ) ;~ - @AutoItVersion = 3.3.14.5 ;~ - TimeMS: 32.9974 ;~ - TimeMS: 676.0522 ;~ - WIN_10 ( FileGetVersion("WinVer.exe") = 10.0.18362.1 ) ;~ - @AutoItVersion = 3.3.15.3 ;~ - TimeMS: 18.4056 ;~ - TimeMS: 18.9169 ..yes v. 3.3.15.3 works fine1 point -
Code running slow after FileOpenDialog
boomingranny reacted to argumentum for a topic
..try the new and improved beta. It fixes this problem. - WIN_10 ( FileGetVersion("WinVer.exe") = 10.0.14393.0 ) - @AutoItVersion = 3.3.14.5 - TimeMS: 26.9179417943872 - TimeMS: 23.5783072812843 - WIN_10 ( FileGetVersion("WinVer.exe") = 10.0.14393.0 ) - @AutoItVersion = 3.3.15.3 - TimeMS: 15.2403032434683 - TimeMS: 15.0289094212104 Edit: ...sorry, I was in the wrong PC to test that, BRB1 point -
Attachment name in e-mail
Skysnake reacted to albertmaathuis for a topic
Feel very stupid.😕 Downloaded today the new UDF before programming and put it in the "include" map. But I had it open also to see how the syntax should be. So it didn't overwrite the old file!!!! Thanks for the tip; now it works as it should!1 point -
Custom Registry Functions UDF
Mbee reacted to argumentum for a topic
nothing. 2 years and nothing. can you believe that !. But I am of my word. If a "test.au3" pops up, I'll recreate the setup I offered two years ago, and sure as heck I'll get it done, or help me god, I'll short circuit the internet. If don't stand for something, you don't stand for anything. And I am not that type of person/coder/MamaCalledMeFool/GoodLuckJustifyingMyExistence !1 point -
TextReplace (En+Ru) TextReplace - v1.1.3, 700 kb (exe+sources+lng) screenshot 1 (Show in detail, Linux) screenshot 1 (Show in detail RTF) screenshot 2 (Search) screenshot 3 (Setting) screenshot 4 (Scenario) screenshot 5 (Multiline)1 point
-
Converter - Dec - Hex - Bin For all of those who need to convert Dec - Hex - Bin and visa versa. #include <Color.au3> #include <GUIConstantsEX.au3> #include <String.au3> Global Const $HX_REF="0123456789ABCDEF" Global Const $color1 = 0x99A8AC Global Const $color2 = 0xFFFFFF $Gui = GUICreate("Converter @ Dec - Bin - Hex"& _StringRepeat(" ",125) & " by ptrex" , 833, 247, 161, 166) GUISetIcon (@windowsdir & "system32Calc.exe",-1,$Gui) $Size = WinGetClientSize($Gui) $radio1 = GUICtrlCreateRadio ("Dec", 100, 10, 60, 20) GUICtrlSetBkColor(-1,0xA1AFB2) $radio2 = GUICtrlCreateRadio ("Hex", 160, 10, 60, 20) GUICtrlSetBkColor(-1,0xA1AFB2) $radio3 = GUICtrlCreateRadio ("Bin", 220, 10, 60, 20) GUICtrlSetBkColor(-1,0xA1AFB2) ;GUICtrlSetState ($radio1, $GUI_CHECKED) $label = GUICtrlCreateLabel("Input", 10, 15, 50, 15) GUICtrlSetBkColor(-1,0xA1AFB2) $labelout = GUICtrlCreateLabel("Result", 10, 45, 50, 15) GUICtrlSetBkColor(-1,0xAEBABD) $Input1 = GUICtrlCreateInput("", 100, 40, 650, 21) $Label1 = GUICtrlCreateLabel("Hexadecimal", 10, 80, 70, 15) GUICtrlSetBkColor(-1,0xBAC4C7) $Label1out = GUICtrlCreateLabel("0", 100, 80, 600, 15) GUICtrlSetBkColor(-1,0xBAC4C7) $Label2 = GUICtrlCreateLabel("Binary", 10, 115, 50, 15) GUICtrlSetBkColor(-1,0xCBD3D5) $Label2out = GUICtrlCreateLabel("0", 100, 115, 600, 15) GUICtrlSetBkColor(-1,0xCBD3D5) _GUICtrlCreateGradient($color1, $color2, 0, 0, $size[0]*1.5, $size[1]) GUISetState(@SW_SHOW) While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $radio1 And BitAND(GUICtrlRead($radio1), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($Label1out,_DecimalToHex(int(StringStripWS(GUICtrlRead($Input1,1),8)))) GUICtrlSetData($Label1,"Hexadecimal") GUICtrlSetData($Label2out,_DecToBinary(StringStripWS(GUICtrlRead($Input1,1),8))) GUICtrlSetData($Label2,"Binary") ;ConsoleWrite("_DecimalToHex " & _DecimalToHex(Int(GUICtrlRead($Input1,1))) & @LF) ;ConsoleWrite("_DecToBinary " & _DecToBinary(GUICtrlRead($Input1,1)) & @CRLF) Case $msg = $radio2 And BitAND(GUICtrlRead($radio2), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($Label1out,_HexToDecimal(StringStripWS(GUICtrlRead($Input1,1),8))) GUICtrlSetData($Label1,"Decimal") GUICtrlSetData($Label2out,_HexToBinaryString(StringStripWS(GUICtrlRead($Input1,1),8))) GUICtrlSetData($Label2,"Binary") ;ConsoleWrite("_HexToDecimal " & _HexToDecimal(GUICtrlRead($Input1,1)) & @LF) ;ConsoleWrite("_HexToBinaryString " & _HexToBinaryString(GUICtrlRead($Input1,1)) & @LF) Case $msg = $radio3 And BitAND(GUICtrlRead($radio3), $GUI_CHECKED) = $GUI_CHECKED GUICtrlSetData($Label1out,_BinaryToHexString(StringStripWS(GUICtrlRead($Input1,1),8))) GUICtrlSetData($Label1,"Hexadecimal") GUICtrlSetData($Label2out,_BinaryToDec(StringStripWS(GUICtrlRead($Input1,1),8))) GUICtrlSetData($Label2,"Decimal") ;ConsoleWrite("_BinaryToHexString " & _BinaryToDec(GUICtrlRead($Input1,1)) & @LF) ;ConsoleWrite("_HexToBinaryString " & _HexToBinaryString(GUICtrlRead($Input1,1)) & @LF) EndSelect WEnd ; Conversion Code - Chart ; DECIMAL 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 ; HEX 0 1 2 3 4 5 6 7 8 9 A B C D E F 10 ; BINARY 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 10000 ; --------------------- Functions ----------------------------- ; Binary to Decimal Func _BinaryToDec($strBin) Local $Return Local $lngResult Local $intIndex If StringRegExp($strBin,'[0-1]') then $lngResult = 0 For $intIndex = StringLen($strBin) to 1 step -1 $strDigit = StringMid($strBin, $intIndex, 1) Select case $strDigit="0" ; do nothing case $strDigit="1" $lngResult = $lngResult + (2 ^ (StringLen($strBin)-$intIndex)) case else ; invalid binary digit, so the whole thing is invalid $lngResult = 0 $intIndex = 0 ; stop the loop EndSelect Next $Return = $lngResult Return $Return Else MsgBox(0,"Error","Wrong input, try again ...") Return EndIf EndFunc ; Decimal To Binary Func _DecToBinary($iDec) Local $i, $sBinChar = "" If StringRegExp($iDec,'[[:digit:]]') then $i = 1 Do $x = 16^$i $i +=1 ; Determine the Octets Until $iDec < $x For $n = 4*($i-1) To 1 Step -1 If BitAND(2 ^ ($n-1), $iDec) Then $sBinChar &= "1" Else $sBinChar &= "0" EndIf Next Return $sBinChar Else MsgBox(0,"Error","Wrong input, try again ...") Return EndIf EndFunc ; #FUNCTION# ============================================================== ; Function Name..: _HexToDec ( "expression" ) ; Description ...: Returns decimal expression of a hexadecimal string. ; Parameters ....: expression - String representation of a hexadecimal expression to be converted to decimal. ; Return values .: Success - Returns decimal expression of a hexadecimal string. ; Failure - Returns "" (blank string) and sets @error to 1 if string is not hexadecimal type. ; Author ........: jennico (jennicoattminusonlinedotde) ; Remarks .......: working input format: "FFFF" or "0xFFFF" (string format), do NOT pass 0xFFFF without quotation marks (number format). ; current AutoIt Dec() limitation: 0x7FFFFFFF (2147483647). ; Related .......: Hex(), Dec(), _DecToHex() ; ======================================================================= Func _HexToDecimal($hx_hex) If StringLeft($hx_hex, 2) = "0x" Then $hx_hex = StringMid($hx_hex, 3) If StringIsXDigit($hx_hex) = 0 Then SetError(1) MsgBox(0,"Error","Wrong input, try again ...") Return "" EndIf Local $ret="", $hx_count=0, $hx_array = StringSplit($hx_hex, ""), $Ii, $hx_tmp For $Ii = $hx_array[0] To 1 Step -1 $hx_tmp = StringInStr($HX_REF, $hx_array[$Ii]) - 1 $ret += $hx_tmp * 16 ^ $hx_count $hx_count += 1 Next Return $ret EndFunc ;==>_HexToDec() ; #FUNCTION# ============================================================== ; Function Name..: _DecToHex ( expression [, length] ) ; Description ...: Returns a string representation of an integer converted to hexadecimal. ; Parameters ....: expression - The integer to be converted to hexadecimal. ; - [optional] Number of characters to be returned (no limit). ; If no length specified, leading zeros will be stripped from result. ; Return values .: Success - Returns a string of length characters representing a hexadecimal expression, zero-padded if necessary. ; Failure - Returns "" (blank string) and sets @error to 1 if expression is not an integer. ; Author ........: jennico (jennicoattminusonlinedotde) ; Remarks .......: Output format "FFFF". ; The function will also set @error to 1 if requested length is not sufficient - the returned string will be left truncated. ; Be free to modify the function to be working with binary type input - I did not try it though. ; current AutoIt Hex() limitation: 0xFFFFFFFF (4294967295). ; Related .......: Hex(), Dec(), _HexToDec() ; ======================================================================= Func _DecimalToHex($hx_dec, $hx_length = 21) If IsInt($hx_dec) = 0 Then SetError(1) MsgBox(0,"Error","Wrong input, try again ...") Return "" EndIf Local $ret = "", $Ii, $hx_tmp, $hx_max If $hx_dec < 4294967296 Then If $hx_length < 9 Then Return Hex($hx_dec, $hx_length) If $hx_length = 21 Then $ret = Hex($hx_dec) While StringLeft($ret, 1) = "0" $ret = StringMid($ret, 2) WEnd Return $ret EndIf EndIf For $Ii = $hx_length - 1 To 0 Step -1 $hx_max = 16 ^ $Ii - 1 If $ret = "" And $hx_length = 21 And $hx_max > $hx_dec Then ContinueLoop $hx_tmp = Int($hx_dec/($hx_max+1)) If $ret = "" And $hx_length = 21 And $Ii > 0 And $hx_tmp = 0 Then ContinueLoop $ret &= StringMid($HX_REF, $hx_tmp+1, 1) $hx_dec -= $hx_tmp * ($hx_max + 1) Next $ret=String($ret) If $hx_length < 21 And StringLen($ret) < $hx_length Then SetError(1) Return $ret EndFunc ;==>_DecToHex() ; ---------------------------------------------------------------- ; Hex to Decimal Conversion ; Correct till Decimal 65789 ?! Func _HexToDecimal_NotCorrect($Input) Local $Temp, $i, $Pos, $Ret, $Output If StringRegExp($input,'[[:xdigit:]]') then $Temp = StringSplit($Input,"") For $i = 1 to $Temp[0] $Pos = $Temp[0] - $i $Ret = Dec (Hex ("0x" & $temp[$i] )) * 16 ^ $Pos $Output &= $Ret Next return $Output Else MsgBox(0,"Error","Wrong input, try again ...") Return EndIf EndFunc ; Decimal To Hex Conversion Func _DecimalToHex_NotCorrect($Input) local $Output, $Ret If StringRegExp($input,'[[:digit:]]') then Do $Ret = Int(mod($Input,16)) $Input = $Input/16 $Output = $Output & StringRight(Hex($Ret),1) Until Int(mod($Ret,16))= 0 Return StringMid(_StringReverse($Output),2) Else MsgBox(0,"Error","Wrong input, try again ...") Return EndIf EndFunc ;------------------------------------------------------------------- ; Binary To Hex Func _BinaryToHexString($BinaryValue) Local $test, $Result = '',$numbytes,$nb If StringRegExp($BinaryValue,'[0-1]') then if $BinaryValue = '' Then SetError(-2) Return endif Local $bits = "0000|0001|0010|0011|0100|0101|0110|0111|1000|1001|1010|1011|1100|1101|1110|1111" $bits = stringsplit($bits,'|') #region check string is binary $test = stringreplace($BinaryValue,'1','') $test = stringreplace($test,'0','') if $test <> '' Then SetError(-1);non binary character detected Return endif #endregion check string is binary #region make binary string an integral multiple of 4 characters While 1 $nb = Mod(StringLen($BinaryValue),4) if $nb = 0 then exitloop $BinaryValue = '0' & $BinaryValue WEnd #endregion make binary string an integral multiple of 4 characters $numbytes = Int(StringLen($BinaryValue)/4);the number of bytes Dim $bytes[$numbytes],$Deci[$numbytes] For $j = 0 to $numbytes - 1;for each byte ;extract the next byte $bytes[$j] = StringMid($BinaryValue,1+4*$j,4) ;find what the dec value of the byte is for $k = 0 to 15;for all the 16 possible hex values if $bytes[$j] = $bits[$k+1] Then $Deci[$j] = $k ExitLoop EndIf next Next ;now we have the decimal value for each byte, so stitch the string together again $Result = '' for $l = 0 to $numbytes - 1 $Result &= Hex($Deci[$l],1) Next return $Result Else MsgBox(0,"Error","Wrong input, try again ...") Return EndIf EndFunc ; Hex To Binary Func _HexToBinaryString($HexValue) Local $Allowed = '0123456789ABCDEF' Local $Test,$n Local $Result = '' if $hexValue = '' then SetError(-2) Return EndIf $hexvalue = StringSplit($hexvalue,'') for $n = 1 to $hexValue[0] if not StringInStr($Allowed,$hexvalue[$n]) Then SetError(-1) return 0 EndIf Next Local $bits = "0000|0001|0010|0011|0100|0101|0110|0111|1000|1001|1010|1011|1100|1101|1110|1111" $bits = stringsplit($bits,'|') for $n = 1 to $hexvalue[0] $Result &= $bits[Dec($hexvalue[$n])+1] Next Return $Result EndFunc Func _GUICtrlCreateGradient($nStartColor, $nEndColor, $nX, $nY, $nWidth, $nHeight) Local $color1R = _ColorGetRed($nStartColor) Local $color1G = _ColorGetGreen($nStartColor) Local $color1B = _ColorGetBlue($nStartColor) Local $nStepR = (_ColorGetRed($nEndColor) - $color1R) / $nHeight Local $nStepG = (_ColorGetGreen($nEndColor) - $color1G) / $nHeight Local $nStepB = (_ColorGetBlue($nEndColor) - $color1B) / $nHeight GuiCtrlCreateGraphic($nX, $nY, $nWidth, $nHeight) For $i = 0 To $nHeight - $nY $sColor = "0x" & StringFormat("%02X%02X%02X", $color1R+$nStepR*$i, $color1G+$nStepG*$i, $color1B+$nStepB*$i) GUICtrlSetGraphic(-1, $GUI_GR_COLOR, $sColor, 0xffffff) GUICtrlSetGraphic(-1, $GUI_GR_MOVE, 0, $i) GUICtrlSetGraphic(-1, $GUI_GR_LINE, $nWidth, $i) Next EndFunc Some of the functions i borrowed from someone -- some of them are mine. Can't really tell what's what. Anyhow, I hope it is fool proof. It wasn' t fool proof, therefore I followed "jennico" advise and used his DecHex and HexDec functions. Enjoy !! regards ptrex1 point