Didonet Posted November 11, 2007 Share Posted November 11, 2007 Help... again! I hate this while... I'm creating program that change the mood in skype with the current song you play in winamp. And i can't detect when does the song is changing... I'm using this function to get the winamp song: expandcollapse popupFunc WinAmp() Dim $PID = 1 $winampHWND = WinGetHandle ( "[CLASS:Winamp v1.x]") If $winampHWND = 0 Then MsgBox (0,"","Winamp does not appear to be running.") Exit EndIf $result = _SendMessage($winampHWND, 0x0400, 0, 0x7D, 0) If @error Then MsgBox (0,"","SendMessage failed." & @error) Exit EndIf $result2 = _SendMessage($winampHWND, 0x0400, $result, 0xD4, 0) If @error Then MsgBox (0,"","SendMessage failed.") Exit EndIf $lpszTitle = $result2 $result3 = DllCall("user32.dll","int","GetWindowThreadProcessId","hwnd",$winampHWND,"int_ptr", $PID) $PID = $result3[2] if (@error OR NOT $PID) Then MsgBox (0,"","GetWindowThreadProcessId failed.") Exit EndIf $result4 = DllCall("kernel32.dll", "uint", "OpenProcess", "byte", 0x10, "int",0, "int", $PID) if (@ERROR OR NOT $result4[0]) then MsgBox (0,"","OpenProcess failed: " & @ERROR) Exit endif $ProcessHandle = $result4[0] $SongTitle = "" While 1 Local $v_Struct = DllStructCreate ('byte[1]') $result5 = DllCall('kernel32.dll', 'int', 'ReadProcessMemory', 'int', $ProcessHandle, 'int', $lpszTitle, 'int', DllStructGetPtr ($v_Struct, 1), 'int', 1, 'int', 0) if (@error) Then MsgBox (0,"","ReadProcessMemory failed: " & @error) DllCall("Kernel32.dll", "int", "CloseHandle", "int", $ProcessHandle) Exit EndIf $temp = DllStructGetData ($v_Struct, 1) $v_Struct = 0 if $temp = 0 then ExitLoop $SongTitle &= Chr($temp) $lpszTitle += 1 WEnd DllCall("Kernel32.dll", "int", "CloseHandle", "int", $ProcessHandle) ; ErrorLevel and return value are not checked. Return "I'm listening to: <b>" & $SongTitle & "</b>" EndFuncoÝ÷ Ù©Ý~àzÛb.®·§¶j(v)ì*^jëh×6Func GetMood() $skype = ObjCreate("Skype4COM.Skype") If Not $skype.Client.IsRunning Then $skype.Client.Start() EndIf $skype.Attach Return $skype.CurrentUserProfile.MoodText EndFunc BUT... the loop is too fast... if i set sleep(5000) the whole program sleeps for 5 secs... How can i check if the song is changed to change it... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 Check out AdlibEnable(). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Didonet Posted November 11, 2007 Author Share Posted November 11, 2007 Yeah, i heard about the AdlibEnable() function. But... where I should use it? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 Just make a separate function to check every 5 seconds the same function you're checking in the loop. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Didonet Posted November 11, 2007 Author Share Posted November 11, 2007 While 1 $msg = GUIGetMsg() If $loop > 500 Then $currentWinamp = WinAmp() If $currentWinamp <> GetMood() Then GUICtrlSetData($text, $currentWinamp) ChangeMood($currentWinamp) TrayTip('Current listening...', $currentWinamp, 5) EndIf $loop = 0 EndIf $loop+=1 WEnd I created this... and without AdlibEnable it works... 1-2% of cpu... I don't get it where to put the AdlibEnable too... Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted November 11, 2007 Moderators Share Posted November 11, 2007 This should be even less CPU:Global $sMood = "", $bCheckMood = False AdlibEnable("_AdlibManager", 5000) While 1 $msg = GUIGetMsg() If $bCheckMood And $sMood <> GUICtrlRead($text) Then GUICtrlSetData($text, $sMood) $bCheckMood = False EndIf If $msg = $GUI_EVENT_CLOSE Then Exit WEnd Func _AdlibManager() $bCheckMood = True $sMood = GetMood() EndFunc Func GetMood() $skype = ObjCreate("Skype4COM.Skype") If Not $skype.Client.IsRunning Then $skype.Client.Start() EndIf $skype.Attach Return $skype.CurrentUserProfile.MoodText EndFuncOf course include your big winamp() func too. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Didonet Posted November 11, 2007 Author Share Posted November 11, 2007 hah, it's true, the process is 0% CPU Thanks... but... one problem If I want to change my mood by the program... when i start to writing the new mood it checks that the content of the edit is not like in my mood and it deletes what i write at this moment and replace it with my mood... is it possible when i'm writing something to stop checking 0.o Thanks again! Link to comment Share on other sites More sharing options...
therks Posted November 12, 2007 Share Posted November 12, 2007 My AutoIt Stuff | My Github Link to comment Share on other sites More sharing options...
Didonet Posted November 13, 2007 Author Share Posted November 13, 2007 help? 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