KimberlyJillPereira

How to copy the first 10 characters in excel and paste it in the search box??

19 posts in this topic

#1 ·  Posted

May I know how to copy the first 10 characters in excel and paste it in the file explorer textbox? How to do? I know that you show use the StringLeft() function but I am not sure how to do. Please help me. Thank you! :)

kimberlyyy.png

lll.png

Share this post


Link to post
Share on other sites



#2 ·  Posted

@JLogan3o13 plss help. thanks

Share this post


Link to post
Share on other sites

#3 ·  Posted

This will search for the images throughout Y:\ and add them to Excel if found:

#include <Array.au3>
#include <IE.au3>
#include <String.au3>
#include<Excel.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
;Author: Kimberly Jill Pereira
#cs ########################################################################################################
    #  Script Function:                                                                                    #
    #  It is an Auto Login bot. It also extracts specific data from table and store it in Microsoft Excel. #
#ce ########################################################################################################

Local $sExcelPath = @ScriptDir
Local $sImagePath = "Y:\"

Local $oIE
Local $oDivs
Local $aPageCount, $iPageCount
Local $aTable, $oTables
Local $aTimeView[0][7]
Local $oUserName, $oPassWord
Local $sUserName = "Oneberry"
Local $sPassWord = "Qwer1234"
$oIE = _IECreate("http://www.timeview2.net/", 1); Opens IE browser
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE);Maximize Internet Explorer window
$oForms = _IETagNameGetCollection($oIE, "form")
For $oForm In $oForms
    If $oForm.id = "UserLoginForm" Then
        $oUserName = _IEFormElementGetObjByName($oForm, "data[User][username]")
        _IEFormElementSetValue($oUserName, $sUserName)
        $oPassWord = _IEFormElementGetObjByName($oForm, "data[User][password]")
        _IEFormElementSetValue($oPassWord, $sPassWord)
        _IEFormSubmit($oForm)
    EndIf
Next

_IENavigate($oIE, "http://www.timeview2.net/alarms")
$oDivs = _IETagNameGetCollection($oIE, "div")
For $oDiv In $oDivs
    If $oDiv.ClassName = "alarms index" Then
        $aPageCount = _StringBetween($oDiv.InnerText, "Page 1 of ", ", showing ")
        If @error Then Exit
        $iPageCount = Number($aPageCount[0])
    EndIf
Next

For $i = 1 To $iPageCount
    _IENavigate($oIE, "http://www.timeview2.net/alarms/index/group:All%20Groups/page:" & $i, 1)
    $oTables = _IETagNameGetCollection($oIE, "table")
    For $oTable In $oTables
        If $oTable.ClassName = "pageindex" Then
            $nTable = $oTable.NextElementSibling
            $aTable = _IETableWriteToArray($nTable, True)
            If UBound($aTable) - 1 > 0 And UBound($aTable, 2) = 7 Then
                If $i = 1 Then
                    _ArrayConcatenate($aTimeView, $aTable, 0)
                Else
                    _ArrayConcatenate($aTimeView, $aTable, 1)
                EndIf
                ExitLoop
            EndIf
        EndIf
    Next
 Next
 Local $oExcel = _Excel_Open(); Opens Microsoft Excel

Local $oWorkbook = _Excel_BookNew($oExcel); Create new Microsoft excel
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE);Maximize Microsoft Excel window
_ArrayColDelete($aTimeView, 6)
 _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aTimeView, "A1"); write the data to A1 cell of Microsoft excel
$oWorkbook.Activesheet.range("A1:G1").Font.Bold = True ; set font to bold
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Pictures", "G1"); write 'Pictures' to G1 cell
$oWorkbook.Activesheet.range("E2:F100").NumberFormat = "yyyy/mm/dd" & " hh:mm:ss" & " AM/PM" ;set E2 to F100 cell to date format in yyyy/mm/dd
$oExcel.ActiveSheet.Columns("A:G").AutoFit
$oColumns = $oExcel.Columns("G")
$oColumns.ColumnWidth = 40.86
$oRows = $oExcel.Rows("2:100");Expands row 2 until 100
$oRows.RowHeight = 198.75;Automatically expands row

Local $sWorkbook = $sExcelPath & "\" & StringReplace(StringReplace($aTimeView[UBound($aTimeView) -1][4] & "-" & $aTimeView[1][4], ":", "-"), " ", "_") & "_TimeView.xlsx"
Local $oExcel = _Excel_BookSaveAs($oWorkbook, $sWorkbook)
$aWorkBook = _Excel_RangeRead($oWorkbook)
Local $aImagePath
For $i = 1 To UBound($aWorkBook) - 1
    $aImagePath = _FileListToArrayRec($sImagePath, "m" & StringTrimLeft($aWorkBook[$i][5], 2) & "*.jpg", 1, 1, 0, 2)
    If UBound($aImagePath) >= 2 Then
        _Excel_PictureAdd($oWorkbook, Default, $aImagePath[1], "G" & $i + 1)
        $aImageSize = _ImageSize($aImagePath[1])
        $oRow = $oExcel.Rows($i + 1)
        $oRow.RowHeight = $aImageSize[1]
    EndIf
Next

;~ Malkeys code: https://www.autoitscript.com/forum/topic/108578-getting-image-size/
Func _ImageSize($sFileName)
    Local $aRet[2], $sExt = StringRegExpReplace($sFileName, "^.*\.", "")
    If (FileExists($sFileName) = 0) Or _
            ((StringLen($sExt) = 3) And (StringRegExp($sExt, "(?i)(bmp|gif|jpg|png|tif|emf|wmf)") = 0)) Or _
            ((StringLen($sExt) = 4) And (StringRegExp($sExt, "(?i)(tiff|jpeg)") = 0)) Then _
            Return SetError(1, 0, $aRet)
    Local $ghGDIPDll = DllOpen("GDIPlus.dll")
    Local $tInput = DllStructCreate("int Version;ptr Callback;int NoThread;int NoCodecs")
    Local $tToken = DllStructCreate("ulong_ptr Data")
    DllStructSetData($tInput, "Version", 1)
    DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", DllStructGetPtr($tToken), "ptr", DllStructGetPtr($tInput), "ptr", 0)
    Local $aImage = DllCall($ghGDIPDll, "int", "GdipLoadImageFromFile", "wstr", $sFileName, "ptr*", 0)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageWidth", "handle", $aImage[2], "uint*", -1)
    $aRet[0] = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageHeight", "handle", $aImage[2], "uint*", 0)
    $aRet[1] = $aResult[2]
    DllCall($ghGDIPDll, "int", "GdipDisposeImage", "handle", $aImage[2])
    DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", DllStructGetData($tToken, "Data"))
    DllClose($ghGDIPDll)
    Return SetError(0, 0, $aRet)
EndFunc ;==>_ImageSize

 

Share this post


Link to post
Share on other sites

#4 ·  Posted

The pictures are not displayed but the name of the excel file was changed. Actually what I wanted to do open file explorer then I wanted to copy the first 10 characters which is the date and paste it in the file explorer searchbox and then select the first folder which has the same date as the copied date. then in that folder has a list of pictures. As seen in the picture below for the first picture the time is 10:59 AM. Is it possible to use the time in excel only hour and minute and use the date modified in file explorer and do a comparision for example like if (datemodified< time_excel)  then condition is to display the picture. Please help me. I have to complete this as I am doing this for my internship. Thanks alot @Subz.:)

j.png

aaq.png

qwww.png

Share this post


Link to post
Share on other sites

#5 ·  Posted

The _FileListToArrayRec should automatically do the searching for you, it does a recursive search of the entire "Y:" drive, in a new script what does the following return, it should return an array of all .jpg in the Y: drive with the full file path, can you please confirm?

#include <Array.au3>
#include <File.au3>
Global $aImagePath = _FileListToArrayRec("Y:\", "m*.jpg", 1, 1, 0, 2)
_ArrayDisplay($aImagePath)

 

Share this post


Link to post
Share on other sites

#6 ·  Posted

Y drive full path : Y:\7_JlnBatu\IllegalParking\7_JlnBatu_cam2

Share this post


Link to post
Share on other sites

#7 ·  Posted

@Subz Thanks. I will try and see if it works.

Share this post


Link to post
Share on other sites

#8 ·  Posted

It only shows the links of the images but doesnt show the images and I wanted the images to be shown in G2 in Excel. Is it use _Excel_PictureAdd() function then will display picture?? It is almost solving but not solved. Please help. Thanks alot.:):).

qqad.png

mmnb.png

Share this post


Link to post
Share on other sites

#9 ·  Posted

Another problem was that for the first picture there are too many 03rd May 2017 I only want one picture for each row. Please help.thanks.

Share this post


Link to post
Share on other sites

#10 ·  Posted

From Row 80 of the code above can you replace with the following code and then let me know what the results are:

Local $sWorkbook = $sExcelPath & "\" & StringReplace(StringReplace($aTimeView[UBound($aTimeView) -1][4] & "-" & $aTimeView[1][4], ":", "-"), " ", "_") & "_TimeView.xlsx"
Local $oExcel = _Excel_BookSaveAs($oWorkbook, $sWorkbook)
$aWorkBook = _Excel_RangeRead($oWorkbook)
_ArrayDisplay($aWorkBook, "Workbook Array")
Local $aImagePath
For $i = 1 To UBound($aWorkBook) - 1
    $aImagePath = _FileListToArrayRec($sImagePath, "m" & StringTrimLeft($aWorkBook[$i][5], 2) & "*.jpg", 1, 1, 0, 2)
    MsgBox(48, "Filename Mask", "m" & StringTrimLeft($aWorkBook[$i][5], 2) & "*.jpg")
    _ArrayDisplay($aImagePath, "Jpg Filenames based upon Mask")
    If UBound($aImagePath) >= 2 Then
        _Excel_PictureAdd($oWorkbook, Default, $aImagePath[1], "G" & $i + 1)
        $aImageSize = _ImageSize($aImagePath[1])
        $oRow = $oExcel.Rows($i + 1)
        $oRow.RowHeight = $aImageSize[1]
    EndIf
Next

 

Share this post


Link to post
Share on other sites

#11 ·  Posted

"C:\Users\User\Desktop\1222eee.au3" (78) : ==> Variable used without being declared.:
Local $sWorkbook = $sExcelPath & "\" & StringReplace(StringReplace($aTimeView[UBound($aTimeView) -1][4] & "-" & $aTimeView[1][4], ":", "-"), " ", "_") & "Book1.xlsx"
Local $sWorkbook = ^ ERROR

 

I get this error

Share this post


Link to post
Share on other sites

#12 ·  Posted

You'll need to post the entire code as I'm not sure where the error is coming from, all I did was add in some checking (_ArrayDisplay) which should not have any effect on the script.

Share this post


Link to post
Share on other sites

#13 ·  Posted

I managed to automatically go into the date folder but I still cant match excel time with the filename time. Please help me thank you.

Local $sString = StringLeft($rRangeRead,8); only read the first 10 characters

$exceldate = StringRegExpReplace($sString, "\A(\d{4})(\d{2})(\d{2})","$1-$2-$3");to put slash inbetween the year month and day
$path = "Y:\7_JlnBatu\IllegalParking\7_JlnBatu_cam2";opens y drive ftp
$files = ($path & "\" & $exceldate);go into the place where it has all images

Share this post


Link to post
Share on other sites

#14 ·  Posted

#include <Array.au3>
#include <IE.au3>
#include <String.au3>
#include<Excel.au3>
#include <MsgBoxConstants.au3>
#include <Date.au3>
#include <FileConstants.au3>


;Author: Kimberly Jill Pereira
#cs ########################################################################################################
    #  Script Function:                                                                                    #
    #  It is an Auto Login bot. It also extracts specific data from table and store it in Microsoft Excel. #
#ce ########################################################################################################

Local $oIE
Local $oDivs
Local $aPageCount, $iPageCount
Local $aTable, $oTables
Local $aResults[0][7]
Local $oUserName, $oPassWord
Local $sUserName = "Oneberry"
Local $sPassWord = "Qwer1234"

$oIE = _IECreate("http://www.timeview2.net/", 1); Opens IE browser
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE);Maximize Internet Explorer window
$oForms = _IETagNameGetCollection($oIE, "form")
For $oForm In $oForms
    If $oForm.id = "UserLoginForm" Then
        $oUserName = _IEFormElementGetObjByName($oForm, "data[User][username]")
        _IEFormElementSetValue($oUserName, $sUserName)
        $oPassWord = _IEFormElementGetObjByName($oForm, "data[User][password]")
        _IEFormElementSetValue($oPassWord, $sPassWord)
        _IEFormSubmit($oForm)
    EndIf
Next

_IENavigate($oIE, "http://www.timeview2.net/alarms")
$oDivs = _IETagNameGetCollection($oIE, "div")
For $oDiv In $oDivs
    If $oDiv.ClassName = "alarms index" Then
        $aPageCount = _StringBetween($oDiv.InnerText, "Page 1 of ", ", showing ")
        If @error Then Exit
        $iPageCount = Number($aPageCount[0])
    EndIf
Next

For $i = 1 To $iPageCount
    _IENavigate($oIE, "http://www.timeview2.net/alarms/index/group:All%20Groups/page:" & $i, 1)
    $oTables = _IETagNameGetCollection($oIE, "table")
    For $oTable In $oTables
        If $oTable.ClassName = "pageindex" Then
            $nTable = $oTable.NextElementSibling
            $aTable = _IETableWriteToArray($nTable, True)
            If UBound($aTable) - 1 > 0 And UBound($aTable, 2) = 7 Then
                If $i = 1 Then
                    _ArrayConcatenate($aResults, $aTable, 0)
                Else
                    _ArrayConcatenate($aResults, $aTable, 1)
                EndIf
                ExitLoop
            EndIf
        EndIf
    Next
 Next
 Local $oExcel = _Excel_Open(); Opens Microsoft Excel

Local $oWorkbook = _Excel_BookNew($oExcel); Create new Microsoft excel
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE);Maximize Microsoft Excel window
_ArrayColDelete($aResults, 6);delete the seventh column 'Actions'
$rangewrite = _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aResults, "A1"); write the data to A1 cell of Microsoft excel
$oWorkbook.Activesheet.range("A1:G1").Font.Bold = True ; set font to bold
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Pictures", "G1"); write 'Pictures' to A1 cell
$oWorkbook.Activesheet.range("E2:F1000").NumberFormat = "yyyy/mm/dd" & " hh:mm:ss" & " AM/PM" ;set E2 to F100 cell to date format in yyyy/mm/dd
$oExcel.ActiveSheet.Columns("A:G").AutoFit
$oColumns = $oExcel.Columns("G")
$oColumns.ColumnWidth = 40.86
$oRows = $oExcel.Rows("2:1000");Expands row 2 until 1000
$oRows.RowHeight = 198.75;Automatically expands row
Local $rRangeRead = _Excel_RangeRead($oWorkbook, Default, "F2")
Local $sString = StringLeft($rRangeRead,8); only read the first 10 characters
Local $wString = StringMid($rRangeRead,11,2);read the minute
Local $qString = StringMid($rRangeRead,9,2);read the hour
$exceldate = StringRegExpReplace($sString, "\A(\d{4})(\d{2})(\d{2})","$1-$2-$3");to put slash inbetween the year month and day
;Local $www = ClipPut($exceldate);copies the text of 10 characters
$path = "Y:\7_JlnBatu\IllegalParking\7_JlnBatu_cam2";opens y drive ftp
$files = ($path & "\" & $exceldate);go into the place where it has all images


;   _Excel_PictureAdd($oWorkbook, Default,"G2", $sPicture, 250, 300, 300, 250)

ShellExecute($files)
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE);Maximize Internet Explorer window

Local $sString = StringLeft($rRangeRead, 16)
Local $oString = StringMid($sString, 3, 12)
;MsgBox("Hi","Hi",$oString)
Local $filename = "m" & $oString
Local $hfilename = $files & "\" & $filename
ShellExecute($hfilename)
;Local $www = ClipPut($filename);copies the text of 10 characters

;Send("{TAB 4}");to select the textbox
;Send("^v");paste it into the textbox
;Sleep(10000);wait for 10 seconds
;Local $sPicture = Send("{DOWN 2}")
;Sleep(2000)
;Local $mRangeRead = _Excel_RangeRead($oWorkbook, Default, "G2")
$oWorkBook.ActiveSheet.Range("G2").Select
; $filecopy = FileCopy($filename,$mRangeRead,$FC_OVERWRITE + $FC_CREATEPATH)
;_ClipPutFile($filecopy)

;_ArrayDisplay($aResults)
;~ Save to CSV
Local $hFileOpen = FileOpen(@ScriptDir & "\Results.csv", 2)
For $i = 0 To UBound($aResults) - 1
    FileWrite($hFileOpen, '"' & _
    StringStripWS($aResults[$i][0], 7) & '","' & _
    StringStripWS($aResults[$i][1], 7) & '","' & _
    StringStripWS($aResults[$i][2], 7) & '","' & _
    StringStripWS($aResults[$i][3], 7) & '","' & _
    StringStripWS($aResults[$i][4], 7) & '","' & _
    StringStripWS($aResults[$i][5], 7) & '"' & @CRLF)
Next
FileClose($hFileOpen)
 

 

This is my full code. please help me. Thanks @Subz

Share this post


Link to post
Share on other sites

#15 ·  Posted

Can you try the following code, just a few notes:

You can't save a csv with images, it has to be xls or xlsx.
The method I'm using to insert images is using Excel UDF, the use of send, clip functions are not recommended.

#include <Array.au3>
#include <IE.au3>
#include <String.au3>
#include<Excel.au3>
#include <MsgBoxConstants.au3>
#include <File.au3>
;Author: Kimberly Jill Pereira
#cs ########################################################################################################
    #  Script Function:                                                                                    #
    #  It is an Auto Login bot. It also extracts specific data from table and store it in Microsoft Excel. #
#ce ########################################################################################################

Local $sExcelPath = @ScriptDir
Local $sImagePath = "Y:\7_JlnBatu\IllegalParking\7_JlnBatu_cam2"

Local $oIE
Local $oDivs
Local $aPageCount, $iPageCount
Local $aTable, $oTables
Local $aTimeView[0][7]
Local $oUserName, $oPassWord
Local $sUserName = "Oneberry"
Local $sPassWord = "Qwer1234"
$oIE = _IECreate("http://www.timeview2.net/", 1); Opens IE browser
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE);Maximize Internet Explorer window
$oForms = _IETagNameGetCollection($oIE, "form")
For $oForm In $oForms
    If $oForm.id = "UserLoginForm" Then
        $oUserName = _IEFormElementGetObjByName($oForm, "data[User][username]")
        _IEFormElementSetValue($oUserName, $sUserName)
        $oPassWord = _IEFormElementGetObjByName($oForm, "data[User][password]")
        _IEFormElementSetValue($oPassWord, $sPassWord)
        _IEFormSubmit($oForm)
    EndIf
Next

_IENavigate($oIE, "http://www.timeview2.net/alarms")
$oDivs = _IETagNameGetCollection($oIE, "div")
For $oDiv In $oDivs
    If $oDiv.ClassName = "alarms index" Then
        $aPageCount = _StringBetween($oDiv.InnerText, "Page 1 of ", ", showing ")
        If @error Then Exit
        $iPageCount = Number($aPageCount[0])
    EndIf
Next

For $i = 1 To $iPageCount
    _IENavigate($oIE, "http://www.timeview2.net/alarms/index/group:All%20Groups/page:" & $i, 1)
    $oTables = _IETagNameGetCollection($oIE, "table")
    For $oTable In $oTables
        If $oTable.ClassName = "pageindex" Then
            $nTable = $oTable.NextElementSibling
            $aTable = _IETableWriteToArray($nTable, True)
            If UBound($aTable) - 1 > 0 And UBound($aTable, 2) = 7 Then
                If $i = 1 Then
                    _ArrayConcatenate($aTimeView, $aTable, 0)
                Else
                    _ArrayConcatenate($aTimeView, $aTable, 1)
                EndIf
                ExitLoop
            EndIf
        EndIf
    Next
 Next
 Local $oExcel = _Excel_Open(); Opens Microsoft Excel

Local $oWorkbook = _Excel_BookNew($oExcel); Create new Microsoft excel
WinSetState("[ACTIVE]", "", @SW_MAXIMIZE);Maximize Microsoft Excel window
_ArrayColDelete($aTimeView, 6)
 _Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, $aTimeView, "A1"); write the data to A1 cell of Microsoft excel
$oWorkbook.Activesheet.range("A1:G1").Font.Bold = True ; set font to bold
_Excel_RangeWrite($oWorkbook, $oWorkbook.Activesheet, "Pictures", "G1"); write 'Pictures' to G1 cell
$oWorkbook.Activesheet.range("E2:F100").NumberFormat = "yyyy/mm/dd" & " hh:mm:ss" & " AM/PM" ;set E2 to F100 cell to date format in yyyy/mm/dd
$oExcel.ActiveSheet.Columns("A:G").AutoFit
$oColumns = $oExcel.Columns("G")
$oColumns.ColumnWidth = 40.86
$oRows = $oExcel.Rows("2:100");Expands row 2 until 100
$oRows.RowHeight = 198.75;Automatically expands row

Local $sWorkbook = $sExcelPath & "\" & StringReplace(StringReplace($aTimeView[UBound($aTimeView) -1][4] & "-" & $aTimeView[1][4], ":", "-"), " ", "_") & "_TimeView.xlsx"
Local $oExcel = _Excel_BookSaveAs($oWorkbook, $sWorkbook)
$aWorkBook = _Excel_RangeRead($oWorkbook)
Local $aImagePath
For $i = 1 To UBound($aWorkBook) - 1
    $aImagePath = _FileListToArrayRec($sImagePath & "\" & StringFormat("%4i-%2i-%2i", StringLeft($aWorkBook[$i][5], 4), StringMid($aWorkBook[$i][5], 5, 2), StringMid($aWorkBook[$i][5], 7, 2)), "m" & StringTrimLeft($aWorkBook[$i][5], 2) & "*.jpg", 1, 1, 0, 2)
    ConsoleWrite($sImagePath & "\" & StringFormat("%4i-%02i-%02i", StringLeft($aWorkBook[$i][5], 4), StringMid($aWorkBook[$i][5], 5, 2), StringMid($aWorkBook[$i][5], 7, 2)) & @CRLF)
    If UBound($aImagePath) >= 2 Then
        _Excel_PictureAdd($oWorkbook, Default, $aImagePath[1], "G" & $i + 1)
        $aImageSize = _ImageSize($aImagePath[1])
        $oRow = $oExcel.Rows($i + 1)
        $oRow.RowHeight = $aImageSize[1]
    EndIf
Next

;~ Malkeys code: https://www.autoitscript.com/forum/topic/108578-getting-image-size/
Func _ImageSize($sFileName)
    Local $aRet[2], $sExt = StringRegExpReplace($sFileName, "^.*\.", "")
    If (FileExists($sFileName) = 0) Or _
            ((StringLen($sExt) = 3) And (StringRegExp($sExt, "(?i)(bmp|gif|jpg|png|tif|emf|wmf)") = 0)) Or _
            ((StringLen($sExt) = 4) And (StringRegExp($sExt, "(?i)(tiff|jpeg)") = 0)) Then _
            Return SetError(1, 0, $aRet)
    Local $ghGDIPDll = DllOpen("GDIPlus.dll")
    Local $tInput = DllStructCreate("int Version;ptr Callback;int NoThread;int NoCodecs")
    Local $tToken = DllStructCreate("ulong_ptr Data")
    DllStructSetData($tInput, "Version", 1)
    DllCall($ghGDIPDll, "int", "GdiplusStartup", "ptr", DllStructGetPtr($tToken), "ptr", DllStructGetPtr($tInput), "ptr", 0)
    Local $aImage = DllCall($ghGDIPDll, "int", "GdipLoadImageFromFile", "wstr", $sFileName, "ptr*", 0)
    Local $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageWidth", "handle", $aImage[2], "uint*", -1)
    $aRet[0] = $aResult[2]
    $aResult = DllCall($ghGDIPDll, "int", "GdipGetImageHeight", "handle", $aImage[2], "uint*", 0)
    $aRet[1] = $aResult[2]
    DllCall($ghGDIPDll, "int", "GdipDisposeImage", "handle", $aImage[2])
    DllCall($ghGDIPDll, "none", "GdiplusShutdown", "ptr", DllStructGetData($tToken, "Data"))
    DllClose($ghGDIPDll)
    Return SetError(0, 0, $aRet)
EndFunc ;==>_ImageSize

 

Share this post


Link to post
Share on other sites

#16 ·  Posted

I could display the picture but only for the first row. Now I have to display the pictures until the end. I am still figuring it out how to do.

Share this post


Link to post
Share on other sites

#17 ·  Posted

Local $sString = StringLeft($rRangeRead, 16); reads yyyymmddhhmmss
Local $oString = StringMid($sString, 3, 12); reads last two number of year e.g. yymmddhhmmss

Local $filename = "m" & $oString; puts string letter m together with yymmddhhmmss
Local $hfilename = $files & "\" & $filename &   "_GE_JB1_7_2_DYL.jpg"

I have a problem in selecting the filename because of the digits after the seconds for example like m170503123455434_GE_JB1_7_2_DYL. Because I dont know how to get those three numbers but the rest of it I can. Is there a way to get partially the filename and select the filename. Is there a way to do it?? Please help me and thank you very much.

Share this post


Link to post
Share on other sites

#18 ·  Posted

Is it use wildcard filename??? I really dont know how to do. Please help me. Thank you:).

Share this post


Link to post
Share on other sites

#19 ·  Posted

If you look at the code in the script:

$aImagePath = _FileListToArrayRec($sImagePath & "\" & StringFormat("%4i-%2i-%2i", StringLeft($aWorkBook[$i][5], 4), StringMid($aWorkBook[$i][5], 5, 2), StringMid($aWorkBook[$i][5], 7, 2)), "m" & StringTrimLeft($aWorkBook[$i][5], 2) & "*.jpg", 1, 1, 0, 2)
    ConsoleWrite($sImagePath & "\" & StringFormat("%4i-%02i-%02i", StringLeft($aWorkBook[$i][5], 4), StringMid($aWorkBook[$i][5], 5, 2), StringMid($aWorkBook[$i][5], 7, 2)) & @CRLF)

So for instance if Alarm Received = "20170503201956" the _FileListToArrayRec should resolve to:

$aImagePath = _FileListToArrayRec("Y:\7_JlnBatu\IllegalParking\7_JlnBatu_cam2\2017-05-03", "m170503201956*.jpg", 1, 1, 2)

So as you can see it's searching the folder "Y:\7_JlnBatu\IllegalParking\7_JlnBatu_cam2\2017-05-03" for any files with the name "m170503201956*.jpg" (note * is wild card).

What you should do is put an _ArrayDisplay below the line above to see if its finding the files.  I have tested this by renaming some .jpg files as m17... and they were all inserted into Excel fine.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Nareshm
      By Nareshm
      Hi All,
      I have excel file like this
      and i want to cut cell/text from excel to other software.

       
      I have to cut the cell of B column one by one and past into other software
      If Winexists("No Data Found")
      then restore cuted cell and goto next/down side cell
      How to do it ?
    • Mag91
      By Mag91
      Hey Community,
      cause im too new in the Auto it world i will try it with the your help. hopefully.
      I woud like to know how i can handle my Problem.
      ----
      I have a Excel Data with 362 random numbers.
      For Example:
      1166642335374 1172899897343
      .....
      this numbers are a part of the filepath ...example
      D:\Projekte\1166_64233_5374
      as u can see its the first number of the Excel data. After the first 4 numbers it shoud make a "_" than another 5 "_"
      This is my first question. How can i handle this to make it Shell execute.
       
      --------
      Second question:
      If i am in the path.
      For Example:
      D:\Projekte\1166_64233_5374
      the code shoud search for specific PDF Files.
      They are named like: 0050569E364B1ED79B900F73E62660EC.pdf
      the first 15 letters are always the same
      0050569E364B1ED
      when he found this data he has to copy it on a Folder on the Desktop.
      (There can also be 2 or 3 pdfs in one Folder with this letters)
      ----
      Please give me some help :-)
       
       
       
       
       
       
    • Mag91
      By Mag91
      Hey Everybody,
      as you know im on a very low autoit-level.
      My question is: How can i read all PDFs from a Folder wich is open and copy them to a Folder on a Desktop.
       
      The Folder wich contains the PDFs is variable Z:\Projektls\"*"*"*EVERYTIME ANOTHER ENDING"*"*"*"*"
      There can be 1 PDF or even 15 PDFs.
      i tried it with _FileListToArray and _FileCopy but i Need some help to understand this language
       
      THANKS!
       
    • tcurran
      By tcurran
      Here's a short UDF that will, at least in most cases, detect whether a window can be copied from or pasted to programmatically--for example, by Send()ing ctl-c, ctl-v. This is often disabled when programs (like your AutoIt script) run at a lower UAC integrity level than the application they are trying to operate on.
      #include <WinAPI.au3> Func _WindowIsPasteable($handle) ;accepts window handle; returns true or false whether a window will accept Ctl-C, Ctl-V Local $bCanPaste = True Local $hTestWindowPID = 0 Local $hTestWindowTID = _WinAPI_GetWindowThreadProcessId($handle, $hTestWindowPID) _WinAPI_AttachThreadInput(_WinAPI_GetCurrentThreadId(), $hTestWindowTID, True);attach to window we want to paste into $bCanPaste = _WinAPI_GetFocus() ;Test whether window is paste-able--returns False if it is not _WinAPI_AttachThreadInput(_WinAPI_GetCurrentThreadId, $hTestWindowTID, False);detach from window thread Return $bCanPaste EndFunc Pass it a window handle; it returns true or false whether a window will accept programmatic pasting. The function may not work on the CMD window, since it handles the clipboard uniquely.
      This function works by attaching to the program thread of the window whose handle it receives, then attempting to perform a GetFocus on that thread. In most cases, the attempt will fail if the window will not accept programmatic copy-paste.
    • FrancescoDiMuro
      By FrancescoDiMuro
      Good morning
      I was trying to replace 2 identical characters from a string, but I didn't manage to with StringReplace()...
      Does anyone know how to replace two ( i.e. : """" with ";" ) ? 
      Thanks