SinghIsKing Posted November 30, 2008 Share Posted November 30, 2008 (edited) hello, Please help me to short my code.Dim $Win_Names = "Win1" Opt("WinTitleMatchMode", 2) If WinExists($Win_Names, "") Then WinSetState($Win_Names, "", @SW_HIDE) MsgBox(64, "Title", "Press ok to show window.", 10) WinSetState($Win_Names, "", @SW_SHOW) MsgBox(64, "Title", "Press ok to Close the window.", 10) WinClose($Win_Names, "") EndIf Dim $Win_Names = "2nd" If WinExists($Win_Names, "") Then WinSetState($Win_Names, "", @SW_HIDE) MsgBox(64, "Title", "Press ok to show window.", 10) WinSetState($Win_Names, "", @SW_SHOW) MsgBox(64, "Title", "Press ok to Close the window.", 10) WinClose($Win_Names, "") EndIf Dim $Win_Names = "Third" If WinExists($Win_Names, "") Then WinSetState($Win_Names, "", @SW_HIDE) MsgBox(64, "Title", "Press ok to show window.", 10) WinSetState($Win_Names, "", @SW_SHOW) MsgBox(64, "Title", "Press ok to Close the window.", 10) WinClose($Win_Names, "") EndIfthere maybe some more window names. any trick to short my code and add new window names without writing the whole If...to...EndIf Script? Edited November 30, 2008 by SinghIsKing Link to comment Share on other sites More sharing options...
FireFox Posted November 30, 2008 Share Posted November 30, 2008 @Singhisking Hi, perhaps this is shorter: Opt("WinTitleMatchMode", 2) Global $Win_Names="First" _Showhide() Global $Win_Names="Second" _Showhide() Global $Win_Names="Third" _Showhide() Func _Showhide() If WinExists($Win_Names, "") Then WinSetState($Win_Names, "", @SW_HIDE) MsgBox(64, "Title", "Press ok to show window.", 10) WinSetState($Win_Names, "", @SW_SHOW) MsgBox(64, "Title", "Press ok to Close the window.", 10) WinClose($Win_Names, "") EndIf EndFunc Link to comment Share on other sites More sharing options...
SinghIsKing Posted November 30, 2008 Author Share Posted November 30, 2008 @Singhisking Hi, perhaps this is shorter: Opt("WinTitleMatchMode", 2) Global $Win_Names="First" _Showhide() Global $Win_Names="Second" _Showhide() Global $Win_Names="Third" _Showhide() Func _Showhide() If WinExists($Win_Names, "") Then WinSetState($Win_Names, "", @SW_HIDE) MsgBox(64, "Title", "Press ok to show window.", 10) WinSetState($Win_Names, "", @SW_SHOW) MsgBox(64, "Title", "Press ok to Close the window.", 10) WinClose($Win_Names, "") EndIf EndFuncoh! Yes, i can short my code using functions. thanksss can i also do it using RegExpTitle? reading the help file did not help. Link to comment Share on other sites More sharing options...
martin Posted November 30, 2008 Share Posted November 30, 2008 little bit shorter. Opt("WinTitleMatchMode", 2) _Showhide("First") _Showhide("Second") _Showhide("Third") Func _Showhide($Title) If WinExists($Title, "") Then WinSetState($Title, "", @SW_HIDE) MsgBox(64, "Title", "Press ok to show window.", 10) WinSetState($Title, "", @SW_SHOW) MsgBox(64, "Title", "Press ok to Close the window.", 10) WinClose($Title, "") EndIf EndFunc ;==>_Showhide I don't think that RegExpTitle will help in this script. Or do you want to detect a window which has "First" in the title? Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. 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