Spoiler anzeigen
#Region Includes
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <GDIPlus.au3>
#include <String.au3>
#EndRegion Includes
#Region Global variables
;CONSTANTS FOR WINANIMATE
Global Const $AW_FADE_IN = 0x00080000;fade-in
Global Const $AW_FADE_OUT = 0x00090000;fade-out
Global Const $AW_SLIDE_IN_LEFT = 0x00040001;slide in from left
Global Const $AW_SLIDE_OUT_LEFT = 0x00050002;slide out to left
Global Const $AW_SLIDE_IN_RIGHT = 0x00040002;slide in from right
Global Const $AW_SLIDE_OUT_RIGHT = 0x00050001;slide out to right
Global Const $AW_SLIDE_IN_TOP = 0x00040004;slide-in from top
Global Const $AW_SLIDE_OUT_TOP = 0x00050008;slide-out to top
Global Const $AW_SLIDE_IN_BOTTOM = 0x00040008;slide-in from bottom
Global Const $AW_SLIDE_OUT_BOTTOM = 0x00050004;slide-out to bottom
Global Const $AW_DIAG_SLIDE_IN_TOPLEFT = 0x00040005;diag slide-in from Top-left
Global Const $AW_DIAG_SLIDE_OUT_TOPLEFT = 0x0005000a;diag slide-out to Top-left
Global Const $AW_DIAG_SLIDE_IN_TOPRIGHT = 0x00040006;diag slide-in from Top-Right
Global Const $AW_DIAG_SLIDE_OUT_TOPRIGHT = 0x00050009;diag slide-out to Top-Right
Global Const $AW_DIAG_SLIDE_IN_BOTTOMLEFT = 0x00040009;diag slide-in from Bottom-left
Global Const $AW_DIAG_SLIDE_OUT_BOTTOMLEFT = 0x00050006;diag slide-out to Bottom-left
Global Const $AW_DIAG_SLIDE_IN_BOTTOMRIGHT = 0x0004000a;diag slide-in from Bottom-right
Global Const $AW_DIAG_SLIDE_OUT_BOTTOMRIGHT = 0x00050005;diag slide-out to Bottom-right
Global Const $AW_EXPLODE = 0x00040010;explode
Global Const $AW_IMPLODE = 0x00050010;implode
Global $USERNAME="L3viathan2142", $PASSWORD="geheim",$curl="curl\curl.exe",$LASTID=0
Opt("GUIOnEventMode",1)
#EndRegion Global variables
_GDIPlus_Startup()
_CreateNotifyGUI()
AdlibEnable("_TWLookForNewTweets",30000)
_TWLookForNewTweets()
;~ _TWupdateStatus("Test mit AutoIt-API-Anbindung")
$stamp=TimerInit()
While True
If Timerdiff($stamp) > 5000 Then _Tweet("RETWEET")
Sleep(100)
WEnd
#Region Functions
Func _TWLookForNewTweets()
$current=_TWgetLastStatus()
If $current[2] <> $LASTID Then _notify($current[0],$current[1],"twitterers\" & $current[0] & ".jpg")
$LASTID=$current[2]
EndFunc
Func _CreateNotifyGUI()
Global $hNotifyGUI=GUICreate("@@TWITIFY@@",300,100,@DesktopWidth-300,@DesktopHeight-140,$WS_POPUP,$WS_EX_TOOLWINDOW)
GUISetBkColor(0x89E0FE)
Global $UserPic=GUICtrlCreatePic("test.jpg",5,5,50,50)
GUICtrlSetOnEvent(-1,"_Tweetctrl")
Global $ServicePic=GUICtrlCreatePic("service.jpg",5,60,50,30)
GUICtrlSetOnEvent(-1,"_Tweetctrl")
GUICtrlSetResizing(-1,802)
Global $HeadLabel=GUICtrlCreateLabel("This is the headline",60,5,300-60-5,30)
GUICtrlSetOnEvent(-1,"_Tweetctrl")
GUICtrlSetFont(-1,11,600)
$text="Ein sehr langer Text, der mindestens 140 Zeichen hat, eher mehr. deshalb wird das hier nicht so gerne gesehen das ich ein Blindtext bin, denn ich habe keine Funktion, außer dem Programmierer zu sagen, wieviel Text hier rein passt..."
Global $TextLabel=GUICtrlCreateLabel($text,60,25,300-60-5,40)
GUICtrlSetOnEvent(-1,"_Tweetctrl")
Global $TweetInput=GUICtrlCreateInput("",5,100,250,40,$ES_MULTILINE)
GUICtrlSetLimit(-1,140)
GUICtrlSetResizing(-1,802)
EndFunc
Func _ImageConvert($oldname,$newname)
$image=_GDIPlus_ImageLoadFromFile($oldname)
_GDIPlus_ImageSaveToFile($image,$newname)
FileDelete($oldname)
EndFunc
;TWUpdateStatus removed
Func _TWgetLastStatus()
#cs
$pid=Run(@ComSpec & " /k " & @ScriptDir & "\" & $curl & " -u " & $USERNAME & ":" & $PASSWORD & ' http://twitter.com/statuses/friends_timeline.xml',@ScriptDir,@SW_HIDE,0x2)
Local $line=""
Sleep(2000)
Do
$line &= StdoutRead($pid)
Until $line <> ""
;~ ClipPut($line)
Return _FilterResult($line)
#ce
Return _FilterResult("<id>92</id><screenname>Bla</screenname><text>TestText</text><profile_image_url>https://autoit.de/icon/postEditL.png</profile_image_url>")
EndFunc
Func _FBupdateStatus()
EndFunc
Func _tweetctrl()
Traytip("","Click",20)
Switch @GUI_CtrlId
Case $ServicePic
_Tweet("NEW")
Case $UserPic, $HeadLabel
_Tweet("REPLY")
Case $TextLabel
_Tweet("RETWEET")
EndSwitch
EndFunc
Func _Tweet($how="")
Local $tweet=""
Switch $how
Case "NEW"
$tweet=""
Case "REPLY"
$tweet="@" & GUICtrlRead($HeadLabel) & " "
Case "RETWEET"
$tweet="RT @" & GUICtrlRead($HeadLabel) & " " & GUICtrlRead($TextLabel)
EndSwitch
WinMove("@@TWITIFY@@","",@DesktopWidth-300,@DesktopHeight-190,300,150)
;~ WinMove("@@TWITIFY@@","",0,0,300,150,20)
EndFunc
Func _notify($head,$text,$pic)
AdlibDisable()
GUICtrlSetData($HeadLabel,$head)
GUICtrlSetData($TextLabel,_URLDecode($text))
GUICtrlSetImage($UserPic,$pic)
_WinAnimate($hNotifyGUI,$AW_SLIDE_IN_BOTTOM,500)
$timestamp=TimerInit();Warten...
;~ _WinAnimate($hNotifyGUI,$AW_SLIDE_OUT_BOTTOM,500)
AdlibEnable("_TWLookForNewTweets",30000)
EndFunc
Func _WinAnimate($v_gui, $i_mode, $i_duration = 1000)
If @OSVersion = "WIN_XP" OR @OSVersion = "WIN_2000" Then
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", WinGetHandle($v_gui), "int", $i_duration, "long", $i_mode)
Local $ai_gle = DllCall('kernel32.dll', 'int', 'GetLastError')
If $ai_gle[0] <> 0 Then
SetError(1)
Return 0
EndIf
Return 1
EndIf
EndFunc;==> _WinAnimate()
Func _FilterResult($line)
Dim $return[3]
$temp=_StringBetween($line,"<screen_name>","</screen_name>")
$return[0]=$temp[0];Screenname
$temp=_StringBetween($line,"<text>","</text>")
$return[1]=$temp[0];Text
$temp=_StringBetween($line,"<id>","</id>")
$return[2]=$temp[0];Text
$temp=_StringBetween($line,"<profile_image_url>","</profile_image_url>")
If Not FileExists("twitterers/" & $return[0] & ".jpg") Then
InetGet($temp[0],"tempPIC")
_ImageConvert("tempPIC","twitterers/" & $return[0] & ".jpg")
EndIf
Return $return
EndFunc
Func _URLDecode($TEXT)
$TEXT=StringReplace($TEXT,"ä","ä")
$TEXT=StringReplace($TEXT,"ü","ü")
$TEXT=StringReplace($TEXT,"Ä","Ä")
$TEXT=StringReplace($TEXT,"Ö","Ö")
$TEXT=StringReplace($TEXT,"Ü","Ü")
$TEXT=StringReplace($TEXT,"ö","ö")
$TEXT=StringReplace($TEXT,"ß","ß")
Return $TEXT
EndFunc
#EndRegion Functions
#Region Documentary
#comments-start
Dokumentation aller Funktionen:
Name: _TWupdateStatus($newStatus)
Desc: updates the twitter status via cURL
Parameters: $newStatus - new Twitter status as String, should have a maximum of 140 characters
Return value: 0 - Sucess
<> 0 - Error while trying to run cURL, is cURL installed in the right directory?
Error value: 1 - too many characters
Name: _TWgetLastStatus()
Desc: gets the last update of your twitters following timeline
Name: _FBgetLastStatus()
Desc: gets the last update of your Facebooks following timeline
Name: _FBupdateStatus($newStatus)
Desc: updates the facebook status via cURL
#comments-end
#EndRegion Documentary
Um das ganze zu benutzen, braucht ihr cURL, im Unterordner. Das Skript ist noch seeehr unübersichtlich... das wird später alles besser geordnet, und die Verpackung in geschätzte tausend Funktionen hat auch ihren Sinn.
Dieses Skript ist noch KEIN Release!! Dieser Thread ist nur für Fragen von mir bezüglich einiger Themen...
Momentan habe ich vorallem ein Problem: Nachdem das Skript mir den aktuellen Tweet anzeigt, möchte ich auf unterschiedliche Steuerelemente klicken können, und dadurch einen neuen Tweet auslösen können, optional als Retweet oder Reply.
Mein Problem: Obwohl ich meiner meinung nach korrekt den Ctrls ihre Events zugeordnet habe, passiert beim Klicken auf ein solches Ctrl nichts...
EDIT: Jetzt verbeispielt und damit ohne cURL nutzbar.