Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Requires AutoHotkey v2
- #SingleInstance Force
- Persistent
- Run("notepad++")
- Sleep(1000)
- WinMaximize "A"
- while (!WinExist("ahk_exe notepad++.exe"))
- Sleep(3000)
- WinIds := []
- CurrWindow := WinGetID("ahk_exe notepad++.exe")
- WinSetStyle("-0xC00000", "ahk_exe notepad++.exe")
- WinIds.Push(CurrWindow)
- EVENT_OBJECT_LOCATIONCHANGE := 0x800B
- hook := WinEventHook(LocationChangeEventHandler, EVENT_OBJECT_LOCATIONCHANGE, EVENT_OBJECT_LOCATIONCHANGE, CurrWindow)
- LocationChangeEventHandler(hWinEventHook, event, hwnd, idObject, idChild, idEventThread, dwmsEventTime) {
- Critical -1
- idObject := idObject << 32 >> 32, idChild := idChild << 32 >> 32, event &= 0xFFFFFFFF, idEventThread &= 0xFFFFFFFF, dwmsEventTime &= 0xFFFFFFFF ; convert to INT/UINT
- InList := false
- for WinId in WinIds {
- InList := (WinId = Hwnd) ? true : InList
- }
- if (!InList) {
- return
- }
- if (WinGetMinMax(Hwnd) = 1) {
- WinGetPos(&X, &Y, &Width, &Height, Hwnd)
- WinGetPos(&TaskbarX, &TaskbarY, &TaskbarW, &TaskbarH, "ahk_class Shell_TrayWnd")
- WinRestore(Hwnd)
- WinMove(X, Y, Width, Height - TaskBarH, Hwnd)
- }
- return
- }
- class WinEventHook {
- __New(callback, eventMin?, eventMax?, winTitle := 0, PID := 0, skipOwnProcess := false) {
- if !HasMethod(callback)
- throw ValueError("The callback argument must be a function", -1)
- if !IsSet(eventMin)
- eventMin := 0x00000001, eventMax := IsSet(eventMax) ? eventMax : 0x7fffffff
- else if !IsSet(eventMax)
- eventMax := eventMin
- this.callback := callback, this.winTitle := winTitle, this.flags := skipOwnProcess ? 2 : 0, this.eventMin := eventMin, this.eventMax := eventMax, this.threadId := 0
- if winTitle != 0 {
- if !(this.winTitle := WinExist(winTitle))
- throw TargetError("Window not found", -1)
- this.threadId := DllCall("GetWindowThreadProcessId", "Int", this.winTitle, "UInt*", &PID)
- }
- this.pCallback := CallbackCreate(callback, "C Fast", 7)
- , this.hHook := DllCall("SetWinEventHook", "UInt", eventMin, "UInt", eventMax, "Ptr", 0, "Ptr", this.pCallback, "UInt", this.PID := PID, "UInt", this.threadId, "UInt", this.flags)
- }
- Stop() => this.__Delete()
- __Delete() {
- if (this.pCallback)
- DllCall("UnhookWinEvent", "Ptr", this.hHook), CallbackFree(this.pCallback), this.hHook := 0, this.pCallback := 0
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement