Sign in to follow this  
Followers 0
Dethredic

msn monetering function

51 posts in this topic

i have a script that checks to see if msn is running and if so it does a bunch of things

I have 2 accounts on my computer mine and my little bros.

the script is ment to limit him to 10 minutes on msn per day.

the problem is that if i have msn running in my account (and not the other) the script sees msn as running (when im in the other account) and therefor starts counting down when it shouldn't be.

is there a way i can get the process exist to only check one account to see if a process is running?

here is my script:

Dim $10Mins = 600000
Global $Timeup
TraySetState(2)

HotKeySet("!^x", "Quit")

Func Quit()
    Exit 0
EndFunc

While 1 
    Sleep(1000)
    If ProcessExists("msnmsgr.exe") And @UserName = "Lowy Gunnewiek" Then 
     Call("Timeup")
     Call("Countdown")
EndIf
Sleep(1000)
WEnd

Call("Timeup")


;Countdown 10 Mins

Func Countdown()
    Sleep(1000)
    If ProcessExists("msnmsgr.exe") And @UserName = "Lowy Gunnewiek" Then
        Sleep(1000)
        MsgBox(4096 , "Time Limit", "Your 10 Minutes On MSN Is Now Counting Down")
        Do
            If ProcessExists("msnmsgr.exe") And @UserName = "Lowy Gunnewiek" Then
            Sleep(1000)
            $10Mins = $10Mins - 1000
            EndIf
        Until $10Mins = 0
    IniWrite( "Log.ini", @MON , @MDAY , "Timeup")
    EndIf
EndFunc


;Kill MSN

Func Timeup()
    $Timeup = IniRead( "Log.ini", @MON , @MDAY , "NotFound")
    If ProcessExists("msnmsgr.exe") And @UserName = "Lowy Gunnewiek" Then   
        If $Timeup = "Timeup" Then
            ProcessClose("msnmsgr.exe")
            MsgBox(4096 , "Times Up", "Your 10 Minutes Has Expired, Try Again Tomorrow")
        EndIf
    EndIf
EndFunc

i need to check if the msn is mine or my bros so i added this: @UserName = "Lowy Gunnewiek" (brother)

but that just check wat account is active.

how can i make it so it checks for the msn process belonging to my bros account??


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites



Haven't you already posted on this very thing?

http://www.autoitscript.com/forum/index.ph...st&p=242345


[center]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.[/center]

Share this post


Link to post
Share on other sites

I have 2 accounts on my computer mine and my little bros.

the script is ment to limit him to 10 minutes on msn per day.

look out that he wont be member here.

maybe one day will come that he punish you for this :lmao:!


[quote name='AceLoc']I gots new sunglasses there cool.[/quote]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I think this can be done with Objects much easier from Microsoft.Messenger.MSNSignedIn but I couldn't get it to work... So here is a long drawn out function just because the above pissed me off (Not sure it will work for everyone, but it worked for all my MSN accounts)

$ActiveUser = _MSNUserActive()
If @error Then
    MsgBox(16, 'Error', @error & ' is the error number.')
Else
    MsgBox(64, 'Info:', 'MSN Messenger Active User: ' & $ActiveUser)
EndIf

Func _MSNUserActive()
    If Not ProcessExists('msnmsgr.exe') Then Return SetError(1, 0, 0);MSN is not on
    Local $hMain = @UserProfileDir & '\Local Settings\Application Data\Microsoft\Messenger\'
    Local $hFileToRead = '\SharingMetadata\Logs\Dfsr.log'
    Local $sSearch = FileFindFirstFile($hMain & '*.*')
    Local $hDirectory, $sUserName, $hFoundDir, $aSplit
    While 1
        $hDirectory = FileFindNextFile($sSearch)
        If @error Then ExitLoop
        If StringInStr(FileGetAttrib($hMain & $hDirectory), 'd') And StringInStr($hDirectory, '@') Then
            $aSplit = StringSplit($hDirectory, '@');Find the username by splitting email address found as a directory
            $sUserName &= $aSplit[1] & Chr(1)
            $hFoundDir &= $hMain & $hDirectory & $hFileToRead & Chr(1)
        EndIf
        Sleep(10)
    WEnd
    
    If Not $sUserName Then Return SetError(2, 0, 0);No users found
    
    $sUserName = StringSplit(StringTrimRight($sUserName, 1), Chr(1))
    $hFoundDir = StringSplit(StringTrimRight($hFoundDir, 1), Chr(1))
    If $sUserName[0] < 2 Then
        If $sUserName[1] = '' Then Return SetError(3, 0, 0);If by chance a directory was found, but the username is blank
        Return $sUserName[1];Only 1 username registered, return username
    EndIf
    
    Local $hRead, $aNSplit, $aSRE, $iHour = 0, $iMin = 0, $iSec = 0, $nUser
    For $iCC = 1 To $hFoundDir[0]
        $hRead = FileRead($hFoundDir[$iCC])
        $aSRE = StringRegExp($hRead, '(?i:' & @YEAR & @MON & @MDAY & ' )(.*?)(?i:\.)', 3)
        If Not @extended Or Not IsArray($aSRE) Then ContinueLoop
        $aNSplit = StringSplit($aSRE[0], ':')
        If $aNSplit[0] < 3 Then ContinueLoop
        If Int($aNSplit[1]) > Int($iHour) Then
            $iHour = $aNSplit[1]
            $iMin = $aNSplit[2]
            $iSec = $aNSplit[3]
            $nUser = $iCC
        ElseIf Int($aNSplit[1]) = Int($iHour) And Int($aNSplit[2]) > Int($iMin) Then
            $iHour = $aNSplit[1]
            $iMin = $aNSplit[2]
            $iSec = $aNSplit[3]
            $nUser = $iCC
        ElseIf Int($aNSplit[1]) = Int($iHour) And Int($aNSplit[2]) = Int($iMin) And Int($aNSplit[3]) > Int($iSec) Then
            $iHour = $aNSplit[1]
            $iMin = $aNSplit[2]
            $iSec = $aNSplit[3]
            $nUser = $iCC
        EndIf
    Next
    If $nUser Then Return $sUserName[$nUser]
    Return SetError(4, 0, 0)
EndFunc
Edit:

Had to fix the If/ElseIf statement.

Edited by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

thanks smoke_n

this will help


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

Also

$oMessenger = ObjCreate("Messenger.UIAutomation.1")
          $oServices = $oMessenger.Services()
          $oPrimserv = $oServices.PrimaryService()
          $oName = $oPrimserv.MyFriendlyName()
          If $oName = "Lowy Gunnewiek" Then   ProcessClose("msnmsgr.exe")

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

can someone help me combine mine with smoke_n.

so it checks if my bros msn is the active one then runs the script.

and if hes not on it just keeps checking like every 10 secs or so


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

can someone help me combine mine with smoke_n.

so it checks if my bros msn is the active one then runs the script.

and if hes not on it just keeps checking like every 10 secs or so

Whats wrong with mine? :lmao:

$oMessenger = ObjCreate("Messenger.UIAutomation.1")
$oServices = $oMessenger.Services()
$oPrimserv = $oServices.PrimaryService()
$oName = $oPrimserv.MyFriendlyName() 
Dim $10Mins = 600000
Global $Timeup
TraySetState(2)

HotKeySet("!^x", "Quit")

Func Quit()
    Exit 0
EndFunc

While 1
    Sleep(1000)
    If ProcessExists("msnmsgr.exe") And $oName = "Lowy Gunnewiek" Then
     Call("Timeup")
     Call("Countdown")
EndIf
Sleep(1000)
WEnd

Call("Timeup")


;Countdown 10 Mins

Func Countdown()
    Sleep(1000)
    If ProcessExists("msnmsgr.exe") And $oName = "Lowy Gunnewiek" Then
        Sleep(1000)
        MsgBox(4096 , "Time Limit", "Your 10 Minutes On MSN Is Now Counting Down")
        Do
            If ProcessExists("msnmsgr.exe") And $oName = "Lowy Gunnewiek" Then
            Sleep(1000)
            $10Mins = $10Mins - 1000
            EndIf
        Until $10Mins = 0
    IniWrite( "Log.ini", @MON , @MDAY , "Timeup")
    EndIf
EndFunc


;Kill MSN

Func Timeup()
    $Timeup = IniRead( "Log.ini", @MON , @MDAY , "NotFound")
    If ProcessExists("msnmsgr.exe") And $oName = "Lowy Gunnewiek" Then   
        If $Timeup = "Timeup" Then
            ProcessClose("msnmsgr.exe")
            MsgBox(4096 , "Times Up", "Your 10 Minutes Has Expired, Try Again Tomorrow")
        EndIf
    EndIf
EndFunc

Tell me if it works, I didnt test it.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

nothing happens i run it then it quits,

i wanted to use smoke_n's cause i saw how the end result worked when i ran it. urs i didn't understand at all


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

on my bros account i get an error if msn is not logged in when i run it (which is bad)

as i said b4 nothing happens if msn is running


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

on my bros account i get an error if msn is not logged in when i run it (which is bad)

as i said b4 nothing happens if msn is running

It must only work for windows messenger.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

i have windows messenger.


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

i have windows messenger.

Were you using it?

# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

ya lol


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

any other ideas?


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

anyone?


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

have any ideas???


"Its not about the 30 inch 1080p display, or the SLI 8800 ultras, or the DDR3 memory. It's about when you turn on your PC, does it return the favor?"Math is like sex. Sure, it may give some practical results, but that is not why we do it

Share this post


Link to post
Share on other sites

I think you've bumped enough now that either you can consider the topic dead, or no one wants to help you.


[center]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.[/center]

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

if i get this right you want msn to exit when he is on his account so all you do is.....

drop it in his start up folder in his account with a reg write telling it to run the script on boot up and vola

edited: and 10mins is sleep(100000)

Edited by Vicks

[s]Autoit[/s]

Share this post


Link to post
Share on other sites

Except, I think, Hes saying that, he doesnt log out of his account first, just switches user, so it detects his msn on his username before his brothers.


# MY LOVE FOR YOU... IS LIKE A TRUCK- #

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0