IanN1990 Posted October 13, 2011 Posted October 13, 2011 (edited) Heya, after a while searching i came across this topichttp://www.autoitscript.com/forum/topic/...r-v45/page__hl__messenger__fro?do=embed' frameborder='0' data-embedContent>**I tryed to paste the code into this topic but had problems with the Now i am fairly new but getting better, "has completed a few autoit exe projects" but something like this is out of levelWhat i am after is a exe that checks the status of msn, and changes it from away to online, or online to away. I am told the code i need is within that topic but i cant make heads or tails of it. Any help would be appreciated**At last, after 30mins of editing i found no-script was blocking the from working correctly Sorry to all the views that must of seen this post as a mess half the time ^^ Edited April 14, 2012 by IanN1990
IanN1990 Posted October 13, 2011 Author Posted October 13, 2011 (edited) expandcollapse popup;MSN application based status updater ;Practical use is for gaming ;Credit to Cynagen #include <_MSN.au3> #include <_WinProcess.au3> #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <ComboConstants.au3> #include <Constants.au3> if @Compiled Then $setstatus = 0 if ProcessExists(@ScriptName) <> @AutoItPID then Exit EndIf $version = "BETA v4.5" TraySetToolTip("MSN Application Status Updater " & $version) Opt("TrayOnEventMode",1) Opt("TrayMenuMode",1) ;~ Opt("TrayAutoPause",0) TraySetClick(16) $configshow = TrayCreateItem("Configure application tracking") TrayItemSetOnEvent($configshow,"ConfigureApps") TraySetOnEvent($TRAY_EVENT_PRIMARYDOUBLE,"ConfigureApps") TrayCreateItem("") $debugshow = TrayCreateItem("Show debug log") TrayItemSetOnEvent($debugshow,"showDebug") $trayexit = TrayCreateItem("Exit") TrayItemSetOnEvent($trayexit,"TrayExit") TraySetState() $debugdata = "" $debugwind = 0 $setstatus = 0 func Debug($dbugin) if $debugwind then msgbox(64,"DEBUG INTERNAL", "DATA PREFLUSH: " & @CRLF & $debugdata, 1) $dbugarr = StringSplit($debugdata,@CRLF,1) $debugdata = "" $d = 1 if $dbugarr[0] = 30 then $d = 2 while $d <= $dbugarr[0] if $dbugarr[$d] <> "" then $debugdata = $debugdata & $dbugarr[$d] & @CRLF $d = $d + 1 WEnd $debugdata = $debugdata & @HOUR & ":" & @MIN & ":" & @SEC & " " & $dbugin & @CRLF ;$out = FileOpen("status.debug",2) ;FileWrite($out,$debugdata) ;FileClose($out) EndFunc func showDebug() MsgBox(64,"DEBUG LOG", $debugdata) EndFunc Func TrayExit() Exit EndFunc Func OnAutoItExit() if $setstatus <> 0 then ChangeMSNMessage(0,False,"") EndFunc TrayTip("MSN Application Status Updater",$version & " Loaded",1) Debug("Application starting") $msnapplist=@ScriptDir & "\msnapplist.ini" if not FileExists($msnapplist) then filewriteline($msnapplist,"[options]" & @CRLF & "sleep=500") ConfigureApps() EndIf Func ConfigureApps() #Region ### START Koda GUI section ### Form= $ConfigWND = GUICreate("MSNStatus Configuration", 345, 417, -1, -1) $Group1 = GUICtrlCreateGroup("Application to add/modify", 8, 0, 329, 57) $AppList = GUICtrlCreateCombo("", 16, 24, 233, 25) $NewApp = GUICtrlCreateButton("New", 249, 24, 40, 20, 0) $DeleteApp = GUICtrlCreateButton("Delete", 288, 24, 43, 20, 0) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group2 = GUICtrlCreateGroup("General Settings", 8, 64, 329, 145) $Label1 = GUICtrlCreateLabel("Prefix", 80, 80, 30, 17, $SS_CENTER) $Label2 = GUICtrlCreateLabel("Suffix", 200, 80, 30, 17, $SS_CENTER) $Label3 = GUICtrlCreateLabel("Music:", 16, 96, 60, 17, $SS_RIGHT) $MusicPrefix = GUICtrlCreateInput("", 80, 94, 121, 21) $MusicSuffix = GUICtrlCreateInput("", 200, 94, 121, 21) $Label4 = GUICtrlCreateLabel("Games:", 16, 120, 60, 17, $SS_RIGHT) $GamePrefix = GUICtrlCreateInput("", 80, 118, 121, 21) $GameSuffix = GUICtrlCreateInput("", 200, 118, 121, 21) $Label5 = GUICtrlCreateLabel("Office:", 16, 144, 60, 17, $SS_RIGHT) $OfficePrefix = GUICtrlCreateInput("", 80, 142, 121, 21) $OfficeSuffix = GUICtrlCreateInput("", 200, 142, 121, 21) $Label6 = GUICtrlCreateLabel("Process checking timer (ms):", 64, 178, 139, 17, $SS_CENTER) $Timer = GUICtrlCreateInput("", 208, 174, 73, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) GUICtrlCreateGroup("", 16, 161, 313, 7) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group3 = GUICtrlCreateGroup("Application Settings", 8, 216, 329, 97) $Label7 = GUICtrlCreateLabel("Name override:", 16, 236, 76, 17, $SS_RIGHT) $NameOverride = GUICtrlCreateInput("", 96, 232, 233, 21) GUICtrlSetTip(-1, "Leaving this blank will use auto-detect, and will show up as {AUTONAME} in the example display.") $Label8 = GUICtrlCreateLabel("Application type:", 16, 258, 82, 17) $TypeG = GUICtrlCreateRadio("Game", 104, 256, 65, 17) $TypeM = GUICtrlCreateRadio("Music", 176, 256, 65, 17) $TypeO = GUICtrlCreateRadio("Office", 248, 256, 65, 17) $Label9 = GUICtrlCreateLabel("Prefix/Suffix override:", 16, 284, 105, 17) $AppPrefix = GUICtrlCreateInput("", 120, 280, 105, 21) $AppSuffix = GUICtrlCreateInput("", 224, 280, 105, 21) GUICtrlCreateGroup("", -99, -99, 1, 1) $Group4 = GUICtrlCreateGroup("Example display", 8, 320, 329, 65) $Label10 = GUICtrlCreateLabel("This is what MSN should display upon activating the application.", 16, 336, 307, 17, $SS_CENTER) $ExampleDisplay = GUICtrlCreateLabel("", 16, 360, 313, 17, BitOR($GUI_SS_DEFAULT_LABEL,$SS_LEFTNOWORDWRAP,$SS_SUNKEN,$SS_NOPREFIX)) GUICtrlCreateGroup("", -99, -99, 1, 1) $OK = GUICtrlCreateButton("OK", 165, 392, 55, 20, 1) $Apply = GUICtrlCreateButton("Apply", 220, 392, 55, 20, 0) $Cancel = GUICtrlCreateButton("Cancel", 275, 392, 55, 20, 0) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### #Region ### Initialize display GUICtrlSetData($Timer,IniRead($msnapplist,"options","sleep",500)) GUICtrlSetData($MusicPrefix,IniRead($msnapplist,"options","prefix0","")) GUICtrlSetData($MusicSuffix,IniRead($msnapplist,"options","suffix0","")) GUICtrlSetData($GamePrefix,IniRead($msnapplist,"options","prefix1","")) GUICtrlSetData($GameSuffix,IniRead($msnapplist,"options","suffix1","")) GUICtrlSetData($OfficePrefix,IniRead($msnapplist,"options","prefix2","")) GUICtrlSetData($OfficeSuffix,IniRead($msnapplist,"options","suffix2","")) $inilist = IniReadSectionNames($msnapplist) if @error then msgbox(0,"Error","Could not read MSN App List for configuration") Exit Else $list="" For $i = 1 to $inilist[0] if $inilist[$i] <> "options" then $list&=$inilist[$i] & "|" Next GUICtrlSetData($AppList,stringtrimright($list,1)) EndIf #EndRegion ### Initialize display dim $lastapp, $showexample=0 While 1 $nMsg = GUIGetMsg() if GUICtrlRead($AppList) <> $lastapp then $nMsg = $AppList $lastapp = GUICtrlRead($AppList) EndIf if $nMsg = $Apply OR $nMsg = $OK then IniWrite($msnapplist,"options","prefix0",GUICtrlRead($MusicPrefix)) IniWrite($msnapplist,"options","suffix0",GUICtrlRead($MusicSuffix)) IniWrite($msnapplist,"options","prefix1",GUICtrlRead($GamePrefix)) IniWrite($msnapplist,"options","suffix1",GUICtrlRead($GameSuffix)) IniWrite($msnapplist,"options","prefix2",GUICtrlRead($OfficePrefix)) IniWrite($msnapplist,"options","suffix2",GUICtrlRead($OfficeSuffix)) IniWrite($msnapplist,"options","sleep",GUICtrlRead($Timer)) $app=GUICtrlRead($AppList) if $app <> "" then if GUICtrlRead($TypeG) = $GUI_CHECKED then IniWrite($msnapplist,$app,"type",1) if GUICtrlRead($TypeM) = $GUI_CHECKED then IniWrite($msnapplist,$app,"type",0) if GUICtrlRead($TypeO) = $GUI_CHECKED then IniWrite($msnapplist,$app,"type",2) if GUICtrlRead($NameOverride) <> "" then IniWrite($msnapplist,$app,"name",GUICtrlRead($NameOverride)) else IniDelete($msnapplist,$app,"name") EndIf if GUICtrlRead($AppPrefix) <> "" Then IniWrite($msnapplist,$app,"prefix",GUICtrlRead($AppPrefix)) Else IniDelete($msnapplist,$app,"prefix") EndIf if GUICtrlRead($AppSuffix) <> "" then IniWrite($msnapplist,$app,"suffix",GUICtrlRead($AppSuffix)) Else IniDelete($msnapplist,$app,"suffix") EndIf EndIf if $nMsg = $OK then GUIDelete($ConfigWND) ExitLoop EndIf $showexample=1 EndIf Switch $nMsg Case $GUI_EVENT_CLOSE GUIDelete($ConfigWND) ExitLoop Case $Cancel GUIDelete($ConfigWND) ExitLoop Case $AppList $app=GUICtrlRead($AppList) GUICtrlSetData($NameOverride,IniRead($msnapplist,$app,"name","")) GUICtrlSetData($AppPrefix,IniRead($msnapplist,$app,"prefix","")) GUICtrlSetData($AppSuffix,IniRead($msnapplist,$app,"suffix","")) Switch IniRead($msnapplist,$app,"type",0) Case 0 GUICtrlSetState($TypeM,$GUI_CHECKED) Case 1 GUICtrlSetState($TypeG,$GUI_CHECKED) Case 2 GUICtrlSetState($TypeO,$GUI_CHECKED) EndSwitch $showexample=1 Case $DeleteApp if GUICtrlRead($AppList) then IniDelete($msnapplist,GUICtrlRead($AppList)) $inilist = IniReadSectionNames($msnapplist) if @error then msgbox(0,"Error","Could not read MSN App List for configuration") Exit Else $list="" For $i = 1 to $inilist[0] if $inilist[$i] <> "options" then $list&=$inilist[$i] & "|" Next GUICtrlSetData($AppList,"") GUICtrlSetData($AppList,stringtrimright($list,1)) EndIf $showexample=1 Case $NewApp $file=FileOpenDialog("Select an application to track",".","Applications (*.exe)|Binary files (*.bin)|All files (*.*)",1,"",$ConfigWND) if NOT @Error Then $file1=stringsplit($file,"\") $file=$file1[$file1[0]] $inilist = IniReadSectionNames(@ScriptDir & "\msnapplist.ini") if @error then msgbox(0,"Error","Could not read MSN App List for configuration") Exit Else $list="" For $i = 1 to $inilist[0] if $inilist[$i] <> "options" then $list&=$inilist[$i] & "|" Next if NOT StringInStr($list,$file,2) then $list&=$file Else $list=StringTrimRight($list,1) EndIf GUICtrlSetData($AppList,"") GUICtrlSetData($AppList,$list,$file) EndIf $app=$file GUICtrlSetData($NameOverride,IniRead($msnapplist,$app,"name","")) GUICtrlSetData($AppPrefix,IniRead($msnapplist,$app,"prefix","")) GUICtrlSetData($AppSuffix,IniRead($msnapplist,$app,"suffix","")) Switch IniRead($msnapplist,$app,"type",0) Case "0" GUICtrlSetState($TypeM,$GUI_CHECKED) Case "1" GUICtrlSetState($TypeG,$GUI_CHECKED) Case "2" GUICtrlSetState($TypeO,$GUI_CHECKED) EndSwitch EndIf $showexample=1 EndSwitch if $showexample Then $app=GUICtrlRead($AppList) if $app <> "" Then $example_type=IniRead($msnapplist,$app,"type",0) $example_prefix=IniRead($msnapplist,$app,"prefix",IniRead($msnapplist,"options","prefix" & $example_type,"")) if $example_prefix <> "" then $example_prefix&=" " $example_suffix=IniRead($msnapplist,$app,"suffix",IniRead($msnapplist,"options","suffix" & $example_type,"")) if $example_suffix <> "" then $example_suffix=" " & $example_suffix $example_name=IniRead($msnapplist,$app,"name","{AUTONAME}") GUICtrlSetData($ExampleDisplay,$example_prefix & $example_name & $example_suffix) else GUICtrlSetData($ExampleDisplay,"") EndIf $showexample=0 endif WEnd EndFunc while 1 $lastprocs = 0 $var = IniReadSectionNames($msnapplist) if @error Then msgbox(4096, "ERROR", "Error: 'msnapplist.ini' could not be read" & @CRLF & "Please check the file and try again") Exit EndIf Debug("msnapplist.ini Exists and is readable") if $var[0]-1 = 0 Then if $var[1] = "options" then TraySetState(4) TrayTip("Hey, Listen!","You don't have any applications set up. I know we prompted you to add some (I'm programmed to), so you must be REALLY lazy. How about you add some now? Doubleclick on this icon to bring up the Configuration tool, otherwise I'm a useless app!",10) Debug("MSNStatus is useless at this point, user has no defined applications.") EndIf Else TraySetState(8) EndIf $filetime = FileGetTime($msnapplist,0,1) $sleep = IniRead($msnapplist,"options","sleep",500) Debug("Loaded msnapplist into memory") while $filetime = FileGetTime($msnapplist,0,1) Debug("Applications tracked: " & $var[0]-1) for $i = 1 to $var[0] if $var[$i] = "options" then continueloop $appexe = $var[$i] Debug("Checking for '" & $appexe & "'") $appname = "" $lappname = "" $apptype=IniRead($msnapplist,$appexe,"type",2) $prefix=IniRead($msnapplist,$appexe,"prefix",IniRead($msnapplist,"options","prefix" & $apptype,0)) $suffix=IniRead($msnapplist,$appexe,"suffix",IniRead($msnapplist,"options","suffix" & $apptype,0)) while processexists($appexe) Debug("Tracking process: " & $appexe) $pidname = _Process2Win($appexe) while _Win2Process($pidname) <> $appexe AND processexists($appexe) $pidname = _Process2Win($appexe) Debug("Retrying to match process to window [PIDNAME]") sleep($sleep) WEnd $appname=IniRead($msnapplist,$appexe,"name",$pidname) if $prefix then $appname = $prefix & " " & $appname if $suffix then $appname = $appname & " " & $suffix if $appname <> $lappname then Debug("Found process: " & $appexe & " with title: " & $appname) ChangeMSNMessage($apptype,True,$appname) $setstatus=1 Debug("Updated status") $lappname = $appname EndIf sleep($sleep) WEnd if $appname then ChangeMSNMessage(0,False,"") $setstatus=0 Debug("Cleared status") EndIf sleep(1) Next $procs = ProcessList() while $procs[0][0] = $lastprocs $procs = ProcessList() Debug("Checked processes") sleep(ceiling($sleep/10)) WEnd Debug("New process detected (Process count changed)") $lastprocs = $procs[0][0] sleep($sleep) WEnd TrayTip("Application list has changed!", "Reloading the list", 2) Debug("Application list changed, reloaded") sleep($sleep) WEnd Edited October 13, 2011 by IanN1990
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