frank10 Posted November 27, 2012 Share Posted November 27, 2012 Didn't work. It remains always the first webcam. Maybe I must do a autoit script to control the skype client and make the manual change of webcam. It's a pity it can't be done from skype4com. Link to comment Share on other sites More sharing options...
FireFox Posted November 28, 2012 Author Share Posted November 28, 2012 @frank10 Are you trying to make a video surveillance ? if so it's a good idea Link to comment Share on other sites More sharing options...
frank10 Posted November 28, 2012 Share Posted November 28, 2012 Yes I do. I was thinking of sending webcam video through the net, maybe on a server to see them in a web page or creating an app on android, then I thought of skype and that's simpler. Now I would like to record the camera sent to phone with skype. Any ideas? Link to comment Share on other sites More sharing options...
TJWho Posted November 29, 2012 Share Posted November 29, 2012 I'v been tinkering around with the Skype UDF and got a script that auto replies to chat when a user enters a special command. Example: >> !time . I feel it could help other people with the, "Skype_OnEvent" functions. This was pieced together and taken from an old example. Amazing work btw, FireFox for making this udf. Was also wondering if there was a better way to respond to a chat directly from a message. Right now i'm using, "$oMsg.Chat.SendMessage". Thanks! Example code below: expandcollapse popup;Made by TJWho... ; ;You or a friend can message you with the following commands ; ;!help ;!time ;!slap [Person] ;!8ball [question] ;all the dice commands do the same thing ;!roll ;!DICE 20 ;!RANDOM 1-100 ;!RAND 3d3 ;#include <Skype.au3> ;Depending on where your skype.au3 is at. #include "Skype.au3" _Skype_Start() ;in case not running #Region Variables Global $oChat, $blChat = False Global $oCall, $blCall = False, $blCallHold = False Global $sCurrUserHandle = _Skype_ProfileGetHandle() Global $sDealUserHandle #EndRegion Variables #Region Skype_OnEvent _Skype_OnEventAttachmentStatus("_AttachmentStatus") _Skype_OnEventMessageStatus("_ChatMessage", $cCmsSent) _Skype_OnEventMessageStatus("_ChatMessage", $cCmsReceived) _Skype_OnEventError("_Error") #EndRegion Skype_OnEvent ;Taken from a 8ball.ini file #region 8ball.ini local $a8ball[29] $a8ball[0] = "Maybe..." $a8ball[1] = "As I see It, Yes" $a8ball[2] = "It is certain" $a8ball[3] = "It is decidedly so" $a8ball[4] = "Most likely" $a8ball[5] = "Outlook good" $a8ball[6] = "Signs point to Yes" $a8ball[7] = "Without a doubt" $a8ball[8] = "YES" $a8ball[9] = "Yes, definitely" $a8ball[10] = "You may rely on it" $a8ball[11] = "Ask again later" $a8ball[12] = "Better not tell you now" $a8ball[13] = "Cannot predict now" $a8ball[14] = "Concentrate and ask again" $a8ball[15] = "Don't count on it" $a8ball[16] = "My reply is No" $a8ball[17] = "My sources say No" $a8ball[18] = "Outlook not so good" $a8ball[19] = "Reply Hazy, Try again" $a8ball[20] = "Very doubtful" $a8ball[21] = "Not only no, but HELL No!" $a8ball[22] = "Not only yes, but HELL Yes!" $a8ball[23] = "You will regret it!" $a8ball[24] = "Signs point to No" $a8ball[25] = "Go away... I don't want you back!" $a8ball[26] = "Well I love you, come back!" $a8ball[27] = "What? Are you taking me as an 8 ball?" $a8ball[28] = "Outlook is disturbing" #endregion 8ball.ini ;// Sleep While 1 Sleep(1) WEnd ;// Where the event gets called too Func _ChatMessage($oMsg) DecodeMsg($oMsg) If $oSkype.Convert.ChatMessageTypeToText($oMsg.Type) = "unknown" Then AutoChat($oMsg) EndIf if $oSkype.Convert.ChatMessageTypeToText($oMsg.Type) = 'Said' then AutoChat($oMsg) EndIf EndFunc ;==>_ChatMessage ;// The DecodeMsg event handler decodes messages in a chat and converts leave reasons to text for messages of type "Left": Func DecodeMsg($oMsg) $sText = $oMsg.FromHandle & " " & $oSkype.Convert.ChatMessageTypeToText($oMsg.Type) & ":" If StringLen($oMsg.Body) Then $sText = $sText & " " & $oMsg.Body EndIf Dim $oUser For $oUser In $oMsg.Users $sText = $sText & " " & $oUser.Handle Next #cs If $oMsg.Type = $cMessageType_Left Then $sText = $sText & " " & $oSkype.Convert.ChatLeaveReasonToText($oMsg.LeaveReason) EndIf #ce ConsoleWrite($sText & @LF) EndFunc Func _AttachmentStatus($TAttachmentStatus) ;the Skype UDF will automatically attach to skype when this one will be available EndFunc ;// $oMsg.Chat.SendMessage responds with a message Func AutoChat($oMsg) local $sTemp = StringSplit($oMsg.Body," ") switch $sTemp[1] case '!time' $time = _DateDayOfWeek(@WDAY)&" "&_DateToMonth(@MON)&" "&@MDAY&" "&@YEAR&" -- "&@HOUR&":"&@MIN&":"&@SEC $oMsg.Chat.SendMessage('/me >>'&$time) ;Tuesday November 27 2012 -- 21:49:50 -05:00 case '!help' $oMsg.Chat.SendMessage('/me >>'&help_list()) case '!roll','!DICE','!RANDOM','!RAND' $oMsg.Chat.SendMessage('/me >>'&DICE($oMsg.body)) EndSwitch if $sTemp[0] = 1 then return 0 Switch $sTemp[1] case '!slap' $oMsg.Chat.SendMessage('/me >>'&$oMsg.FromHandle & ' slaps '&$sTemp[2]&' around a bit with a large trout') case '!8ball' $i = Random (0, UBound($a8ball) -1) $oMsg.Chat.SendMessage('/me >>'&$a8ball[$i]) EndSwitch EndFunc Func DICE($d='') ;ConsoleWrite("BEFORE: "&$d & @LF) local $regname = '(?x)(?i)!((roll)|(DICE)|(RANDOM)|(RAND))' $d = StringRegExpReplace($d,$regname,"") ;ConsoleWrite("AFTER: "&$d & @LF) if $d = '' then return Random(1,100,1) local $tempd,$templ local $Wrong = 'Invalid Syntax!' $regexp = "(?x)(?i)(([1-9]d[1-9])|([0-9]{0,4}-[0-9]{0,4})|([0-9]{0,4}))" if Not StringRegExp($d,$regexp) Then return $Wrong $tempd = StringSplit($d,"d") if $tempd[0] = 1 Then $templ = StringSplit($d,"-") if $templ[0] = 1 Then return Random(1,int($d),1) return Random($templ[1],$templ[2],1) Else local $n = int($tempd[1]) if $n > 1000 then Return "Its too BIG!!!" local $str = '' While True if $n = 0 then ExitLoop $str &= '.'&Random(1,$tempd[2],1) $n -=1 WEnd return StringRight($str,StringLen($str)-1) EndIf return $Wrong EndFunc Func help_list() local $str = "Current list of commands:" & _ "!HELP,!ROLL,!SLAP,!TRIVIABOT,!TIME,!8BALL" Return $str EndFunc Func _Error($iError, $sError) ConsoleWrite("iERROR: "&$iError&"sERROR: "& $sError & @LF) EndFunc Func _Exit() Exit EndFunc ;==>_Exit Link to comment Share on other sites More sharing options...
FireFox Posted November 29, 2012 Author Share Posted November 29, 2012 (edited) @frank10 If it's not possible to do it manually with Skype, you won't be able to do it with Skype4COM. However, you can always try to find a workaround somewhere. @TJWho Thank you ! If you already know how to use the Skype4COM api with objects, only few functions will be useful for you because I have only converted objects to functions like AutoIt does, without handling non object errors. So, If you want to convert your script with a minimum of "visible" class objects, this would be (not tested) : expandcollapse popup#include "Skype.au3" ;Made by TJWho... ; ;You or a friend can message you with the following commands ; ;!help ;!time ;!slap [Person] ;!8ball [question] ;all the dice commands do the same thing ;!roll ;!DICE 20 ;!RANDOM 1-100 ;!RAND 3d3 ;#include <Skype.au3> ;Depending on where your skype.au3 is at. #include "Skype.au3" _Skype_Start() ;in case not running #region Variables Global $oChat, $blChat = False Global $oCall, $blCall = False, $blCallHold = False Global $sCurrUserHandle = _Skype_ProfileGetHandle() Global $sDealUserHandle #endregion Variables #region Skype_OnEvent _Skype_OnEventAttachmentStatus("_AttachmentStatus") _Skype_OnEventMessageStatus("_ChatMessage", $cCmsSent) _Skype_OnEventMessageStatus("_ChatMessage", $cCmsReceived) _Skype_OnEventError("_Error") #endregion Skype_OnEvent ;Taken from a 8ball.ini file #region 8ball.ini Local $a8ball[29] $a8ball[0] = "Maybe..." $a8ball[1] = "As I see It, Yes" $a8ball[2] = "It is certain" $a8ball[3] = "It is decidedly so" $a8ball[4] = "Most likely" $a8ball[5] = "Outlook good" $a8ball[6] = "Signs point to Yes" $a8ball[7] = "Without a doubt" $a8ball[8] = "YES" $a8ball[9] = "Yes, definitely" $a8ball[10] = "You may rely on it" $a8ball[11] = "Ask again later" $a8ball[12] = "Better not tell you now" $a8ball[13] = "Cannot predict now" $a8ball[14] = "Concentrate and ask again" $a8ball[15] = "Don't count on it" $a8ball[16] = "My reply is No" $a8ball[17] = "My sources say No" $a8ball[18] = "Outlook not so good" $a8ball[19] = "Reply Hazy, Try again" $a8ball[20] = "Very doubtful" $a8ball[21] = "Not only no, but HELL No!" $a8ball[22] = "Not only yes, but HELL Yes!" $a8ball[23] = "You will regret it!" $a8ball[24] = "Signs point to No" $a8ball[25] = "Go away... I don't want you back!" $a8ball[26] = "Well I love you, come back!" $a8ball[27] = "What? Are you taking me as an 8 ball?" $a8ball[28] = "Outlook is disturbing" #endregion 8ball.ini ;// Sleep While 1 Sleep(10) ;min 10 ;) WEnd ;// Where the event gets called too Func _ChatMessage($oMsg) DecodeMsg($oMsg) $sMsgType = _Skype_ChatMessageGetType($oMsg) If _Skype_ConvertChatMessageType($sMsgType, True) = "Unknown" Then ;or not converted: $cCmeUnknown AutoChat($oMsg) ElseIf _Skype_ConvertChatMessageType($sMsgType, True) = "Said" Then ;or not converted: $cCmeSaid AutoChat($oMsg) EndIf EndFunc ;==>_ChatMessage ;// The DecodeMsg event handler decodes messages in a chat and converts leave reasons to text for messages of type "Left": Func DecodeMsg($oMsg) $sText = _Skype_ChatMessageGetFromHandle($oMsg) & " " & _Skype_ConvertChatMessageType(_Skype_ChatMessageGetType($oMsg), True) & ":" $sMsgBody = _Skype_ChatMessageGetBody($oMsg) If StringLen($sMsgBody) Then $sText &= " " & $sMsgBody EndIf #cs If $oMsg.Type = $cMessageType_Left Then $sText = $sText & " " & $oSkype.Convert.ChatLeaveReasonToText($oMsg.LeaveReason) EndIf #ce ConsoleWrite($sText & @LF) EndFunc ;==>DecodeMsg Func _AttachmentStatus($TAttachmentStatus) ;the Skype UDF will automatically attach to skype when this one will be available EndFunc ;==>_AttachmentStatus ;// $oMsg.Chat.SendMessage responds with a message Func AutoChat($oMsg) $sMsgBody = _Skype_ChatMessageGetBody($oMsg) Local $sTemp = StringSplit($sMsgBody, " ") Switch $sTemp[1] Case '!time' $time = _DateDayOfWeek(@WDAY) & " " & _DateToMonth(@MON) & " " & @MDAY & " " & @YEAR & " -- " & @HOUR & ":" & @MIN & ":" & @SEC $oMsg.Chat.SendMessage('/me >>' & $time) ;Tuesday November 27 2012 -- 21:49:50 -05:00 Case '!help' $oMsg.Chat.SendMessage('/me >>' & help_list()) Case '!roll', '!DICE', '!RANDOM', '!RAND' $oMsg.Chat.SendMessage('/me >>' & DICE($sMsgBody)) EndSwitch If $sTemp[0] = 1 Then Return 0 Switch $sTemp[1] Case '!slap' $oMsg.Chat.SendMessage('/me >>' & _Skype_ChatMessageGetFromHandle($oMsg) & ' slaps ' & $sTemp[2] & ' around a bit with a large trout') Case '!8ball' $i = Random(0, UBound($a8ball) - 1) $oMsg.Chat.SendMessage('/me >>' & $a8ball[$i]) EndSwitch EndFunc ;==>AutoChat Func DICE($d = '') ;ConsoleWrite("BEFORE: "&$d & @LF) Local $regname = '(?x)(?i)!((roll)|(DICE)|(RANDOM)|(RAND))' $d = StringRegExpReplace($d, $regname, "") ;ConsoleWrite("AFTER: "&$d & @LF) If $d = '' Then Return Random(1, 100, 1) Local $tempd, $templ Local $Wrong = 'Invalid Syntax!' $regexp = "(?x)(?i)(([1-9]d[1-9])|([0-9]{0,4}-[0-9]{0,4})|([0-9]{0,4}))" If Not StringRegExp($d, $regexp) Then Return $Wrong $tempd = StringSplit($d, "d") If $tempd[0] = 1 Then $templ = StringSplit($d, "-") If $templ[0] = 1 Then Return Random(1, Int($d), 1) Return Random($templ[1], $templ[2], 1) Else Local $n = Int($tempd[1]) If $n > 1000 Then Return "Its too BIG!!!" Local $str = '' While True If $n = 0 Then ExitLoop $str &= '.' & Random(1, $tempd[2], 1) $n -= 1 WEnd Return StringRight($str, StringLen($str) - 1) EndIf Return $Wrong EndFunc ;==>DICE Func help_list() Local $str = "Current list of commands:" & _ "!HELP,!ROLL,!SLAP,!TRIVIABOT,!TIME,!8BALL" Return $str EndFunc ;==>help_list Func _Error($iError, $sError) ConsoleWrite("iERROR: " & $iError & "sERROR: " & $sError & @LF) EndFunc ;==>_Error Func _Exit() Exit EndFunc ;==>_Exit Was also wondering if there was a better way to respond to a chat directly from a message. Right now i'm using, "$oMsg.Chat.SendMessage". Good question, I have not found any example so I don't know, but it should exist. For the moment you must have the chat object which is not the case in your example. Br, FireFox. Edited November 29, 2012 by FireFox Link to comment Share on other sites More sharing options...
yahaosoft Posted November 29, 2012 Share Posted November 29, 2012 Very nice! thank you for sharing it. FireFox 1 Thanksgiving... Link to comment Share on other sites More sharing options...
lionfaggot Posted December 2, 2012 Share Posted December 2, 2012 (edited) so, i wanted to call someone then instantly hang up. as i understand it, _Skype_CallCreate("user") returns the call object? so i set it as a variable then used it in the finsih function, it calls but never finishes, heres the code: ---- $user = "lolpork" Global $oCall = _Skype_CallCreate($user) _Skype_CallFinish($oCall) ---- any ideas why it wont end the call? do i need some special object that i dont have? Edited December 2, 2012 by lionfaggot Link to comment Share on other sites More sharing options...
TJWho Posted December 3, 2012 Share Posted December 3, 2012 Lets see, One way to do this is use the _Skype_CallGetStatus function. Look for the word ";TCallStatus" in the Skype UDF. That will give you all the different call status that you can look for. Here is an example if you want them to pick up first and then it will drop the call. #include "Skype.au3" local $user = "lolpork" $oCall = _Skype_CallCreate($user) While 1 ;Wait for them to answer then drop the call if _Skype_CallGetStatus($oCall) = $cClsInProgress then ExitLoop WEnd _Skype_CallFinish($oCall) Hope this is what you looking for. Link to comment Share on other sites More sharing options...
Tjalve Posted December 13, 2012 Share Posted December 13, 2012 Hi FireFox. First of all. GREAT UDF. This will be a killer if i just understand how the heck everything is suposed to work here the deal. I want to create a script that add uers to the contact list. I have a list of skype-names and Ive managed to be able to check if the current user is in the contact list. heres my code #include #include $data = _Skype_SearchForUsers("skypename") ;~ _arraydisplay($data) consolewrite(_Skype_UserGetAuthorized($data[0]) & @CRLF) if _Skype_UserGetAuthorized($data[0]) = "False" Then ConsoleWrite($data[0].TBuddyStatus.budPendingAuthorization & @CRLF) EndIf Now if the function returns false, i would like to att the user to the list. or at least send a request to that person (a custom message woyld be awsome). But i cannot find a fuction for that so i seached the net and found that the API uses somthing called "TBuddyStatus.budPendingAuthorization". But i cant get it to work. The code runs, but nothing is happening. Any help would be appritiated. /G Link to comment Share on other sites More sharing options...
FireFox Posted December 13, 2012 Author Share Posted December 13, 2012 First of all. GREAT UDF. This will be a killer if i just understand how the heck everything is suposed to work I'm glad you like it Here you go : #include "Skype.au3" _Skype_OpenAddAFriend("echo123") ;or directly $oSkype.Friends.Add("echo123") I have not found how to set a custom add message, but I think that the first message sent is the custom message so try it. For the rest, keep your code. Br, FireFox. Link to comment Share on other sites More sharing options...
Tjalve Posted December 13, 2012 Share Posted December 13, 2012 I have now tried forever and i cant get it to work. I used _Skype_OpenAddAFriend("echo123") and the only thing that happend was that skype searched for users with that name. But didnt add them to my list I the tried to manually add the skypename of a user that i have deleted from my list _Skype_OpenAddAFriend("my.skype.name") and nothing happend. I tried the secound pice of code aswell. Same thing. Nothing happend. Link to comment Share on other sites More sharing options...
FireFox Posted December 14, 2012 Author Share Posted December 14, 2012 (edited) oh.., the syntax was a suggestion and you're right it's not as simple as I thought.Here you go :#include "Skype.au3" _Skype_UserAdd("echo123") Func _Skype_UserAdd($sUserHandle, $sPendingMessage = "Hi !") ;by FireFox If _Skype_UserGetBuddyStatus($sUserHandle) <> $cBudFriend Then __Skype_SendCommand("SET USER " & $sUserHandle & " BUDDYSTATUS " & $cBudPendingAuthorization & " " & $sPendingMessage, "", False) EndIf EndFunc ;==>_Skype_UserAddP.S: Don't try to add yourself as I saw "my.skype.name" in your last post.Br, FireFox. Edited December 14, 2012 by FireFox Link to comment Share on other sites More sharing options...
Tjalve Posted December 17, 2012 Share Posted December 17, 2012 oh.., the syntax was a suggestion and you're right it's not as simple as I thought. Here you go : #include "Skype.au3" _Skype_UserAdd("echo123") Func _Skype_UserAdd($sUserHandle, $sPendingMessage = "Hi !") ;by FireFox If _Skype_UserGetBuddyStatus($sUserHandle) <> $cBudFriend Then __Skype_SendCommand("SET USER " & $sUserHandle & " BUDDYSTATUS " & $cBudPendingAuthorization & " " & $sPendingMessage, "", False) EndIf EndFunc ;==>_Skype_UserAdd P.S: Don't try to add yourself as I saw "my.skype.name" in your last post. Br, FireFox. Alright i tried it on one of my friends (witch i had deeted befor) and it works. Great stuff! However the program never finishes. I just keep running like its waiting for somthing to happen or an never ending loop. The plan is to create a script that will add all contacts in out company to your skype.NBut if this little code never finshes, then i cant do more then one Link to comment Share on other sites More sharing options...
FireFox Posted December 17, 2012 Author Share Posted December 17, 2012 (edited) Huh, this is an autoit/Skype4COM issue. The only workaround is to replace the default Exit statement (when you don't have one it's at the end of the script) by : ProcessClose(@AutoItPID) Br, FireFox. Edited December 17, 2012 by FireFox Link to comment Share on other sites More sharing options...
Tjalve Posted December 19, 2012 Share Posted December 19, 2012 Ok. Thanks.I will do some more testing. Thanks Link to comment Share on other sites More sharing options...
Wisenlucky Posted February 27, 2013 Share Posted February 27, 2013 (edited) Hi everyone, How do I send skype message using this UDF? I added the Libraries to my code, trying to run, but nothing happends. #include <GUIConstants.au3> #include <Array.au3> #include <WinAPI.au3> #include "lib\Skype.au3" #AutoIt3Wrapper_UseX64=n $sUserHandle = "Wisenlucky" _Skype_ChatCreateWith($sUserHandle) Edited February 28, 2013 by Wisenlucky Link to comment Share on other sites More sharing options...
FireFox Posted February 27, 2013 Author Share Posted February 27, 2013 I added the Libraries to my code Those librairies have nothing to deal with the Skype UDF. You have not even included the UDF itself you want to use.I let you correct your mistake by yourself. As I see you are a novice in programming languages, start some tutorials.Br, FireFox. Link to comment Share on other sites More sharing options...
Wisenlucky Posted February 28, 2013 Share Posted February 28, 2013 (edited) I let you correct your mistake by yourself.Thanks a lot. I don't imagine how I would live further without your permission. Those librairies have nothing to deal with the Skype UDF. You have not even included the UDF itself you want to use. Actually I did. Just made mistake posting not all the included UDF's. I included all the other UDF's as in your example script, as i wasn't sure - maybe Skype.au3 UDF uses some of them. This is the code (corrected the code above also) #include <GUIConstants.au3> #include <Array.au3> #include <WinAPI.au3> #include "lib\Skype.au3" #AutoIt3Wrapper_UseX64=n $sUserHandle = "Wisenlucky" _Skype_ChatCreateWith($sUserHandle) ...start some tutorials. I read your tutorials before posting. It didn't help. For example as I understand I need to create chat first , then send the message using these functions. _Skype_ChatCreate($sUserHandle) _Skype_ChatMessage($iChatId, $sMessage) Nowhere in the manual I can find what's $sUserHandle and what's $iChatId. Logic tells me $sUserHandle is the username or skype nickname. Neither of them works in the code above. Second problem - nowhere in tutorial I can find how to get parameter ChatId. Can any one give any advice regarding these parameters? Edited February 28, 2013 by Wisenlucky Link to comment Share on other sites More sharing options...
FireFox Posted February 28, 2013 Author Share Posted February 28, 2013 Actually I did. Just made mistake posting not all the included UDF's. I included all the other UDF's as in your example script, as i wasn't sure Ok my apologizes then. There is indeed a bug in the UDF for the function _Skype_ChatCreate, but you can handle a chat using the object instead of the ID. Here is how : (download the fixed version first to test with the ChatId) #include "Skype.au3" Local $iChatId, $oChat ;userhandle: account name of the user. ;using chat id: $iChatId = _Skype_ChatCreate("userhandle") _Skype_ChatMessage($iChatId, "test") ;using chat object: $oChat = _Skype_ChatCreateWith("userhandle") _Skype_ChatSendMessage($oChat, "test2") Nowhere in the manual I can find what's $sUserHandle and what's $iChatId. Logic tells me $sUserHandle is the username or skype nickname. Neither of them works in the code above. Second problem - nowhere in tutorial I can find how to get parameter ChatId. Read carefully what the function returns, if it's an object or an ID. Br, FireFox. Link to comment Share on other sites More sharing options...
Wisenlucky Posted February 28, 2013 Share Posted February 28, 2013 (edited) Read carefully what the function returns, if it's an object or an ID.Uh. Now I think I got it! Works perfectly now. Thanks a lot for your UDF, help and such a quick bugfix! Edited February 28, 2013 by Wisenlucky Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now