Jump to content

if , else problem


Go to solution Solved by Inverted,

Recommended Posts

hi all

 im trying to make a script that if it finds msn it hide it and if did not find it it show it 

i tried this

If WinSetState("Windows Live Messenger", "",@SW_SHOW) Then
   WinSetState("Windows Live Messenger", "",@SW_HIDE )
  Else
   WinSetState("Windows Live Messenger", "",@SW_SHOW )
EndIf

when the msn is showed then i run the script it hide it 

and after it hide it if i re start the script it will not show it

any ideas ?

Link to comment
Share on other sites

Shouldn't it be

If WinGetState("Windows Live Messenger") = ...
Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

thanks for replay guys 

i tried this

HotKeySet("!x", "msn")
Func msn()
If WinGetState("Windows Live Messenger", "") = 15 Then WinSetState("Windows Live Messenger", "",@SW_HIDE)
If WinGetState("Windows Live Messenger", "") = 5 Then WinSetState("Windows Live Messenger", "",@SW_SHOW)
EndFunc

While 1
Sleep(1000)
WEnd

 

it is working only when i press alt x when msn is active how can i make it hide msn even if i'am using another program ?

Edited by Alexxander

Link to comment
Share on other sites

  • Solution

$isHidden = False
HotKeySet("!x", "msn")

Func msn()
    If $isHidden Then
        $isHidden = False
        WinSetState("Calculator", "",@SW_SHOW)
    Else
        $isHidden = True
        WinSetState("Calculator", "",@SW_HIDE)
    EndIf
EndFunc

While 1
    Sleep(1000)
WEnd

I tested that with Calculator and it works  :bye:

Maybe you'd also want to do an WinActivate to bring it to front.

Edited by Inverted
Link to comment
Share on other sites

$isHidden = False
HotKeySet("!x", "msn")

Func msn()
    If $isHidden Then
        $isHidden = False
        WinSetState("Calculator", "",@SW_SHOW)
    Else
        $isHidden = True
        WinSetState("Calculator", "",@SW_HIDE)
    EndIf
EndFunc

While 1
    Sleep(1000)
WEnd

I tested that with Calculator and it works  :bye:

Maybe you'd also want to do an WinActivate to bring it to front.

 

interesting ...

what is $isHidden i searched for it in the help doc i couldn't find it 

may u explain ?

Link to comment
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
 Share

  • Recently Browsing   0 members

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