Jump to content

reload the same script


Recommended Posts

  • Developers

OK ... get it ...  You can't even be bothered to type more than OK...    whatever.

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

@Deye

This one need to hold In a specific class (notepad)

 

#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("blind", 100, 100, @DesktopWidth - (700 + 100), @DesktopHeight - (700 + 100), -1, $WS_EX_TOOLWINDOW)
    GUISetOnEvent($GUI_EVENT_CLOSE, 'close')

    $button1 = GUICtrlCreateButton("show", 5, 65, 40, 20)
    GUICtrlSetOnEvent(-1, "show_Button")

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

    DllCall("user32.dll", "", "", "hwnd", $gui, "", "", "", "") ; 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}", "callscript")
EndFunc   ;==>_Main

_Main()

Func close()
    Exit
EndFunc   ;==>close

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

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 callscript()
    WinActivate($gui)
EndFunc   ;==>callscript
Link to comment
Share on other sites

This will be my last edit for this script!. So, I'm done with it for any further requests.
Hope it serves you well this time, Good luck ..

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

HotKeySet("{END}", "callWindow")
Global $gui, $FGW, $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)

Global $hEventProc, $hEventHook
_HookEvents()
OnAutoItExitRegister('OnAutoItExit')
GUISetState()

While 1
    Switch GUIGetMsg()
        Case $GUI_EVENT_CLOSE
            Exit
        Case $button1
            If $Pause = False Then
                $Pause = True
                GUICtrlSetData($button1, "run")
                _UnhookEvents()
                WinSetOnTop($gui, "", 0)
            Else
                $Pause = False
                GUICtrlSetData($button1, "stop")
                _HookEvents()
            EndIf
    EndSwitch
    If $Pause = False Then
        If HWnd($FGW) And BitAND(WinGetState($FGW), 8) Then
            If _IsPressed("01", $hDLL) Then
                While _IsPressed("01", $hDLL)
                    Sleep(250)
                WEnd
                Flash()
            EndIf
        EndIf
    EndIf
    Sleep(30)
WEnd

Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime)
    #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime
    Switch $iEvent
        Case $EVENT_SYSTEM_FOREGROUND
            Return _Show($hWnd)
    EndSwitch
EndFunc   ;==>_EventProc

Func _Show($hWnd)
    If $hWnd = $gui Then Return
    If _WinAPI_GetClassName($hWnd) = "notepad" Then
        _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
        $FGW = $hWnd
        _UnhookEvents()
        AdlibRegister("isWindow", 3000)
        Return
    EndIf
EndFunc   ;==>_Show

Func isWindow()
    If Not BitAND(WinGetState($FGW), 1) Then
        AdlibUnRegister("isWindow")
        _HookEvents()
    EndIf
EndFunc   ;==>isWindow

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

Func _HookEvents()
    $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword')
    $hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_FOREGROUND, $EVENT_SYSTEM_FOREGROUND, DllCallbackGetPtr($hEventProc), $WINEVENT_OUTOFCONTEXT)
EndFunc   ;==>_HookEvents

Func _UnhookEvents()
    AdlibUnRegister("isWindow")
    _WinAPI_UnhookWinEvent($hEventHook)
    DllCallbackFree($hEventProc)
EndFunc   ;==>_UnhookEvents

Func OnAutoItExit()
    _UnhookEvents()
EndFunc   ;==>OnAutoItExit

Func Flash()
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_NOZORDER, $SWP_HIDEWINDOW))
    Sleep(300)
;~  If BitAND(WinGetState($FGW), 8) Then
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_NOZORDER, $SWP_SHOWWINDOW))
;~  Else
;~      _HookEvents()
;~  EndIf
EndFunc   ;==>Flash

 

Edited by Deye
WinEventHook change
Link to comment
Share on other sites

ok...Should I have a problem with my pc! 

autoit v3 script has stopped workind (I opened the script and gave it there)

 

My OS is 32bits in a processor 64... 

is there any problem?

@Deye

Edited by PeterOctavio
Stop quoting whole posts and typing your answer in them please!
Link to comment
Share on other sites

ok...Should I have a problem with my pc!  @Deye

autoit v3 script has stopped workind (I opened the script and gave it there)

My OS is 32bits in a processor 64... 

is there any problem?

 

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

HotKeySet("{END}", "callWindow")
Global $gui, $FGW, $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)

Global $hEventProc, $hEventHook
_HookEvents()
OnAutoItExitRegister('OnAutoItExit')
GUISetState()

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

Func _EventProc($hEventHook, $iEvent, $hWnd, $iObjectID, $iChildID, $iThreadId, $iEventTime)
    #forceref $hEventHook, $iObjectID, $iChildID, $iThreadId, $iEventTime
    Switch $iEvent
        Case $EVENT_SYSTEM_FOREGROUND
            AdlibUnRegister("Click")
            Return _Show($hWnd)
        Case $EVENT_SYSTEM_MINIMIZEEND
            AdlibUnRegister("Click")
            Return _Show($hWnd)
    EndSwitch
EndFunc   ;==>_EventProc

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($hWnd)
    If $hWnd = $gui Then Return
    If _WinAPI_GetClassName($hWnd) = "notepad"  Then
        _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
        $FGW = $hWnd
        _UnhookEvents()
        AdlibRegister("Click", 100)
        Return
    EndIf
    Return _Hide()
EndFunc   ;==>_Show

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

Func _HookEvents()
    $hEventProc = DllCallbackRegister('_EventProc', 'none', 'ptr;dword;hwnd;long;long;dword;dword')
    $hEventHook = _WinAPI_SetWinEventHook($EVENT_SYSTEM_FOREGROUND, $EVENT_SYSTEM_MINIMIZEEND, DllCallbackGetPtr($hEventProc), $WINEVENT_OUTOFCONTEXT)
EndFunc   ;==>_HookEvents

Func _UnhookEvents()
    _WinAPI_UnhookWinEvent($hEventHook)
    DllCallbackFree($hEventProc)
    AdlibUnRegister("Click")
EndFunc   ;==>_UnhookEvents

Func OnAutoItExit()
    _UnhookEvents()
EndFunc   ;==>OnAutoItExit

Func Click()
    If BitAND(WinGetState($FGW), 8) Then
        If _IsPressed("01", $hDLL) Then
            While _IsPressed("01", $hDLL)
                Sleep(100)
            WEnd
            Flash()
        EndIf
    EndIf
EndFunc   ;==>Click

Func Flash()
    _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_NOZORDER, $SWP_HIDEWINDOW))
    Sleep(300)
    If BitAND(WinGetState($FGW), 8) Then
        _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_NOZORDER, $SWP_SHOWWINDOW))
    EndIf
EndFunc   ;==>Flash

 

Link to comment
Share on other sites

What happens if you change the Click function with this one, does it still crash 

Func Click()
    If BitAND(WinGetState($FGW), 8) Then
        If _IsPressed("01", $hDLL) Then
            While _IsPressed("01", $hDLL)
                Sleep(100)
            WEnd
            Flash()
        EndIf
    EndIf
    Sleep(100)
EndFunc   ;==>Click

 

Edited by Deye
Link to comment
Share on other sites

Has an error here, do not need to have that time (3000), just have to have the script follow the class.

I confused you saying that the script has to verify in 3 seconds if the class is active, when in fact, just being executed

@Deye

Func _Show($hWnd)
    If $hWnd = $gui Then Return
    If _WinAPI_GetClassName($hWnd) = "notepad" Then
        _WinAPI_SetWindowPos($gui, $HWND_TOPMOST, 0, 0, 0, 0, BitOR($SWP_FRAMECHANGED, $SWP_NOMOVE, $SWP_NOSIZE, $SWP_NOACTIVATE, $SWP_SHOWWINDOW))
        $FGW = $hWnd
        _UnhookEvents()
        AdlibRegister("isWindow", 3000)
        Return
    EndIf
EndFunc   ;==>_Show
Edited by PeterOctavio
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...