Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 11/26/2019 in all areas

  1. FrancescoDiMuro

    ComboBox

    @AlMax3000 Use _FileListToArrayRec() to read files/directories to an array, and then add the array elements in the ComboBox
    2 points
  2. The code is solid and simple, it can almost explain itself. This is the native autoit way to do the "imagesearch", no 3rd party .dll needed. It gets "your.bmp", and "screenshot.bmp" ----> Convert the .bmp files into 2D-Arrays (Malkey's function) ----> Compare the 2D-arrays, return the matched position. Tested on: Windows 7; Windows server 2008R2; Windows 10 1809. Pros: It is native. No extra .dll needed It is super robust. (I used to have lots of funny results using other imagesearch libs). It gets screenshot the same you get your screenshot crop, so it always gets a solid result, and 100% accurate. The code is very simple and friendly, all level users can understand and use it. Cons: It is slow to convert your.big.screen.bmp into a 2D-array, and may consume 200+MB of memory and may take 5 - 20 seconds to return the result. (the actual search in an array is fast, but the conversion from .bmp to array is slow. The speed depends on your CPU speed and your screen size). Correct: now optimized, it's ~5 seconds and ~ 70MB ram usage. It is a pixel-by-pixel color-code strict comparison in the "array-in-array" search, so you have to use the 24-bit BMP file, no "Tolerance" allowed. 2019-Jun-11: script update: Same day updated: Update example; Optimize the algorithm for performance, now most computers can get the result in ~5 seconds, using ~70MB temporary memory, for the 1920x1080 resolution screen. 2019-Jun-12 script update: It now uses "PrintScreen" hotkey to save the screenshot.bmp (restores the user's old clipboard content after it is done) ~This is the only way to make sure the screenshot matches exactly what the user is seeing, after doing dozens of harsh tests. The reason: The UDF "ScreenCapture" and "ImageSearch.dll" are not reliable for an unknown reason. Some window/dialogue special drawings are "invisible" in their screenshots. But the "PrintScreen" key -> Clipboard -> screenshot.bmp, this method always catches exact things showing on the screen. #include <GDIPlus.au3> #include <ClipBoard.au3> ;Sinple Example.================== the 1.bmp is what you want to find on your screen $result = _ScreenSearchBmp("1.bmp") if $result[0] = 0 Then MsgBox(0,"","not found") Else MouseMove($result[0],$result[1],20) ;move mouse to the result EndIf ;Example End.================== You can "include" this file after you remove this "Example" part here. ;=============================================================================== ; ; Description: Main Function. Find the position of an image on the desktop ; Parameter(s): ; $center = 1 - Set where the returned x,y location of the image is. ; default 1 means center, 0 means top-left ; ; Return Value(s): On Success - Returns the array of matched position [x,y] on your screen. ; On Failure - Returns array [0,0] (BTW, there is no position 0,0 on a screen, so it means error) ; ; Note: Warning: The BMP file must be a 24-bit BMP (windows default) ; ;=============================================================================== Func _ScreenSearchBmp($file,$center=1) local $pixelarray,$screenarray ;get both your image.bmp and screenshot.bmp into pixel-by-pixel 2D arrays _FileImageToArray($file, $pixelarray) _Clip_screenshot(@TempDir & "\screenshot.bmp") _FileImageToArray(@TempDir & "\screenshot.bmp",$screenarray) FileDelete(@TempDir & "\screenshot.bmp") ;compare the 2 2D-arrays local $result = _2darray_in_2darray($screenarray,$pixelarray) ;result tidy up, for if $center=1, and for if not found. Local $aresult[2] $aresult[0] = $result[0] $aresult[1] = $result[1] if $aresult[0] = 0 then Return $aresult ;if not found , return 0 0 here if $center = 1 then $aresult[0] = $result[0]+ Round(UBound($pixelarray,1)/2) if $center = 1 then $aresult[1] = $result[1]+ Round(UBound($pixelarray,2)/2) Return $aresult ;if ALL GOOD, and $center=1 then return the center of the image here. EndFunc ;=============================================================================== ; Code by Malkey, converts .bmp into 2D array pixal by pixal. : thanks man! ;=============================================================================== Func _FileImageToArray($filename, ByRef $aArray) Local $Reslt, $stride, $format, $Scan0, $iW, $iH, $hImage Local $v_Buffer, $width, $height Local $i, $j _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile($filename) $iW = _GDIPlus_ImageGetWidth($hImage) $iH = _GDIPlus_ImageGetHeight($hImage) $Reslt = _GDIPlus_BitmapLockBits($hImage, 0, 0, $iW, $iH, $GDIP_ILMREAD, $GDIP_PXF32ARGB) ;Get the returned values of _GDIPlus_BitmapLockBits () $width = DllStructGetData($Reslt, "width") $height = DllStructGetData($Reslt, "height") $stride = DllStructGetData($Reslt, "stride") $format = DllStructGetData($Reslt, "format") $Scan0 = DllStructGetData($Reslt, "Scan0") Dim $aArray[$width][$height] For $i = 0 To $iW - 1 For $j = 0 To $iH - 1 $aArray[$i][$j] = DllStructGetData(DllStructCreate("dword", $Scan0 + ($j * $stride) + ($i * 4)), 1) Next Next _GDIPlus_BitmapUnlockBits($hImage, $Reslt) _GDIPlus_ImageDispose($hImage) _GDIPlus_Shutdown() Return EndFunc ;==>_FileImageToArray ;=============================================================================== ; ; Description: ; My code, search a 2D array inside another 2d array ; If found, return the positon of first element ; If error or not found, return array [0,0]. Because the very first match would be [1,1], "0" means something wrong. ; eg. search a 2d array ; [1,2,3,4] ; [5,6,7,8] ; [9,0,1,2] ; for: ; [7,8] ; [1,2] ; You will get result [2,3] (means, matched, first element position is row 2, colunm 3) ; ; Parameter(s): ; ; Return Value(s): On Success - Returns the array of matched [x,y], the top-left element position in the source. ; On Failure - Returns [0,0] ; ; ;=============================================================================== Func _2darray_in_2darray($source,$search) ;get the size of the both arrays local $sourcerow = UBound($source,1) Local $sourcecol = UBound($source,2) local $searchrow = UBound($search,1) Local $searchcol = UBound($search,2) ;error input cheching, if error return position 0,0 if $sourcerow = 0 or $sourcecol = 0 or $searchrow = 0 or $searchcol = 0 then Local $aPeople[2] $aPeople[0] = 0 $aPeople[1] = 0 Return $aPeople EndIf ; A crazy 4-for-loops, compare every x,y of search array in every x,y in source array for $ssr = 1 to $sourcerow - $searchrow +1 for $ssc = 1 to $sourcecol - $searchcol +1 for $sr = 1 to $searchrow for $sc = 1 to $searchcol ;if an element not match, go back, search for next if $search[$sr-1][$sc-1] <> $source[$ssr+$sr-2][$ssc+$sc-2] then ContinueLoop 3 Next Next ;if the loop passed all elements test, made it here, means the result is found! congress! lets return the result: Local $aPeople[2] $aPeople[0] = $ssr $aPeople[1] = $ssc Return $aPeople Next Next ;all the loops finished, no result found. return [0,0] Local $aPeople[2] $aPeople[0] = 0 $aPeople[1] = 0 Return $aPeople EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _Clip_screenshot ; Description ...: This get a screenshot.bmp using "Print Screen" key, so the image is EXACT same image you use "Print Screen" key, to avoid funny results. ; Syntax ........: _Clip_screenshot($file) ; Parameters ....: $file - The location of the screen shot .bmp file you want it to save ; Return values .: None ; Author ........: Kyle ; =============================================================================================================================== Func _Clip_screenshot($file) local $tempdata = _ClipBoard_GetData() ;save current user's clipboard Send("{PRINTSCREEN}") sleep(200) If _ClipBoard_IsFormatAvailable($CF_BITMAP) Then _ClipBoard_Open(0) $hClipboardImage = _ClipBoard_GetDataEx($CF_BITMAP) _ClipBoard_Close() _GDIPlus_Startup() $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hClipboardImage) Local $iX = _GDIPlus_ImageGetWidth($hBitmap) Local $iY = _GDIPlus_ImageGetHeight($hBitmap) Local $hClone = _GDIPlus_BitmapCloneArea($hBitmap, 0, 0, $iX, $iY, $GDIP_PXF24RGB) ;make sure its 24bit bmp _GDIPlus_ImageDispose($hBitmap) $hBitmap = $hClone $sCLSID = _GDIPlus_EncodersGetCLSID("BMP") _GDIPlus_ImageSaveToFileEx($hBitmap, $file, $sCLSID, 0) _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_Shutdown() EndIf _ClipBoard_SetData($tempdata) ; restore user clipboard EndFunc Remove the "example" part then you can include this code as a file.
    1 point
  3. Version 0.2019.12.12

    789 downloads

    My fine tuned High Contrast theme, came from the need of a better "Dark Mode", that is still not there yet. Okay, let's use a "High Contrast Theme", but then again, the available colors to tweak are quite limited. So I'm like But since we can code: Behold !, an expanded theme color chooser 😁 And none of the changes, add or remove anything to the OS. Is just color tweaking. ...is incomplete as far as I would like it to be but, fully functional at this stage. ( I'll continue as time permits )
    1 point
  4. Use Chrome to inspect. If that doesn't change anything then stop the weed web !
    1 point
  5. SkysLastChance

    ComboBox

    _GUICtrlComboBox_AddDir($idCombo, $sSelectFolder & "\*") ? You may need to look into _FileListToArrayRec
    1 point
  6. Hi @ArcFreez ! There are probably neater solutions, but as long as you're satisfied, I'd leave it as it is . As far as I could figure out, 7zG.exe does not write an ERRStream, unlike 7za.exe. On the other hand, 7zG.exe provides you with a progress bar, even if you have to terminate the application with ProcessClose in case of an error (wrong password). I would stick to 7zG.exe . Besides : The Exitcodes of 7za.exe are not very informative anyway. This is e.g. the ERRStream in case a wrong password is used : PID = 836 StdoutRead ==> 7-Zip (a) 19.00 (x86) : Copyright (c) 1999-2018 Igor Pavlov : 2019-02-21 Scanning the drive for archives: 1 file, 48342224 bytes (47 MiB) Extracting archive: C:\AutoIt\Zip-test\Archive.zip -- Path = C:\AutoIt\Projekte\Zip-test\Archive.zip Type = zip Physical Size = 48342224 Sub items Errors: 1 Archives with Errors: 1 Sub items Errors: 1 Have a nice evening, Musashi
    1 point
  7. Give me some time ( approx. 1 hour), I just have a few other things to finish .
    1 point
  8. @ArcFreez : You can use the commandline versions of 7-Zip directly : -> copy 7zA.exe, 7zG.exe and 7z.dll (see latest version of 7-Zip) in a directory, here e.g. @ScriptDir Info EXITCODES : Example (q&d) : Global $s7ZipProg = @ScriptDir & '\' & "7za.exe" ; w/o GUI-Progressbar Global $s7ZipProgGUI = @ScriptDir & '\' & "7zG.exe" ; with GUI-Progressbar Global $sZipPassword = "" ; <== Password Global $sArchive = "Archive.Zip" ; <== The Archive to use Global $sOutDir = @ScriptDir ; <== Where to extract the files ; switch : -aoa = Overwrite all existing files without prompt. ; switch : -y = suppress overwrite queries in the e and x commands. ; 1. w/o GUI-Progressbar : $sCommand = $s7ZipProg & ' x "' & $sArchive & '" -o"' & $sOutDir & '" -p' & $sZipPassword & ' -aoa -y' RunWait ($sCommand, "", @SW_HIDE) ; 2. with GUI-Progressbar : $sCommand = $s7ZipProgGUI & ' x "' & $sArchive & '" -o"' & $sOutDir & '" -p' & $sZipPassword & ' -aoa -y' RunWait ($sCommand, "", @SW_SHOW)
    1 point
  9. No, -pPASSWORD is correct. -p (set Password) switch Syntax -p{password} {password} Specifies password. Examples : 7z a archive.7z -psecret -mhe *.txt
    1 point
  10. Moved to the appropriate forum. Moderation Team
    1 point
  11. A pretty vague definition! If I guess correctly you want to replace a tooling sequence by another one. Does this do the job? Local $sToBeCopied = StringRegExpReplace(FileRead("O8000.txt"), "(?s)(.*?\RN1.*?\R)(.*?\RM99\R)(.*)", "$2") Local $sModified = StringRegExpReplace(FileRead("O1800.txt"), "(?s)(.*?\RN1.*?\R)(.*?\RM50\R(?=\h*\R))(.*)", "$1" & $sToBeCopied & "$3") FileDelete("O1800_new.txt") FileWrite("O1800_new.txt", $sModified)
    1 point
  12. I like to use this method with either IsVisible or IsEnabled depending on how the screen reacts. it's much more coding but it's faster to run the automation. $iTimer = TimerInit() While 1 If ControlCommand("Traffic-wizard", "&Next", "Button6", "IsVisible", "") = 1 Then ExitLoop EndIf If TimerDiff($iTimer) >= 30000 Then ;What's the max time until it throws an error? 30 seconds MsgBox(0, "Failed", "Next screen failed to display within the allowed time") Exit 2 EndIf WEnd ;Now ControlClick the button ControlClick("Traffic-wizard", "&Next >", "Button6")
    1 point
  13. You are mixing a few very different techniques in your script. _Excel* functions use COM to communicate with Excel Win* functions work with the Excel GUI You are using Excel's Select method. This automates the Excel GUI as well Send etc. sends keystrokes to the active window Your script is slowed down by the Sleep statements #4 is prone to errors because of user interaction. I suggest to do everything with the _Excel* functions. If none is available then you could use pure COM in additon to work with Excel. First step would be to grab one of the steps you do (Counter = 1, 2, 3 or 4) and explain what you want to do so we can help you to replace it with COM. Gerne zusätzlich auch in Deutsch
    1 point
  14. Hi all. It's a long time I didn't write a piece of code here... I found the subject interesting, I tried for a long time to find a suitable code ... this is something that can not compete with JC's code 😅 Local $sMacList = '' & _ '12-34-56-34-14-91' & @CR & _ '12-34-56-80-04-54' & @CR & _ '12-34-56-80-93-11' & @CR & _ '12-34-56-EA-76-0F' & @CR & _ '12-34-56-EA-76-9F' & @CR & _ '12-34-56-EA-78-11' & @CR & _ '12-34-56-EA-78-19' Local $sPattern _generatePattern($sMacList) ConsoleWrite($sPattern) Func _generatePattern($str) Local $aComb, $sLeft Local $aMac = StringRegExp($str, "\N+", 3) Local $sFirst = StringRegExp($str, "^[[:xdigit:]]{2}", 1)[0] Local $iLen = StringLen(StringRegExpReplace($str, "(?s)\R.+", "")) Local $sReplace = StringRegExpReplace($str, "(?m)^" & $sFirst & "(-|$)", "") If @extended = UBound($aMac) Then $sPattern &= $sFirst & "-" If $sReplace <> "" Then _generatePattern($sReplace) Else $aComb = StringRegExp($str, "(?:^|\R)([[:xdigit:]]{2})(?!.*\R\1)", 3) $sPattern &= "(" For $i = 0 To UBound($aComb) - 1 $sPattern &= ($i ? "|" : "") & $aComb[$i] & "-" $sLeft = StringRegExpReplace(StringRegExpReplace($str, "(?m)" & $aComb[$i] & "-|^(?!" & $aComb[$i] & ")\N+\R?" , ""), "\R$", "") If $iLen <> 2 Then _generatePattern($sLeft) Next $sPattern &= ")" EndIf $sPattern = StringRegExpReplace($sPattern, "-(?=[|)])", "") EndFunc
    1 point
  15. Inpho

    AutoIt Snippets

    I use these daily; thought I'd share. Don't use this version, updated one is below #AutoIt3Wrapper_Au3Check_Parameters=-d -w- 1 -w 2 -w 3 -w 4 -w 5 -w 6 #include-once #include <Date.au3> ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringRandom ; Description ...: Returns a string of random characters ; Syntax ........: _StringRandom($iAmount[, $iType = 1]) ; Parameters ....: $iAmount - an integer value. Length of returned string ; $iType - [optional] an integer value. Default is 1. ; 1 - Return digits (0 - 9) ; 2 - Return hexadecimal (0 - 9, A - F) ; 3 - Return Alphanumeric upper (0 - 9, A - Z) ; 4 - Return Alphanumeric (0 - 9, A - Z, a - z) ; 5 - Return Alpha upper (A - Z) ; 6 - Return Alpha (A - Z, a - z) ; Return values .: Success - String ; Failure - Empty string and @error flag as follows: ; @error : 1 - $iAmount is not a positive integer ; 2 - $iType is out of bounds ; Author ........: Sam Coates ; =============================================================================================================================== Func _StringRandom($iAmount, $iType = 1) If $iAmount < 1 Or IsInt($iAmount) = 0 Then Return(SetError(-1, 0, "")) Local $sString = "" Local $iRandom = 0, $iRandomLow = 1, $iRandomHigh = 62 Local $aCharId[63] If $iType = 1 Then ;; digits: 1 - 10 $iRandomHigh = 10 ElseIf $iType = 2 Then ;; hexadecimal: 1 - 16 $iRandomHigh = 16 ElseIf $iType = 3 Then ;; alnumupper: 1 - 36 $iRandomHigh = 36 ElseIf $iType = 4 Then ;; alnum: 1 - 62 $iRandomHigh = 62 ElseIf $iType = 5 Then ;; alphaupper: 11 - 36 $iRandomLow = 11 $iRandomHigh = 36 ElseIf $iType = 6 Then ;; alpha: 11 = 62 $iRandomLow = 11 $iRandomHigh = 62 Else Return(SetError(-2, 0, "")) EndIf For $i = 1 To 10 ;; loop through our array, assigning ascii values to each element $aCharId[$i] = Chr(47 + $i) Next For $i = 11 to 36 $aCharId[$i] = Chr(54 + $i) Next For $i = 37 To 62 $aCharId[$i] = Chr(60 + $i) Next For $i = 1 To $iAmount $iRandom = Random($iRandomLow, $iRandomHigh, 1) ;; random interger between $iRandomLow and $iRandomHigh $sString &= $aCharId[$iRandom] ;; append string with corresponding character from ascii array Next Return ($sString) EndFunc ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringTrimLeft ; Description ...: Searches for a string inside a string, then removes everything on the left of that string ; Syntax ........: _StringTrimLeft($sString, $sRemove[, $iCaseSense = 0, $iOccurrence = 1]) ; Parameters ....: $sString - a string value. The string to search inside. ; $sRemove - a string value. The string to search for. ; $iCaseSense - an integer value. Flag to indicate if the operations should be case sensitive. ; $iOccurrence - an integer value. Which occurrence of the substring to find in the string. Use a ; negative occurrence to search from the right side. ; Return values .: Success - String ; Failure - Empty string as returned from StringTrimLeft() ; Author ........: Sam Coates ; =============================================================================================================================== Func _StringTrimLeft($sString, $sRemove, $iCaseSense = 0, $iOccurrence = 1) Local $sReturn = StringTrimLeft($sString, StringInStr($sString, $sRemove, $iCaseSense, $iOccurrence) + StringLen($sRemove) - 1) Return ($sReturn) EndFunc ;==>_StringTrimLeft ; #FUNCTION# ==================================================================================================================== ; Name ..........: _StringLeft ; Description ...: Searches for a string inside a string, then removes everything on the right of that string ; Syntax ........: _StringLeft($sString, $sRemove[, $iCaseSense = 0, $iOccurrence = 1]) ; Parameters ....: $sString - a string value. The string to search inside. ; $sRemove - a string value. The string to search for. ; $iCaseSense - an integer value. Flag to indicate if the operations should be case sensitive. ; $iOccurrence - an integer value. Which occurrence of the substring to find in the string. Use a ; negative occurrence to search from the right side. ; Return values .: Success - String ; Failure - Empty string as returned from StringLeft() ; Author ........: Sam Coates ; =============================================================================================================================== Func _StringLeft($sString, $sRemove, $iCaseSense = 0, $iOccurrence = 1) Local $sReturn = StringLeft($sString, StringInStr($sString, $sRemove, $iCaseSense, $iOccurrence) - 1) Return ($sReturn) EndFunc ;==>_StringLeft ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileToFileName ; Description ...: Returns a filename from a FQPN (Fully Qualified Path Name) ; Syntax ........: _FileToFileName($sPath[, $bIncludeExtension = True]) ; Parameters ....: $sPath - a string value. ; $bIncludeExtension - [optional] a boolean value. Default is True. ; Return values .: Success - String ; Failure - Empty string as returned from StringLeft() ; Author ........: Sam Coates ; =============================================================================================================================== Func _FileToFileName($sPath, $bIncludeExtension = True) Local $sReturn = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1)) If $bIncludeExtension = False Then $sReturn = StringLeft($sReturn, StringInStr($sReturn, ".", 0, -1) - 1) Return ($sReturn) EndFunc ;==>_FileToFileName ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileToFilePath ; Description ...: Returns a folder path from a FQPN (Fully Qualified Path Name) ; Syntax ........: _FileToFilePath($sPath) ; Parameters ....: $sPath - a string value. ; Return values .: Success - String ; Failure - Empty string as returned from StringLeft() ; Author ........: Sam Coates ; =============================================================================================================================== Func _FileToFilePath($sPath) Local $sReturn = StringLeft($sPath, StringInStr($sPath, "\", 0, -1) - 1) Return ($sReturn) EndFunc ;==>_FileToFilePath ; #FUNCTION# ==================================================================================================================== ; Name ..........: _FileToFileExtension ; Description ...: Returns a file extension from a filename/FQPN (Fully Qualified Path Name) ; Syntax ........: _FileToFileExtension($sPath) ; Parameters ....: $sPath - a string value. ; Return values .: Success - String ; Failure - Empty string as returned from StringTrimLeft() ; Author ........: Sam Coates ; =============================================================================================================================== Func _FileToFileExtension($sPath) Return (StringTrimLeft($sPath, StringInStr($sPath, ".", 0, -1))) EndFunc ;==>_FileToFileExtension ; #FUNCTION# ==================================================================================================================== ; Name ..........: _DateTimeGet ; Description ...: Returns the date and time formatted for use in sortable filenames, logs, listviews, etc. ; Syntax ........: _DateTimeGet(iType = 1[, $bHumanFormat = False]) ; Parameters ....: $iType - [optional] an integer value. Default is 1. ; 1 - Date and time in file-friendly format; 20190115_113756 ; 2 - Date in file-friendly format; 20190115 ; 3 - Time in file friendly format; 113756 ; $bHumanFormat - [optional] a boolean value. Default is False. ; True - Includes slashes in the date and colons in the time with a space inbetween ; False - No slashes or colons included with an underscore inbetween ; Return values .: Success - String ; Failure - Sets @error to non-zero and returns an empty string ; Author ........: Sam Coates ; =============================================================================================================================== Func _DateTimeGet($iType = 1, $bHumanFormat = False) If $iType < 1 Or $iType > 3 Then Return(SetError(-1, 0, "")) ;; Param1: ;; 1 = Date and time in file friendly format: 20190115_113756 ;; 2 = Date in file friendly format: 20190115 ;; 3 = Time in file friendly format: 113756 ;; Param2: ;; True = Use human-readable format: 15/01/2019 11:37:56 Local $sTime = _NowTime() Local $sDate = _NowDate() If $iType = 1 Then If $bHumanFormat = False Then $sTime = StringReplace($sTime, ":", "") $sDate = StringReplace($sDate, "/", "") $sDate = StringTrimLeft($sDate, 4) & StringMid($sDate, 3, 2) & StringLeft($sDate, 2) Return ($sDate & "_" & $sTime) Else Return ($sDate & " " & $sTime) EndIf ElseIf $iType = 2 Then If $bHumanFormat = False Then $sDate = StringReplace($sDate, "/", "") $sDate = StringTrimLeft($sDate, 4) & StringMid($sDate, 3, 2) & StringLeft($sDate, 2) EndIf Return ($sDate) ElseIf $iType = 3 Then If $bHumanFormat = False Then $sTime = StringReplace($sTime, "/", "") EndIf Return ($sTime) EndIf EndFunc ;==>_DateTimeGet EDIT: I have no idea why I claim digits are 1 - 10 instead of 0 - 9... Excuse my brainfart. Amended.
    1 point
  16. you have forgotten to store the ID line 85 must be $id = _GUICtrlListView_AddItem($List1, $id, 1) ; id
    1 point
  17. trancexx

    WinHttp redirection

    Where do you actually use the action page? Try it like this: #include "WinHttp.au3" Global $sRead, $hOpen, $hConnect Global $sUsername, $sPassword $sUsername = "Email" $sPassword = "Password" Global $sUrl = "https://accounts.google.com/" $sActionPage = "ServiceLogin?hl=pt-BR&uilel=3&service=youtube&passive=true&continue=https%3A%2F%2Fwww.youtube.com%2Fsignin%3Ffeature%3Dsign_in_button%26next%3D%252F%26hl%3Dpt%26action_handle_signin%3Dtrue%26app%3Ddesktop#identifier" $hOpen = _WinHttpOpen('Mozilla/5.0 (Windows NT 5.1; rv:2.0) Gecko/20100101 Firefox/4.0'); create new session $hConnect = _WinHttpConnect($hOpen, $sUrl) $sRead = _WinHttpSimpleFormFill($hConnect, _ $sActionPage, "gaia_loginform", _ "name:Email", $sUsername, _ "type:submit", 0) $hConnNew = $sRead $sHTM = _WinHttpSimpleFormFill($hConnNew, _ $hOpen, "gaia_loginform", _ "name:Passwd", $sPassword, _ "type:submit", 0) If @error Then MsgBox(0, "Error", "Error: " & @error) Else ConsoleWrite(@CRLF & $sHTM & @CRLF & @CRLF) EndIf _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) Exit Do you see the difference? Btw, why that user agent string?
    1 point
  18. Not tough at all A bit simplified but still working : $aresult = StringRegExp($sContent,'(".*?")|(?<=,|^)[^,]*(?=,|$)', 3) request : (".*?") : groups of 0 or more characters inside quotes (lazy) | : or (?<=,|^) : preceded by a comma or start of string (lookbehind) [^,]* : 0 or more non-comma characters (negated character class) (?=,|$) : followed by a comma or end of string (lookahead)
    1 point
  19. You can do it like this: #include "WinHttp.au3" $initialurl = "http://google.com" ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Get connection handle $hConnect = _WinHttpConnect($hOpen, $initialurl) ; Register Callback function $hREDIRECT_CALLBACK = DllCallbackRegister(__Redirect, "none", "handle;dword_ptr;dword;ptr;dword") ; Set callback _WinHttpSetStatusCallback($hConnect, $hREDIRECT_CALLBACK, $WINHTTP_CALLBACK_FLAG_REDIRECT) ; Make a request $hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "/") ;Here the request follow the redirection and land on a different webpage ; Close handles _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen) ; Free callback DllCallbackFree($hREDIRECT_CALLBACK) ; Define callback function Func __Redirect($hInternet, $iContext, $iInternetStatus, $pStatusInformation, $iStatusInformationLength) Local $sStatus = "About to automatically redirect the request to: " & DllStructGetData(DllStructCreate("wchar[" & $iStatusInformationLength & "]", $pStatusInformation), 1) & " " ConsoleWrite("!>" & $sStatus & @CRLF) MsgBox(4096, "REDIRECTION:", $sStatus) EndFunc
    1 point
×
×
  • Create New...