Jump to content

Msn Messenger Boss Function


Andre
 Share

Recommended Posts

Hi,

Iv'e created an small tool that quickly hides all the open conversation windows from msn messenger in case your boss (or wife/girlfriend) comes in the room :(

Boss Key = [CTRL] + `

Change the variable $NameOfWindow according to the language of Msn Messgener you are using.

In my case it's dutch.

;----
; Variables Declaration
;----
 
Dim $MaxWindows = 15
Dim $Arr[($MaxWindows +1) * 2]
Dim $Counter = 1
Dim $NameOfWindow = "- Gesprek"
Dim $I
Dim $IsHidden = "False"

; ----------------------------------------------------------------------------
; Set up our defaults
; ----------------------------------------------------------------------------
AutoItSetOption("WinTitleMatchMode",2)
AutoItSetOption("MustDeclareVars",1) 
; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

HotKeySet("^`","LetsDoIt")

While 1
   Sleep(100)
Wend


Func LetsDoIt()
   
If $IsHidden = "False" Then
   $Counter = 1
   For $I = 1 To $Maxwindows
      If WinExists($NameOfWindow,"") Then
         $Arr[$Counter] = WinGetTitle($NameOfWindow,"")
         $Counter = $Counter + 1
         WinSetTitle($NameOfWindow,"", $Counter & "My New Window")
         $Arr[$Counter] = WinGetTitle($Counter & "My New Window","")
         $Counter = $Counter + 1
      EndIf
   Next
   
   For $I = 2 to $Counter -1 Step 2
      WinSetState($Arr[$I],"",@SW_HIDE)
   Next

     
   $IsHidden = "True"
Else

   For $I = 2 to $Counter -1 Step 2
      WinSetState($Arr[$I],"",@SW_Show)
      
   Next
 
   For $I = $Counter  To 1 Step -2
      If $I = 1 Then ExitLoop
         WinSetTitle($Arr[$I -1] ,"", $Arr[$I-2])
      Next
   $IsHidden = "False"   
EndIf
EndFunc

Regards,

Andre :ph34r:

Edit : Ps. let me know if u like it :lol:

Edited by Andre
What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

Just tested it. Its a bit buggy, works for a few presses of the hotkey (see below *), but then the conversation window just disappears. Exiting the script does not restore the window. If you exit msn, it tells you that all converstion windows will be closed, so they are all there. Might be worth adding the ability to restore all conversation windows if the script is exited.

*I think the problem above occurs if you press the hotkey too quickly.

But all in all very useful - thanks!! I use a lot of boss keys, mainly written using power-pro!!!

I am using WinXP Pro on a 2.6 Celeron, With MSN 6.2

Steve

Also watch out when copying the script from the forum as the hotkey line copies has the wrong type of single quote for my UK keyboard

HotKeySet("^'","LetsDoIt") - This works on my system

HotKeySet("^`","LetsDoIt") - This from Andre's script Doesn't

Probably an internationallisation problem!!!

Edited by xircon
Link to comment
Share on other sites

Hi Xircon,

Indeed if u press the hotkey too quickly it fails.

About restoring the windows if u exit the script is not possible because there is no event that monitors it

Andre

What about Windows without using AutoIt ?It would be the same as driving a car without an steering Wheel!
Link to comment
Share on other sites

  • 4 weeks later...

Hiya Andre,

although i'm not using MSN i like your program. I had a look at it and made some changes (i hope you don't mind), now it should be more stable and even quicker.

Don't forget to change Window title and Hotkey to your needs!

; ----------------------------------------------------------------------------
; Set up defaults
; ----------------------------------------------------------------------------

AutoItSetOption("MustDeclareVars", 1)

; ----------------------------------------------------------------------------
; Set up variables
; ----------------------------------------------------------------------------

Dim $MaxWindows = 15
Dim $Arr[($MaxWindows +1)][2]
Dim $Counter = 1
Dim $NameOfWindow = "- Mozilla Firefox"
Dim $I
Dim $IsHidden = 0
Dim $InProgress = 0

; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

HotKeySet("°", "LetsDoIt")

While 1
   Sleep(100)
Wend

Func LetsDoIt()
  If NOT $InProgress Then
    $InProgress = 1
    If NOT $IsHidden Then
      $Counter = 1
      AutoItSetOption("WinTitleMatchMode", 2)
      For $I = 0 To $Maxwindows-1
        If WinExists($NameOfWindow, "") Then 
          $Arr[$I][0] = "handle=" & WinGetHandle($NameOfWindow, "")
          $Arr[$I][1] = WinGetTitle($NameOfWindow, "")
          WinSetState($NameOfWindow, "", @SW_HIDE)
          WinSetTitle($NameOfWindow, "", "Window" & $I)
        Else
          ExitLoop
        EndIf
        $Counter = $I
      Next
      $IsHidden = 1
    Else
      AutoItSetOption("WinTitleMatchMode", 4)
      For $I = $Counter to 0 Step -1
        WinSetTitle($Arr[$I][0], "", $Arr[$I][1])
        WinSetState($Arr[$I][0], "", @SW_Show)
      Next
      $IsHidden = 0
    EndIf
    $InProgress = 0
  EndIf
EndFunc

Greetings,

ZeD

Link to comment
Share on other sites

mhm, dunno if anyone needs such complex script except me, but i remade the code, so you are able to define up to 10 groups of up to 10 window titles to hide.

I dont use it as a boss key only, but also to hide windows i dont need atm, but cant close (like java eclipse platform)

Check it out if you want.

; ----------------------------------------------------------------------------
; Set up defaults
; ----------------------------------------------------------------------------

AutoItSetOption("MustDeclareVars", 1)

; ----------------------------------------------------------------------------
; Set up variables
; ----------------------------------------------------------------------------

Dim $MaxWindows = 10
Dim $Arr[10][$MaxWindows][2]
Dim $Counter[10]
Dim $I
Dim $J
Dim $IsHidden[10]
Dim $InProgress = 0
Dim $WindowArr[10][$MaxWindows]
Dim $WinNum[10]

; Here you define your Window titles. First dimension is the group, second dimension
; is the window number in the group. Please set winnum[groupnumber] to the
; number of windows you have entered in the group.
$WindowArr[0][0] = "Mozilla Firefox"
$WindowArr[0][1] = "Explorer - "
$WinNum[0] = 2

$WindowArr[1][0] = "Java - Eclipse"
$WindowArr[1][1] = "AutoIt Help"
$WinNum[1] = 2

; ----------------------------------------------------------------------------
; Script Start
; ----------------------------------------------------------------------------

; Access each group through pressing Ctrl+Shift+(Groupnumber+1)
HotKeySet("^+1", "Prog1") ; this is group 0 !!
HotKeySet("^+2", "Prog2")
HotKeySet("^+3", "Prog3")
HotKeySet("^+4", "Prog4")
HotKeySet("^+5", "Prog5")
HotKeySet("^+6", "Prog6")
HotKeySet("^+7", "Prog7")
HotKeySet("^+8", "Prog8")
HotKeySet("^+9", "Prog9")
HotKeySet("^+0", "Prog0")

For $J = 0 To 9
  $IsHidden[$J] = 0
  For $I = 0 To $MaxWindows-1
    WinSetState("Window" & $J & $I, "", @SW_Show)
  Next
Next

While 1
   Sleep(100)
Wend

Func Prog1()
  Hide_Win(0)
EndFunc
Func Prog2()
  Hide_Win(1)
EndFunc
Func Prog3()
  Hide_Win(2)
EndFunc
Func Prog4()
  Hide_Win(3)
EndFunc
Func Prog5()
  Hide_Win(4)
EndFunc
Func Prog6()
  Hide_Win(5)
EndFunc
Func Prog7()
  Hide_Win(6)
EndFunc
Func Prog8()
  Hide_Win(7)
EndFunc
Func Prog9()
  Hide_Win(8)
EndFunc
Func Prog0()
  Hide_Win(9)
EndFunc

Func Hide_Win($group)
  If NOT $InProgress Then
    $InProgress = 1
    If NOT $IsHidden[$group] Then
      $Counter[$group] = -1
      AutoItSetOption("WinTitleMatchMode", 2)
      For $J = 0 To $WinNum[$group]-1
        For $I = $Counter[$group]+1 To $MaxWindows-1
          If WinExists($WindowArr[$group][$J], "") Then 
            $Arr[$group][$I][0] = "handle=" & WinGetHandle($WindowArr[$group][$J], "")
            $Arr[$group][$I][1] = WinGetTitle($WindowArr[$group][$J], "")
            WinSetState($WindowArr[$group][$J], "", @SW_HIDE)
            WinSetTitle($WindowArr[$group][$J], "", "Window" & $group & $I)
          Else
            ExitLoop
          EndIf
          $Counter[$group] = $I
        Next
      Next
      $IsHidden[$group] = 1
    Else
      AutoItSetOption("WinTitleMatchMode", 4)
      For $I = $Counter[$group] to 0 Step -1
        WinSetTitle($Arr[$group][$I][0], "", $Arr[$group][$I][1])
        WinSetState($Arr[$group][$I][0], "", @SW_Show)
      Next
      WinActivate($Arr[$group][0][0], "")
      $IsHidden[$group] = 0
    EndIf
    $InProgress = 0
  EndIf
EndFunc

Greetings,

ZeD

Link to comment
Share on other sites

mhh ... worked fine here. post your windowarr-settings, and i'll try them

ah yea, another thing: i put windowmatchmode to 2, so it will search window titles by substring. will mean if you specify "pad" as window it will find "paddle game" but also "notepad". be sure to use window titles which cannot be misunderstood.

btw: the script will restore any hidden window when started. so if u loose any window, just close the script and re-open it (in special cases several times), it should unhide all windows then (but with wrong title)

Edited by ZeDMIN
Link to comment
Share on other sites

has ny1 come up with an upgraded script enabling for the taskbar icon to be hidden as well (nt the script but lyk msn for example)...the sm way the conversation can be hidden...if the taskbar icon could also be hidden or mayB temporarily replaced to something else while the conversations are hidden...if both scripts could be done..tht wud b gr8!!

Link to comment
Share on other sites

Just a thought, if you add a hotkey function to exit the script, you could possibly add the ability to restore the windows upon exit. Of course, if you exit from the taskbar icon, then that will not work.

Here's a quick snipit from the help files for the exit_function idea.

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

...

...

; Rest of Script

...

...

Func MyExit()

WinMaxmize("...windows...") ;added to show where to restore windows, check on syntax before using

Exit

EndFunc

Jason

jason7237
Link to comment
Share on other sites

If you want, put this in the script:

HotKeySet("^+x", "Terminate")

...

Func Terminate()
  For $J = 0 To 9
    If $IsHidden[$J] Then
      AutoItSetOption("WinTitleMatchMode", 4)
      For $I = $Counter[$J] to 0 Step -1
        WinSetTitle($Arr[$J][$I][0], "", $Arr[$J][$I][1])
        WinSetState($Arr[$J][$I][0], "", @SW_Show)
      Next
      $IsHidden[$J] = 0
    EndIf
  Next
  Exit
EndFunc

Should undo all hidings. (I did not test it. Tell me if it doesn't work.)

Greetings,

ZeD

Edited by ZeDMIN
Link to comment
Share on other sites

has ny1 come up with an upgraded script enabling for the taskbar icon to be hidden as well (nt the script but lyk msn for example)...the sm way the conversation can be hidden...if the taskbar icon could also be hidden or mayB temporarily replaced to something else while the conversations are hidden...if both scripts could be done..tht wud b gr8!!

<{POST_SNAPBACK}>

Edited by ali
Link to comment
Share on other sites

Sorry ali, AFAIK thats not possible with AutoIt

I would be glad if any Expert AutoIt-Programmer could prove me wrong  :(

Greetings,

ZeD

i meant his question if it is possible to hide task icons as well as windows.

but the exit-thing is also interesting, thanks valik :ph34r:

Greetings,

ZeD

Link to comment
Share on other sites

  • 1 month later...

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...