Sign in to follow this  
Followers 0
will88

a little help with winsetstate() - @SW_Show

3 posts in this topic

#1 ·  Posted (edited)

HotkeySet("{F1}", "Start") 
HotkeySet("{F2}", "Stop") 
HotkeySet("{F3}", "Hide")
HotkeySet("{F4}", "Show")
Global $Loop = 1
While 1 
If $Loop = 1 Then 
sleep(random(500, 1000))
If $Loop = 1 Then 
Sleep(1000) 
Else 
ExitLoop 
EndIf 
EndIF
WEnd 



Func Start() 
$Loop = 1 
EndFunc 
Func Stop() 
$Loop = 0
EndFunc

Func Show() 
If Not Winactive( "Untitled - Notepad" )Then
WinSetState( "Untitled - Notepad", "", @SW_Show )
EndIf
EndFunc

Func Hide()
If WinActive( "Untitled - Notepad" ) Then
WinSetState( "Untitled - Notepad", "", @SW_Hide )
EndIf
EndFunc

When I press f3 to minimize Untitled - Notepad it dissapeers like It should. When I press f4 to bring it up again it doesent work.

Edited by will88

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Hi, slightly modified your code

HotkeySet("{ESC}", "Quit")
HotkeySet("{F3}", "Hide")
HotkeySet("{F4}", "Show")

Global $hWnd = WinGetHandle("Untitled - Notepad")

While 1
    Sleep(100)
WEnd

Func Quit()
    Show()
    Exit
EndFunc 

Func Show()
    If WinExists($hWnd) And Not BitAnd(WinGetState($hWnd), 2) Then WinSetState($hWnd, "", @SW_SHOW)
EndFunc

Func Hide()
    If WinExists($hWnd) And BitAnd(WinGetState($hWnd), 2) Then WinSetState($hWnd, "", @SW_HIDE)
EndFunc

Cheers

Edited by smashly

Share this post


Link to post
Share on other sites

Hi, slightly modified your code

HotkeySet("{ESC}", "Quit")
HotkeySet("{F3}", "Hide")
HotkeySet("{F4}", "Show")

Global $hWnd = WinGetHandle("Untitled - Notepad")

While 1
    Sleep(100)
WEnd

Func Quit()
    Show()
    Exit
EndFunc 

Func Show()
    If WinExists($hWnd) And Not BitAnd(WinGetState($hWnd), 2) Then WinSetState($hWnd, "", @SW_SHOW)
EndFunc

Func Hide()
    If WinExists($hWnd) And BitAnd(WinGetState($hWnd), 2) Then WinSetState($hWnd, "", @SW_HIDE)
EndFunc

Cheers

Ty!

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