Jump to content

reload the same script


Recommended Posts

MADE BY DEYE...

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Local $hDLL = DllOpen("user32.dll")
Local $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), $WS_POPUP, $WS_EX_TOOLWINDOW)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
    If _IsPressed("01", $hDLL) Then ;Left mouse click
        _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))
        While _IsPressed("01", $hDLL)
            Sleep(3000)
        WEnd
        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
        _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
    EndIf
    Sleep(10)
WEnd

 

MADE BY JEFRY...

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>

Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)

    $button1 = GUICtrlCreateButton("fresh", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button2")

    ; disable close button
    $hMenu = _GUICtrlMenu_GetSystemMenu($gui)
    _GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, False)


    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()
EndFunc

_Main()

Func button2()
       Exit
EndFunc

Func button1()
    GUISetState(@SW_HIDE, $gui)
    Sleep(500)
    GUISetState(@SW_SHOW, $gui)
EndFunc


While 1
    Sleep(10)
WEnd

 

Hahaha now how I put it together? In the place of the fresh button it can be the stop button (to be in standbay, but always in the top, and the second button can disappear!

Link to comment
Share on other sites

How does this work for you 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $gui, $Pause = False ,$hDLL = DllOpen("user32.dll")

_Main()

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    $button1 = GUICtrlCreateButton("Pause", 10, 65, 50, 20)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $button1
                If $Pause = False Then
                    $Pause = True
                    GUICtrlSetData($button1, "Hide")
                    WinSetOnTop($gui, "", 1)
                Else
                    $Pause = False
                    GUICtrlSetData($button1, "Pause")
                    WinSetOnTop($gui, "", 0)
                EndIf
        EndSwitch
        If _IsPressed("01", $hDLL) Then ;Left mouse click
        If $Pause = False Then
            If $gui <> _WinAPI_GetForegroundWindow() Then
                _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))
                    While _IsPressed("01", $hDLL)
                        Sleep(10)
                    WEnd
                    Sleep(3000)
                    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
                    _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
                EndIf
            EndIf
        EndIf
        Sleep(30)
    WEnd
EndFunc   ;==>_Main

 

Edited by Deye
Link to comment
Share on other sites

Let's by steps, how do I make the close button work in this one? (I'm talking about the "x" of the title bar)

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>


Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)

    $button1 = GUICtrlCreateButton("stop", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button2")

    ; disable close button
    $hMenu = _GUICtrlMenu_GetSystemMenu($gui)
    _GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, 0)


    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()

EndFunc

_Main()

Func button2()
       Exit
EndFunc

Func button1()
    GUISetState(@SW_HIDE, $gui)
    Sleep(5000) ; 5000 miliseconds = 5 secs
    GUISetState(@SW_SHOW, $gui)
EndFunc


While 1
    Sleep(10)
WEnd

Link to comment
Share on other sites

Hi,

Please try to explain if full what is it you really need in your own language then use a https://translate.google.com/ to convert to English

Autoit uses 2 ways to capture Gui events 
One is GUIOnEventMode and the one I used is GUIGetMsg() in the while loop, and you shouldn't\cannot use both in one script, look here https://www.autoitscript.com/autoit3/docs/guiref/GUIRef_OnEventMode.htm

Link to comment
Share on other sites

50 minutes ago, PeterOctavio said:

how do I make the close button work in this one? (I'm talking about the "x" of the title bar)

You need to remove the code that disabled it and add an event for the close

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>


Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'button2')

    $button1 = GUICtrlCreateButton("stop", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button2")

    ; disable close button
;~     $hMenu = _GUICtrlMenu_GetSystemMenu($gui)
;~     _GUICtrlMenu_EnableMenuItem($hMenu, $SC_CLOSE, $MF_GRAYED, 0)


    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()

EndFunc

_Main()

Func button2()
       Exit
EndFunc

Func button1()
    GUISetState(@SW_HIDE, $gui)
    Sleep(5000) ; 5000 miliseconds = 5 secs
    GUISetState(@SW_SHOW, $gui)
EndFunc


While 1
    Sleep(10)
WEnd

 

Link to comment
Share on other sites

Ok, next step!!!

REPLACE THE OFF BUTTON BY THE PAUSE BUTTON

(WHEN PAUSE IS ACTIVATED, THE BUTTON FRESH SHOULD NOT WORK, AND THE WINDOW MUST LOSE THE WINSETONTOP CHARACTERISTIC, BECOMING A NORMAL WINDOW)

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>

Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'button2')

    $button1 = GUICtrlCreateButton("FRESH", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20) ;REPLACE BY PAUSE (BECOME THIS SCRIPT, INACTIVE OR STANDBAY)
    GUICtrlSetOnEvent(-1, "Button2")

    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()

EndFunc

_Main()

Func button2()
       Exit
EndFunc

Func button1()
    GUISetState(@SW_HIDE, $gui)
    Sleep(500) ;SHORT BLINK
    GUISetState(@SW_SHOW, $gui)
EndFunc


While 1
    Sleep(10)
WEnd

Link to comment
Share on other sites

1 hour ago, Deye said:

Hi,

Please try to explain if full what is it you really need in your own language then use a https://translate.google.com/ to convert to English

Autoit uses 2 ways to capture Gui events 
One is GUIOnEventMode and the one I used is GUIGetMsg() in the while loop, and you shouldn't\cannot use both in one script, look here https://www.autoitscript.com/autoit3/docs/guiref/GUIRef_OnEventMode.htm

In this one, when pause is triggered, the script should minimize, or become standbay

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $gui, $Pause = False ,$hDLL = DllOpen("user32.dll")

_Main()

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    $button1 = GUICtrlCreateButton("Pause", 10, 65, 50, 20)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
    GUISetState()
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $button1
                If $Pause = False Then
                    $Pause = True
                    GUICtrlSetData($button1, "Hide")
                    WinSetOnTop($gui, "", 1) ;i changed here for 0
                Else
                    $Pause = False
                    GUICtrlSetData($button1, "Pause")
                    WinSetOnTop($gui, "", 0) ;and i changed here for 1 and work, but when hide is activated, the blink behavior, dont work perfect
                EndIf
        EndSwitch
        If _IsPressed("01", $hDLL) Then ;Left mouse click ;something wrong here, i dont need this part, just when window transitions happen
        If $Pause = False Then
            If $gui <> _WinAPI_GetForegroundWindow() Then
                _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))
                    While _IsPressed("01", $hDLL)
                        Sleep(10)
                    WEnd
                    Sleep(500)
                    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
                    _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
                EndIf
            EndIf
        EndIf
        Sleep(30)
    WEnd
EndFunc   ;==>_Main

 

Edited by PeterOctavio
Link to comment
Share on other sites

Ok, next step!!!

REPLACE THE OFF BUTTON BY THE PAUSE BUTTON

(WHEN PAUSE IS ACTIVATED, THE BUTTON FRESH SHOULD NOT WORK, AND THE WINDOW MUST LOSE THE WINSETONTOP CHARACTERISTIC, BECOMING A NORMAL WINDOW)

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>

Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'button2')

    $button1 = GUICtrlCreateButton("FRESH", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20) ;REPLACE BY PAUSE (BECOME THIS SCRIPT, INACTIVE OR STANDBAY)
    GUICtrlSetOnEvent(-1, "Button2")

    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()

EndFunc

_Main()

Func button2()
       Exit
EndFunc

Func button1()
    GUISetState(@SW_HIDE, $gui)
    Sleep(500) ;SHORT BLINK
    GUISetState(@SW_SHOW, $gui)
EndFunc


While 1
    Sleep(10)
WEnd

Link to comment
Share on other sites

  • Developers

Maybe you need to slow down a little?
Please also use the Codeboxes for the code and less Special fonts/Bold/Caps and colors in your text. ;)

Jos 

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

When pause is clicked the window will be hidden, to show the window again you may click on the scripts tray item

#include <misc.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $gui, $Pause = False, $hDLL = DllOpen("user32.dll")

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)
;~ Opt("TrayIconHide", 1)

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
$button1 = GUICtrlCreateButton("Pause", 10, 65, 50, 20)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            If $Pause = False Then
                $Pause = True
                GUICtrlSetData($button1, "Hide")
                WinSetOnTop($gui, "", 1)
                _GUI_ToTray()
            Else
                $Pause = False
                GUICtrlSetData($button1, "Pause")
                WinSetOnTop($gui, "", 0)
                _Hide()
            EndIf
    EndSwitch
    If $Pause = False Then
        If _IsPressed("01", $hDLL) Then ;Left mouse click
            If $gui <> _WinAPI_GetForegroundWindow() Then _Hide()
        EndIf
    EndIf
    Sleep(30)
WEnd

Func _GUI_ToTray()
    GUISetState(@SW_HIDE, $gui)
    TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "_GUI_Restore")
    Opt("TrayIconHide", 0)
    Return $gui
EndFunc   ;==>_GUI_ToTray

Func _GUI_Restore()
    GUISetState(@SW_SHOW, $gui)
    WinActivate($gui)
    TraySetState(2)
;~  Opt("TrayIconHide", 1)
EndFunc   ;==>_GUI_Restore

Func _Hide()
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))
    While _IsPressed("01", $hDLL)
        Sleep(250)
    WEnd
    Sleep(3000)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
    _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
EndFunc   ;==>_Hide

 

Link to comment
Share on other sites

39 minutes ago, Deye said:

This one I finished, it's just a detail, I want to join the buttons 2 and 3 in one, when I click on one, switch to the other, same as you already did in a script above

And if the selected option is off, the run button be inactive

 

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>

Opt("GUIOnEventMode", 1)

Global $gui

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'close')

    $button1 = GUICtrlCreateButton("run", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Button1")

     $button2 = GUICtrlCreateButton("on", 50, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "button2")

     $button3 = GUICtrlCreateButton("Off", 50, 85, 60, 20)
    GUICtrlSetOnEvent(-1, "button3")

        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008); slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()
    hotkeyset ("{END}", "callwindow")
 EndFunc


_Main()

Func close()
       Exit
EndFunc

Func button1()
    GUISetState(@SW_HIDE, $gui)
    Sleep(500) ;SHORT BLINK
    GUISetState(@SW_SHOW, $gui)
EndFunc

Func button2()
    WinSetOnTop($gui, "", 1)
EndFunc

Func button3()
  WinSetOnTop($gui, "", 0)
EndFunc


While 1
    Sleep(10)
 WEnd

 func callwindow()
    WinActivate ("hidecard")
    EndFunc
 

Edited by PeterOctavio
Link to comment
Share on other sites

Ok, yours stayed like this, 

The interesting thing now was that when you activate the stop, it becomes more inactive still, because it notes that when you click on the icon of the system tray, you can choose not to use it, then it ends up on the screen ...

#include <misc.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $gui, $Pause = False, $hDLL = DllOpen("user32.dll")

Opt("TrayOnEventMode", 1)
Opt("TrayMenuMode", 1)
Opt("TrayAutoPause", 0)
;~ Opt("TrayIconHide", 1)

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
$button1 = GUICtrlCreateButton("stop", 10, 65, 50, 20)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            If $Pause = False Then
                $Pause = True
                GUICtrlSetData($button1, "run")
                WinSetOnTop($gui, "", 1)
                _GUI_ToTray()
            Else
                $Pause = False
                GUICtrlSetData($button1, "stop")
                WinSetOnTop($gui, "", 0)
                _Hide()
            EndIf
    EndSwitch
    If $Pause = False Then
        If _IsPressed("01", $hDLL) Then ;Left mouse click
            If $gui <> _WinAPI_GetForegroundWindow() Then _Hide()
        EndIf
    EndIf
    Sleep(30)
WEnd

Func _GUI_ToTray()
    GUISetState(@SW_HIDE, $gui)
    TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "_GUI_Restore")
    Opt("TrayIconHide", 0)
    Return $gui
EndFunc   ;==>_GUI_ToTray

Func _GUI_Restore()
    GUISetState(@SW_SHOW, $gui)
    WinActivate($gui)
    TraySetState(2)
;~  Opt("TrayIconHide", 1)
EndFunc   ;==>_GUI_Restore

Func _Hide()
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))
    While _IsPressed("01", $hDLL)
        Sleep(250)
    WEnd
    Sleep(300)
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
    _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
EndFunc   ;==>_Hide

Link to comment
Share on other sites

27 minutes ago, PeterOctavio said:

The interesting thing now was that when you activate the stop, it becomes more inactive still, because it notes that when you click on the icon of the system tray, you can choose not to use it, then it ends up on the screen ...

 you can do all sorts of things ,add tray menu commands .etc (interesting indeed ..) No rest for the wicked ;)

#include <misc.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <ButtonConstants.au3>
#include <GUIMenu.au3>

Opt("GUIOnEventMode", 1)

Global $gui, $button1, $button2

Func _Main()
    $gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'close')

    $button1 = GUICtrlCreateButton("Run", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "RunButton")

    $button2 = GUICtrlCreateButton("Off", 50, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "Off_button")

    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
    WinSetOnTop($gui, "", 1) ; it's better to use the window hwnd, it's safer and faster than using the window title
    TraySetState()
    GUISetState()
    HotKeySet("{END}", "callwindow")
EndFunc   ;==>_Main

_Main()

Func close()
    Exit
EndFunc   ;==>close

Func RunButton()
    GUISetState(@SW_HIDE, $gui)
    Sleep(500) ;SHORT BLINK
    GUISetState(@SW_SHOW, $gui)
EndFunc   ;==>RunButton

Func Off_button()
    WinSetOnTop($gui, "", 0)
    GUICtrlSetData($button2, "On")
    GUICtrlSetOnEvent($button2, "On_button")
    GUICtrlSetState($button1, $GUI_disable)
EndFunc   ;==>Off_button

Func On_button()
    WinSetOnTop($gui, "", 1)
    GUICtrlSetData($button2, "Off")
    GUICtrlSetOnEvent($button2, "Off_button")
    GUICtrlSetState($button1, $GUI_ENABLE)
EndFunc   ;==>On_button

While 1
    Sleep(10)
WEnd

Func callwindow()
    WinActivate($gui)
EndFunc   ;==>callwindow

 

Link to comment
Share on other sites

Now what you built... 

something wrong with the short blink ... it was not to trigger with any click...

For example, the notepad is minimized, when you maximize it passes the front of all screens right ... the function of this script is that when this happens, it passes the front of the notepad, with the winsetontop function only for the notepad window , That is, I will maximize two things at the same time

I have to put a standby time of 3 seconds as soon as notepad goes to top

#include <misc.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

Global $gui, $Pause = False, $hDLL = DllOpen("user32.dll")

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
$button1 = GUICtrlCreateButton("stop", 10, 65, 50, 20)
DllCall("user32.dll", "", "", "hwnd", $gui, "", , "","" ) ; slide-in
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            If $Pause = False Then
                $Pause = True
                GUICtrlSetData($button1, "run")

            Else
                $Pause = False
                GUICtrlSetData($button1, "stop")
                WinSetOnTop($gui, "", 0)

            EndIf
    EndSwitch
    If $Pause = False Then
        If _IsPressed("01", $hDLL) Then ;Left mouse click
            If $gui <> _WinAPI_GetForegroundWindow() Then _Hide()
        EndIf
    EndIf
    Sleep(30)
WEnd


Func _Hide()
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))

details:

>>>> Window <<<<
Title:    Untitled - Notepad
Class:    Notepad
Position:    545, 227
Size:    474, 369
Style:    0x14CF0000
ExStyle:    0x00000110
Handle:    0x00090404

>>>> Control <<<<
Class:    
Instance:    
ClassnameNN:    
Name:


    While _IsPressed("01", $hDLL)
        Sleep(250)
    WEnd
    Sleep(300)
    DllCall("user32.dll", "", "", "hwnd", $gui, "", "", "", "") ; slide-in
    _WinAPI_SetWindowPos($gui, $HWND_NOTOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
EndFunc   ;==>_Hide

 

 

Edited by PeterOctavio
Link to comment
Share on other sites

How does this works for you :

#include <misc.au3>
#include <Constants.au3>
#include <GuiConstantsEx.au3>
#include <WindowsConstants.au3>
#include <WinAPI.au3>

HotKeySet("{END}", "callwindow")

Global $gui, $FGW, $Pause = False

$gui = GUICreate("hidecard", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
$button1 = GUICtrlCreateButton("stop", 10, 65, 50, 20)

AdlibRegister("NotepadWindow", 1000)
OnAutoItExitRegister('_UnRegister')
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            If $Pause = False Then
                $Pause = True
                GUICtrlSetData($button1, "run")
                _UnRegister()
                WinSetOnTop($gui, "", 0)
            Else
                $Pause = False
                GUICtrlSetData($button1, "stop")
                AdlibRegister("NotepadWindow", 1000)
            EndIf
    EndSwitch
    Sleep(30)
WEnd

Func NotepadWindow()
    $FGW = _WinAPI_GetForegroundWindow()
    If $FGW = $gui Then Return
    If _WinAPI_GetClassName($FGW) = "Notepad" Then Return _Show()
    Return _Hide()
EndFunc   ;==>NotepadWindow

Func _Hide()
    If BitAND(WinGetState($gui), 2) Then _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_HIDEWINDOW))
EndFunc   ;==>_Hide

Func _Show()
    DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $gui, "int", 200, "long", 0x00040008) ; slide-in
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
EndFunc   ;==>_Show

Func _UnRegister()
    AdlibUnRegister("NotepadWindow")
EndFunc   ;==>_UnRegister

Func callwindow()
    _WinAPI_SetWindowPos($gui, $HWND_TOP, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_SHOWWINDOW))
    WinActivate($gui)
EndFunc   ;==>callwindow

 

Edited by Deye
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...