Hallo Alle,
ich habe mir ein Script geschrieben, welches auf YouTube alle Videos fü einen Author/Keywords sucht und in einem Listview anzeigt. Nach dem Laden der Daten kann man per Rechtsklick ein kontextmenü aufrufen.
Wenn ich dann ein Menüeintrag (Zu Download hinzufügen) auswählöe, passiert .... None ...
Kann da jemand mal schauen?
Achtung: Das Script benötigt im Verzeichnis @scriptdir folgende Verzeichnisstruktur: \bilder\test+\sounds
Spoiler anzeigen
#include <file.au3>
#include <array.au3>
#include <string.au3>
#Include <GuiListView.au3>
#include <GuiStatusBar.au3>
#Include <GuiListBox.au3>
#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Include <GuiEdit.au3>
#include <GuiImageList.au3>
#include <Constants.au3>
#include <GDIPlus.au3>
#include "_GUIImageList_AddBitmapEx.au3"
#Include <Misc.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <ListViewConstants.au3>
#include <StructureConstants.au3>
#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>
#include <GuiTab.au3>
#Region ### START Koda GUI section ### Form=
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]Local $aParts[3] = [250, 550, -1]
[/autoit] [autoit][/autoit] [autoit]$Form1 = GUICreate("Youtube Video Suche", 953, 547, 32, 124)
$hStatus = _GUICtrlStatusBar_Create ($Form1, $aParts)
$rc = ping("www.youtube.de")
If $rc = 0 Then
$lb_MsgText1 = GUICtrlCreateLabel("Keine aktive Internetverbindung vorhanden!", 40, 124, 540, 100)
GUICtrlSetFont(-1, 22, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
Else
$lV_Searchresults = GUICtrlCreateListView("", 40, 72, 601, 450, -1, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_SetExtendedListViewStyle($lV_Searchresults, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, _
$LVS_EX_DOUBLEBUFFER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000A0)
GUICtrlSetBkColor(-1, 0xBBCCEE)
$lb_Author = GUICtrlCreateLabel("Name/Nickname des Authors", 40, 24, 140, 17)
$ef_Author = GUICtrlCreateInput("matimar1", 40, 45, 140, 20)
$lb_Keyword = GUICtrlCreateLabel("Schlüsselwort", 185, 24, 140, 17)
$ef_Keyword = GUICtrlCreateInput("Feng shui music", 185, 45, 140, 20)
$btn = GUICtrlCreateButton("Suche starten", 330, 45, 90, 20)
[/autoit] [autoit][/autoit] [autoit]$lb_MsgText = GUICtrlCreateLabel("Hole Seite 1", 572, 24, 60, 17)
$hListBox = GUICtrlCreateList("", 658, 22, 40, 55)
$lV_Downloads = GUICtrlCreateListView("", 661, 72, 250, 450, -1, BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE, $LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_SetExtendedListViewStyle($lV_Downloads, BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, _
$LVS_EX_DOUBLEBUFFER))
GUICtrlSetFont(-1, 9, 400, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x0000A0)
GUICtrlSetBkColor(-1, 0xBBCCEE)
$CM_DownloadDummy = GUICtrlCreateDummy()
$ListView1context = GUICtrlCreateContextMenu($CM_DownloadDummy)
$MenuItem1 = GUICtrlCreateMenuItem("Zu Download-Liste hinzufügen", $ListView1context)
$CM_SortDummy = GUICtrlCreateDummy()
$ListView1context1 = GUICtrlCreateContextMenu($CM_SortDummy)
$ListView1context1Download = GUICtrlCreateMenuItem("Zu Download-Liste hinzufügen", $ListView1context1)
$ListView1context1Trenner = GUICtrlCreateMenuItem("", $ListView1context1)
$ListView1context1Sort = GUICtrlCreateMenu("Sortierung", $ListView1context1)
$MenuItem2 = GUICtrlCreateMenuItem("Aufsteigend", $ListView1context1Sort)
$MenuItem3 = GUICtrlCreateMenuItem("Absteigend", $ListView1context1Sort)
; Add columns
;_GUICtrlListView_AddColumn($lV_Searchresults, "", 25)
_GUICtrlListView_AddColumn($lV_Searchresults, "", 0)
_GUICtrlListView_AddColumn($lV_Searchresults, " Bild Nr Titel", 300)
_GUICtrlListView_AddColumn($lV_Searchresults, "Dauer", 50, 1)
_GUICtrlListView_AddColumn($lV_Searchresults, "Schlüsselwörter", 350)
_GUICtrlListView_AddColumn($lV_Searchresults, "YTID", 0)
_GUICtrlListView_AddColumn($lV_Downloads,"Nr", 30)
_GUICtrlListView_AddColumn($lV_Downloads,"Youtube Video ID", 150)
_GUICtrlListView_AddColumn($lV_Downloads,"Status", 150)
Global $B_DESCENDING[_GUICtrlListView_GetColumnCount($lV_Searchresults)]
; Create an image list with images
$hImage = _GUIImageList_Create(120, 90, 5, 1)
;- _GUIImageList_AddBitmap($hImage, @ScriptDir & "\bilder\test\default.bmp")
;- _GUICtrlListView_SetImageList($lV_Searchresults, $hImage, 1)
EndIf
GUICtrlSetState($lb_MsgText, $GUI_HIDE)
GUICtrlSetState($hListBox, $GUI_HIDE)
ControlSend($Form1, "", $ef_Author, "{END}")
ControlFocus($Form1, "", $ef_Author)
GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Dim $aRecords, $lV_Searchresults_values[50][7]
[/autoit] [autoit][/autoit] [autoit]While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
ExitLoop
case $MenuItem1
MsgBox(0, "", "Download aktiviert")
Case $btn
if ControlGetText($Form1, "", $ef_Author) = "" AND _
ControlGetText($Form1, "", $ef_Keyword) = "" then
MsgBox(64, "Youtube Video Suche - Fehler", "Suchkriterium fehlt: " & @CRLF & @CRLF & _
"Entweder Nickname oder 1 Schlüsselwort" & @CRLF & "muß vorhanden sein")
ControlFocus($Form1, "", $ef_Author)
ContinueCase
ElseIf ControlGetText($Form1, "", $ef_Author) <> "" AND _
ControlGetText($Form1, "", $ef_Keyword) <> "" then
$YTQuery = "http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=1&q=" & ControlGetText($Form1, "", $ef_Keyword)& "&author=" & ControlGetText($Form1, "", $ef_Author)
ElseIf ControlGetText($Form1, "", $ef_Author) <> "" Then
$YTQuery = "http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=1&author=" & ControlGetText($Form1, "", $ef_Author)
Else
$YTQuery = "http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=1&q=" & ControlGetText($Form1, "", $ef_Keyword)
endif
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $YTQuery = ' & $YTQuery & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
GUICtrlSetState($hListBox, BitOR($GUI_enable, $GUI_HIDE))
GUICtrlSetState($lb_MsgText, BitOR($GUI_enable, $GUI_HIDE))
GUICtrlSetState($btn, $GUI_disable)
ControlSetText($Form1, "", $btn, "Hole Daten ...")
; MsgBox(64, "Info", "Author: " & ControlGetText($Form1, "", $ef_Author))
;Sleep(5000)
fnc_GetYTData($YTQuery)
ControlSetText($Form1, "", $btn, "Suche")
GUICtrlSetState($btn, $GUI_enable)
GUICtrlSetState($hListBox, BitOR($GUI_enable, $GUI_SHOW))
GUICtrlSetState($lb_MsgText, BitOR($GUI_enable, $GUI_SHOW))
EndSwitch
WEnd
GUIDelete($Form1)
[/autoit] [autoit][/autoit] [autoit]Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg
Local $hWndFrom, $iIDFrom, $iCode, $hWndListBox
If Not IsHWnd($hListBox) Then $hWndListBox = GUICtrlGetHandle($hListBox)
; $hListView = $lV_Searchresults
If Not IsHWnd($lV_Searchresults) Then $hWndListView = GUICtrlGetHandle($lV_Searchresults)
$hWndFrom = $ilParam
$iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
$iCode = BitShift($iwParam, 16) ; Hi Word
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hWndFrom = ' & $hWnd & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
Switch $hWndFrom
Case $hListBox, $hWndListBox
Switch $iCode
Case $LBN_DBLCLK ; Sent when the user double-clicks a string in a list box
_DebugPrint("$LBN_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
$rc = _GUICtrlListBox_GetCount($hListBox)
;- _DebugPrint("Einträge: " & @TAB & $rc)
$aglbitems = _GUICtrlListBox_GetCurSel($hListBox)
;- _DebugPrint("Ausgewählt: " & @TAB & $aglbitems)
; Get indexes of selected items
$aItems = _GUICtrlListBox_GetText($hListBox, $aglbitems)
;- _DebugPrint("Items Selected: " & $aItems)
If $aItems = 1 then
$QueryStart = 1
else
$QueryStart = ($aItems - 1) * 50 + 1
EndIf
;- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $QueryStart = ' & $QueryStart & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$tmp = Stringreplace($YTQuery, "start-index=1", "start-index=" & $QueryStart)
;- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $tmp = ' & $tmp & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
fnc_GetYTData($tmp)
; no return value
Case $LBN_ERRSPACE ; Sent when a list box cannot allocate enough memory to meet a specific request
_DebugPrint("$LBN_ERRSPACE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
Case $LBN_KILLFOCUS ; Sent when a list box loses the keyboard focus
_DebugPrint("$LBN_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
Case $LBN_SELCANCEL ; Sent when the user cancels the selection in a list box
_DebugPrint("$LBN_SELCANCEL" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
Case $LBN_SELCHANGE ; Sent when the selection in a list box has changed
_DebugPrint("$LBN_SELCHANGE" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
Return _ListDblClick()
; no return value
Case $LBN_SETFOCUS ; Sent when a list box receives the keyboard focus
_DebugPrint("$LBN_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; no return value
EndSwitch
EndSwitch
[/autoit] [autoit][/autoit] [autoit]; Proceed the default Autoit3 internal message commands.
; You also can complete let the line out.
; !!! But only 'Return' (without any value) will not proceed
; the default Autoit3-message in the future !!!
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_COMMAND
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
#forceref $hWnd, $iMsg, $iwParam
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $lV_Searchresults
If Not IsHWnd($lV_Searchresults) Then $hWndListView = GUICtrlGetHandle($lV_Searchresults)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $LVN_COLUMNCLICK ; A column was clicked
$tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam)
_DebugPrint("$LVN_COLUMNCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Item:" & @TAB & DllStructGetData($tInfo, "Item") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->Param:" & @TAB & DllStructGetData($tInfo, "Param"))
; Kick off the sort callback
;_GUICtrlListView_SortItems($hWndFrom, DllStructGetData($tInfo, 2))
_GUICtrlListView_SimpleSort($hWndFrom, $B_DESCENDING, DllStructGetData($tInfo, "SubItem"))
; No return value
Case $LVN_KEYDOWN ; A key has been pressed
$tInfo = DllStructCreate($tagNMLVKEYDOWN, $ilParam)
_DebugPrint("$LVN_KEYDOWN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->VKey:" & @TAB & DllStructGetData($tInfo, "VKey") & @LF & _
"-->Flags:" & @TAB & DllStructGetData($tInfo, "Flags"))
; No return value
Case $NM_CLICK ; Sent by a list-view control when the user clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
;ListView_Click()
; No return value
Case $NM_DBLCLK ; Sent by a list-view control when the user double-clicks an item with the left mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_KILLFOCUS ; The control has lost the input focus
_DebugPrint("$NM_KILLFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
Case $NM_RCLICK ; Sent by a list-view control when the user clicks an item with the right mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
;Return 1 ; not to allow the default processing
;Return 0 ; allow the default processing
if _GUICtrlListView_GetItemCount($hWndFrom) = 0 then return 0
$ContextmenuCalledColumn = DllStructGetData($tInfo, "SubItem")
$arPos = MouseGetPos()
$x = $arPos[0]
$y = $arPos[1]
if $ContextmenuCalledColumn <> 2 then
$hMenu = GUICtrlGetHandle($ListView1context)
Else
$hMenu = -1
endif
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hMenu = ' & $hMenu & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hWndFrom = ' & $hWndFrom & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
; ClientToScreen($hWndFrom, $x, $y) --- funktioniert nicht!!!
TrackPopupMenu($hWndFrom, $hMenu, $x, $y)
Return 0 ; allow the default processing
[/autoit] [autoit][/autoit] [autoit]Case $NM_RDBLCLK ; Sent by a list-view control when the user double-clicks an item with the right mouse button
$tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
_DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode & @LF & _
"-->Index:" & @TAB & DllStructGetData($tInfo, "Index") & @LF & _
"-->SubItem:" & @TAB & DllStructGetData($tInfo, "SubItem") & @LF & _
"-->NewState:" & @TAB & DllStructGetData($tInfo, "NewState") & @LF & _
"-->OldState:" & @TAB & DllStructGetData($tInfo, "OldState") & @LF & _
"-->Changed:" & @TAB & DllStructGetData($tInfo, "Changed") & @LF & _
"-->ActionX:" & @TAB & DllStructGetData($tInfo, "ActionX") & @LF & _
"-->ActionY:" & @TAB & DllStructGetData($tInfo, "ActionY") & @LF & _
"-->lParam:" & @TAB & DllStructGetData($tInfo, "lParam") & @LF & _
"-->KeyFlags:" & @TAB & DllStructGetData($tInfo, "KeyFlags"))
; No return value
Case $NM_RETURN ; The control has the input focus and that the user has pressed the ENTER key
_DebugPrint("$NM_RETURN" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
Case $NM_SETFOCUS ; The control has received the input focus
_DebugPrint("$NM_SETFOCUS" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _
"-->IDFrom:" & @TAB & $iIDFrom & @LF & _
"-->Code:" & @TAB & $iCode)
; No return value
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
Func _DebugPrint($s_text)
$s_text = StringReplace($s_text, @LF, @LF & "-->")
ConsoleWrite("!===========================================================" & @LF & _
"+===========================================================" & @LF & _
"-->" & $s_text & @LF & _
"+===========================================================" & @LF)
EndFunc ;==>_DebugPrint
; shows actual page of all reports in listbox
Func _ListDblClick()
Local $indx = _GUICtrlListBox_GetCurSel($hListBox)
ControlSetText($Form1, "", $lb_MsgText, "Hole Seite " & _GUICtrlListBox_GetText($hListBox, $indx))
EndFunc
Func fnc_GetYTData($SearchArg)
[/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]$rc = FileDelete(@ScriptDir & "\update.dat")
_GUICtrlStatusBar_SetText ($hStatus, "Hole Kataloginformationen", 1)
; Local $hDownload = InetGet("http://gdata.youtube.com/feeds/api/users/7600celsius/uploads?max-results=50&start-index=1&lr=de", @ScriptDir & "\update.dat", 1, 1)
; Local $hDownload = InetGet("http://gdata.youtube.com/feeds/api/videos?max-results=50&start-index=1&q=relax&author=7600CELSIUS", @ScriptDir & "\update.dat", 1, 1)
Local $hDownload = InetGet($SearchArg, @ScriptDir & "\update.dat", 1, 1)
Do
Sleep(250)
Until InetGetInfo($hDownload, 2) ; Check if the download is complete.
Local $nBytes = InetGetInfo($hDownload, 0)
InetClose($hDownload) ; Close the handle to release resourcs.
;MsgBox(0, "", "Bytes read: " & $nBytes)
_GUICtrlStatusBar_SetText ($hStatus, "Lese Katalog ein", 1)
[/autoit] [autoit][/autoit] [autoit]$rcfo = FileOpen(@ScriptDir & "\update.dat")
$fileline = FileReadLine($rcfo, 1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $fileline = ' & $fileline & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$newchars = StringReplace($fileline, "><", ">|<")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $chars = ' & $newchars & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$rc = FileClose($rcfo)
_GUICtrlStatusBar_SetText ($hStatus, "Analysiere Katalog", 1)
$KatInfoStart = StringinStr($newchars,"|<openSearch:totalResults>") + 1
$KatInfoEnd = StringinStr($newchars,"</openSearch:itemsPerPage>") - 1
$KatInfo = StringMid($newchars, $KatInfoStart, ($KatInfoEnd-$KatInfoStart)+27)
$QueryInfo = _Stringbetween($KatInfo, ">", "<")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $QueryInfo = ' & UBound($QueryInfo) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;_ArrayDisplay($QueryInfo,"QueryInfo",10)
$AnzVideos = Int($QueryInfo[0])
if $AnzVideos <= 50 then
$AnzSeiten = 1
else
$AnzSeiten = Int($QueryInfo[0] / 50)
if $AnzSeiten < 1 then $AnzSeiten = 1
$tmp = $QueryInfo[0] - (Int($QueryInfo[0] / 50) * 50)
if $tmp > 0 then $AnzSeiten = $AnzSeiten + 1
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $tmp = ' & $tmp & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
EndIf
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $AnzSeiten = ' & $AnzSeiten & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$AktSeite = int($QueryInfo[2]) / 50
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $QueryInfo[2] int($QueryInfo[2]) / 50 = ' & $QueryInfo[2] & ", " & int($QueryInfo[2]) / 50 & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
if $AktSeite < 1 then
$AktSeite = 1
Else
$AktSeite = int($AktSeite + 1)
EndIf
_GUICtrlStatusBar_SetText ($hStatus, "Anzahl Seiten: " & $AnzSeiten & ", Aktuelle Seite: " & $AktSeite, 0)
_GUICtrlStatusBar_SetText ($hStatus, "Anzahl Videos: " & $AnzVideos, 2)
; return
$aRecords = StringSplit($newchars, "|")
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $aRecords = ' & UBound($aRecords) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
; _ArrayDisplay($aRecords, "Results of searching for 0 in $avArray")
$chars = ""
$newchars = ""
_GUICtrlListView_BeginUpdate(GUICtrlGetHandle($lV_Searchresults))
_GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lV_Searchresults))
_GUICtrlListView_EndUpdate(GUICtrlGetHandle($lV_Searchresults))
Local $astartiResult = _ArrayFindAll($aRecords, "<entry", 0, 0, 0, 1)
[/autoit] [autoit][/autoit] [autoit]; _ArrayDisplay($astartiResult, "Results of searching for 0 in $avArray")
[/autoit] [autoit][/autoit] [autoit]Local $aendiResult = _ArrayFindAll($aRecords, "</entry", 0, 0, 0, 1)
if UBound($astartiResult) = 0 and UBound($aendiResult) = 0 then
_GUICtrlStatusBar_SetText($hStatus, "Keine Daten gefunden", 1)
return
endif
; _ArrayDisplay($aendiResult, "Results of searching for 0 in $avArray")
if UBound($astartiResult) > UBound($aendiResult) then Exit
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : UBound($aendiResult) = ' & UBound($aendiResult) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : UBound($astartiResult) = ' & UBound($astartiResult) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
for $lv = 0 to UBound($astartiResult) - 1
_GUICtrlStatusBar_SetText ($hStatus, "Analysiere Link " & $lv & " von 50", 1)
;ConsoleWrite('@@ Debug ' & $lv &' =========================================================' & @CRLF)
for $mediagroup = $astartiResult[$lv] + 1 to $aendiResult[$lv] - 1
; ConsoleWrite('@@ Debug ' & $aRecords[$mediagroup] & @CRLF)
if StringInStr($aRecords[$mediagroup],"<media:keywords>") > 0 Then
$dataArea = StringStripWS($aRecords[$mediagroup], 1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$dataArea = _StringBetween($dataArea,">","<")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;$tempvalue = _Stringbetween($aRecords[$mediagroup], ">", "<", -1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') $lv : $tempvalue = ' & $lv & "-" & $tempvalue & "-" & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$lV_Searchresults_values[$lv][0] = $dataArea[0]
EndIf
[/autoit] [autoit][/autoit] [autoit]if StringInStr($aRecords[$mediagroup],"<id>") > 0 Then
$dataArea = StringStripWS($aRecords[$mediagroup], 1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$dataArea = _StringBetween($dataArea,">","<")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;$tempvalue = _Stringbetween($aRecords[$mediagroup], ">", "<", -1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') $lv : $tempvalue = ' & $lv & "-" & $tempvalue & "-" & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$lV_Searchresults_values[$lv][1] = StringReplace($dataArea[0], "http://gdata.youtube.com/feeds/api/videos/", "")
EndIf
[/autoit] [autoit][/autoit] [autoit]if StringInStr($aRecords[$mediagroup],"<media:title") > 0 Then
$dataArea = StringStripWS($aRecords[$mediagroup], 1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$dataArea = _StringBetween($dataArea,">","<")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;$tempvalue = _Stringbetween($aRecords[$mediagroup], ">", "<", -1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') $lv : $tempvalue = ' & $lv & "-" & $tempvalue & "-" & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$lV_Searchresults_values[$lv][2] = $dataArea[0]
EndIf
[/autoit] [autoit][/autoit] [autoit]if StringInStr($aRecords[$mediagroup],"<published>") > 0 Then
$dataArea = StringStripWS($aRecords[$mediagroup], 1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$dataArea = _StringBetween($dataArea,">","<")
$dataArea = _StringBetween($dataArea[0], "", "T")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$dataArea = StringSplit($dataArea[0], "-")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & UBound($dataArea) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;$tempvalue = _Stringbetween($aRecords[$mediagroup], ">", "<", -1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') $lv : $tempvalue = ' & $lv & "-" & $tempvalue & "-" & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$lV_Searchresults_values[$lv][3] = $dataArea[3] & "." & $dataArea[2] & "." & $dataArea[1]
EndIf
[/autoit] [autoit][/autoit] [autoit]if StringInStr($aRecords[$mediagroup],"<yt:duration") > 0 Then
$dataArea = StringStripWS($aRecords[$mediagroup], 1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$dataArea = _StringBetween($dataArea,"'","'")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea = ' & $dataArea[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;$tempvalue = _Stringbetween($aRecords[$mediagroup], ">", "<", -1)
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') $lv : $tempvalue = ' & $lv & "-" & $tempvalue & "-" & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$tempMinuten = Int($dataArea[0] / 60)
$lV_Searchresults_values[$lv][4] = Int($dataArea[0] / 60) & ":" & StringFormat("%02d",$dataArea[0] - ($tempMinuten * 60))
$lV_Searchresults_values[$lv][5] = $dataArea[0]
;-- ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $dataArea[0] = ' & $dataArea[0] & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
$lV_Searchresults_values[$lv][6] = $dataArea[0] * 192 * 1000 ;/ (1024 * 1024 * ![]()
EndIf
[/autoit] [autoit][/autoit] [autoit]Next
[/autoit] [autoit][/autoit] [autoit]FileDelete(@ScriptDir & "\bilder\test\" & $lV_Searchresults_values[$lv][1] & ".jpg") ;avoid irvanview exiting if already exists
[/autoit] [autoit][/autoit] [autoit]$BildDownloadLink = "http://i.ytimg.com/vi/" & $lV_Searchresults_values[$lv][1] & "/default.jpg"
;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $BildDownloadLink = ' & $BildDownloadLink & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
_GUICtrlStatusBar_SetText ($hStatus, "Lade Bild für " & $lV_Searchresults_values[$lv][1], 1)
Local $hBildDownload = InetGet($BildDownloadLink, @ScriptDir & "\bilder\test\" & $lV_Searchresults_values[$lv][1] & ".jpg", 1, 1)
Do
Sleep(250)
Local $nBytes = InetGetInfo($hBildDownload, 0)
_GUICtrlStatusBar_SetText ($hStatus, "Lade Bild für " & $lV_Searchresults_values[$lv][1] & ", Bytes geladen: " & $nBytes, 1)
Until InetGetInfo($hBildDownload, 2) ; Check if the download is complete.
InetClose($hBildDownload)
_GUICtrlStatusBar_SetText ($hStatus, "Konvertiere " & $lV_Searchresults_values[$lv][1] & ".jpg --> bmp", 1)
$sCmd = "C:\Programme\IrfanView\i_view32 " & $lV_Searchresults_values[$lv][1] & ".jpg /convert " & $lV_Searchresults_values[$lv][1] & ".bmp"
$iPid = Run($sCmd, @ScriptDir & "\bilder\test", @SW_HIDE, 0x4) ;StdErr
While ProcessExists($iPid)
$sStdOut = StderrRead($iPid)
WEnd
$NrNeuesBild = _GUIImageList_AddBitmap($hImage, @ScriptDir & "\bilder\test\" & $lV_Searchresults_values[$lv][1] & ".bmp")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $NrNeuesBild = ' & $NrNeuesBild & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
_GUICtrlListView_SetImageList($lV_Searchresults, $hImage, 1)
$NewItem = _GUICtrlListView_AddItem($lV_Searchresults, $lv+1, -1)
_GUICtrlListView_AddSubItem($lV_Searchresults, $NewItem, StringFormat("%4s", $lv+1) & ". " & $lV_Searchresults_values[$lv][2], 1, $NrNeuesBild)
_GUICtrlListView_AddSubItem($lV_Searchresults, $NewItem, $lV_Searchresults_values[$lv][4], 2, -1)
_GUICtrlListView_AddSubItem($lV_Searchresults, $NewItem, $lV_Searchresults_values[$lv][0], 3, -1)
_GUICtrlListView_AddSubItem($lV_Searchresults, $NewItem, $lV_Searchresults_values[$lv][1], 4, -1)
; _SetItemParam($lV_Searchresults, $NewItem, 3, -1, 0xFF0000)
Next
; _ArrayDisplay($lV_Searchresults_values, "Results of searching for 0 in $avArray")
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $lV_Searchresults_values) = ' & UBound($lV_Searchresults_values) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
_GUICtrlListBox_ResetContent($hListBox)
[/autoit] [autoit][/autoit] [autoit]ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $AnzSeiten = ' & $AnzSeiten & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
[/autoit] [autoit][/autoit] [autoit]for $i = 1 to $AnzSeiten
_GUICtrlListBox_AddString(GUICtrlGetHandle($hListBox), StringFormat("%2s", $i))
Next
_GUICtrlStatusBar_SetText ($hStatus, "Fertig", 1)
_GUICtrlListBox_SetCurSel(GUICtrlGetHandle($hListBox), $AktSeite - 1)
GUICtrlSetState($lb_MsgText, $GUI_SHOW)
GUICtrlsetState(GUICtrlGetHandle($hListBox), $GUI_SHOW)
ControlFocus($Form1, "", GUICtrlGetHandle($hListBox))
; ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : GUICtrlgetState($hListBox, $GUI_SHOW) = ' & GUICtrlgetState($hListBox) & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
SoundPlay(@ScriptDir & "\Sounds\transfer_data.mp3")
Sleep(600)
EndFunc
; Convert the client (GUI) coordinates to screen (desktop) coordinates
Func ClientToScreen($hWnd, ByRef $x, ByRef $y)
Local $stPoint = DllStructCreate("int;int")
DllStructSetData($stPoint, 1, $x)
DllStructSetData($stPoint, 2, $y)
DllCall("user32.dll", "int", "ClientToScreen", "hwnd", $hWnd, "ptr", DllStructGetPtr($stPoint))
[/autoit] [autoit][/autoit] [autoit]$x = DllStructGetData($stPoint, 1)
$y = DllStructGetData($stPoint, 2)
; release Struct not really needed as it is a local
$stPoint = 0
EndFunc ;==>ClientToScreen
; Show at the given coordinates (x, y) the popup menu (hMenu) which belongs to a given GUI window (hWnd)
Func TrackPopupMenu($hWnd, $hMenu, $x, $y)
;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $hWnd = ' & $hWnd & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
;ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : TrackPopupMenu = ' & @crlf & '>Error code: ' & @error & @crlf) ;### Debug Console
DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", $x, "int", $y, "hwnd", $hWnd, "ptr", 0)
EndFunc ;==>ZeigeContextMenu
Vielen Dank! LG fschaef