I need help with my script...
The WindowDrag Feature doesn't want to work, remains stuck on, which I would assume releasing L button should cease drag feature...
Here's my entire script...
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
#InstallKeybdHook
#InstallMouseHook
#SingleInstance force
; #KeyHistory, 0 = Disabled
#KeyHistory 100000
setKeyDelay, 50, 50
setMouseDelay, 50
SetWinDelay, -1
CoordMode, Mouse, Screen
/*
NOTE:
Seems that using "tilde" prior regular mouse-button events will retain mouse-button's drag feature
Not sure what the astericks does
EXAMPLE OF WAV-PLAY via various custom events
~*LButton::Soundplay, c:\Windows\Media\chimes.wav
~*RButton::Soundplay, c:\Windows\Media\chord.wav
~*MButton::Soundplay, c:\Windows\Media\tada.wav
*/
; ╔═════════════════════════════════════╗
; ════════════════════╣ USED SCRIPT VARIABLES & DEFINITIONS ╠════════════════════
; ╚═════════════════════════════════════╝
; ########################
; USED-IN SCRIPT VARIABLES
; ########################
WinTransparentHotkey := 0
TranslucentLevel := 255
WindowDragHotkey := 0
; ################################################
; ALL SCRIPT'S USED PROFILES VARIABLES/IDENTIFIERS
; ################################################
; VIRTUAL MOUSE PROFILES:
Profile := 1
ProfileName := ["DEFAULT", "MEDIA-VIDEO", "MEDIA-MUSIC", "SUPER MARIO", "PAINT.NET", "USB Sudoku"] ; "
; ╔════════════════════════════════════════╗
; ════════════════════╣ USED SCRIPT'S ICON & CUSTOM-MENU ITEMS ╠════════════════════
; ╚════════════════════════════════════════╝
; HOW TO ADD MINI OPENNED-MENU'S LOCATED-IN-LEFT-MARGIN ICONS
; -> Menu, MenuName, Icon, MenuItemName, FileName , IconNumber, IconWidth
; MENU START-POINT --->
Menu, Tray, NoStandard
Menu, Tray, Color, Gray
Menu, Tray, Icon, D:\Admin\Config\Icons\Hardware\ReDragonDarkLinesGreen.ico
Menu, Tray, Tip, ReDragon Final
Menu, AHKMenu, Add, Reload, _ReloadScript
Menu, AHKMenu, Add, Edit, _EditScript
Menu, AHKMenu, Add, ; ==========CHILD-SEPARATOR==========
Menu, AHKMore, Add, Open Lines, _OpenListLines
Menu, AHKMore, Add, Vars, _OpenListVars
Menu, AHKMore, Add, Hotkeys, _OpenListHotkeys
Menu, AHKMore, Add, Key History, _OpenKeyHistory
Menu, AHKMore, Add, ; ==========SUB-CHILD-SEPARATOR==========
Menu, AHKMore, Add, Help, _Help
Menu, AHKMore, Add, Window Spy, _WindowSpy
Menu, AHKMore, Add, Suspend Hotkeys, _SuspendScript
Menu, AHKMore, Add, Pause Script, _PauseScript
Menu, AHKMenu, Add, More, :AHKMore
Menu, AHKMenu, Add, ; ==========CHILD-SEPARATOR==========
Menu, AHKMenu, Add, Exit, _ExitScript
Menu, Tray, add, AHK Menu, :AHKMenu
; Menu, Tray, Add, ; ==========PARENT-SEPARATOR==========
; Menu, Tray, Add, Reload Script, _ReloadScript
; Menu, Tray, Add, Edit Script, _EditScript
Menu, Tray, Add ; ==========PARENT-SEPARATOR==========
Menu, Tray, Add, Profile: Show, _DisplayProfile
;Menu, SelectProfile, Add, Default, _SetProfile_Default
;Menu, SelectProfile, Add, Video, _SetProfile_MediaVideo
;Menu, SelectProfile, Add, Audio, _SetProfile_MediaAudio
;Menu, SelectProfile, Add, Mario, _SetProfile_SuperMario
;Menu, SelectProfile, Add, Paint.net, _SetProfile_PaintNet
;Menu, SelectProfile, Add, USB Sudoku, _SetProfile_USBSudoku
;Menu, Tray, Add, Profile: Select, :SelectProfile
Menu, Tray, Add, ; ==========PARENT-SEPARATOR==========
Menu, ThirdPartyDevApps, Add, Wiimote GlovePie, _LNK_GlovePie
Menu, ThirdPartyDevApps, Add, DS4Windows, _LNK_DS4Windows,
Menu, Tray, Add, Device Apps, :ThirdPartyDevApps
Menu, ControlPanel, Add, Classic Tray Icons, _LNK_ClassicTrayIcons
Menu, ControlPanel, Add, System Tray Icons, _LNK_SystemTrayIcons
Menu, ControlPanel, Add ; ------- Separator
Menu, ControlPanel, Add, Device Manager, _LNK_DeviceManager
Menu, ControlPanel, Add, Network Adapters, _LNK_Config_NetworkAdapters
Menu, ControlPanel, Add, Retro Bluetooth, _LNK_DeviceAndPrinters
Menu, ControlPanel, Add ; ------- Separator
Menu, ControlPanel, Add, Config Sound, _LNK_ConfigSound
Menu, ControlPanel, Add, Mouse Cursor, _MouseCursor
Menu, ControlPanel, Add ; ------- Separator
Menu, ControlPanel, Add, KBD Language, _KBRD_Layout_Switcher
Menu, ControlPanel, Add, Time Format, _LNK_TimeFormat
Menu, Tray, Add, System Panel, :ControlPanel
Menu, QuickLaunch, Add, AIMP, _LNK_Media_Aimp
Menu, Tray, Add, ; ==========PARENT-SEPARATOR==========
Menu, Tray, Add, Quick Apps, :QuickLaunch
Menu, Tray, Add,
Menu, Tray, Add, Clickable On, _ClickThroughOff
Menu, Tray, Click, 1
; <--- MENU END-POINT
RETURN
*/
; ╔══════════════════════════╗
; ════════════════════╣ AHK'S CONTEXT-MENU ITEMS ╠════════════════════
; ╚══════════════════════════╝
; ###########################
; DEFAULT CUSTOM-MENU ENTRIES
; ###########################
; AHK DEFAULT CONTEXT-MENU ITEMS START-POINT
_OpenListLines:
listlines
RETURN
_OpenListVars:
listvars
RETURN
_OpenListHotkeys:
listhotkeys
RETURN
_OpenKeyHistory:
KeyHistory
RETURN
_Help:
run, "C:\Program Files\AutoHotkey\v1.1.37.01\AutoHotkey.chm"
RETURN
;------------------------------------------
_WindowSpy:
run, "C:\Program Files\AutoHotkey\UX\WindowSpy.ahk"
RETURN
_ReloadScript:
Reload
RETURN
_EditScript:
Edit
RETURN
;----------------------------------------
_SuspendScript:
Suspend
RETURN
_PauseScript:
Pause
RETURN
_ExitScript:
ExitApp
RETURN
; AHK DEFAULT CONTEXT-MENU ITEMS END-POINT
; ###########################
; CUSTOM CONTEXT-MENU ENTRIES
; ###########################
_MouseCursor:
Run, D:\AHK\WIN-CTRLPNL\Mouse_Cursor-Style.lnk
RETURN
_LNK_TimeFormat:
Run, D:\Admin\Config\AutoHOTKEY\External Reliant\SystemShortcuts\TimeFormat.lnk
RETURN
_LNK_Config_NetworkAdapters:
Run, D:\Admin\Config\AutoHOTKEY\External Reliant\SystemShortcuts\Config-NetworkAdapters.lnk
RETURN
_LNK_ConfigSound:
Run, D:\Admin\Config\AutoHOTKEY\External Reliant\SystemShortcuts\Config-Sound.lnk
RETURN
_LNK_DeviceManager:
Run, D:\Admin\Config\AutoHOTKEY\External Reliant\SystemShortcuts\DeviceManager.lnk
RETURN
_LNK_DeviceAndPrinters:
Run, D:\Admin\Config\AutoHOTKEY\External Reliant\SystemShortcuts\Devices+Printers.lnk
RETURN
_LNK_ClassicTrayIcons:
Run, D:\Admin\Config\AutoHOTKEY\External Reliant\SystemShortcuts\ModernTrayIcons.lnk
RETURN
; THIRD PARTY DEVICE APPS START-POINT
_LNK_DS4Windows:
Run, D:\Admin\Config\Devices & Hardware\Dualshock 4 PC\DS4Windows Gaming\DS4Windows.exe
RETURN
_LNK_GlovePie:
Run, D:\Admin\Config\Devices & Hardware\GlovePIE\GlovePIE-0.46\PIEFree.exe
RETURN
; THIRD PARTY DEVICE APPS END-POINT
; QUICKLAUNCH START-POINT
_LNK_Media_Aimp:
Run, D:\Admin\Portable\Other Apps\AIMP\AIMP\AIMP.exe
RETURN
; QUICKLAUNCH END-POINT
_LNK_SystemTrayIcons:
run, D:\Admin\Config\AutoHOTKEY\SCRIPTS\.exe's\OS\SystemTrayIcons.lnk
RETURN
; ╔═════════════════╗
; ════════════════════╣ CHANGE PROFILES ╠════════════════════
; ╚═════════════════╝
ChangeProfile:
Profile := Profile = ProfileName.Count() ? 1 : Profile + 1
Gosub, _DisplayProfile
RETURN
_DisplayProfile:
If profile = 1
Gosub, _SplashImg_Profile_Default
Else if profile = 2
Gosub, _SplashImg_Profile_MediaVideo
Else if profile = 3
Gosub, _SplashImg_Profile_MediaAudio
Else if profile = 4
Gosub, _SplashImg_Profile_SuperMario
Else if profile = 5
Gosub, _SplashImg_Profile_PaintNet
Else if profile = 6
Gosub, _SplashImg_Profile_USBSUDOKU
Return
; Gosub, DisplayProfile
RETURN
_SplashSleep: ; concurrently apply splash sleep-timer configuration to all splash images.
Sleep 400
RETURN
_SplashImg_Profile_Default:
SplashImage, D:\Admin\Config\AutoHOTKEY\PROFILES\POPUPS\Default.png, b x1470 y850
Gosub, _SplashSleep
SplashImage, Off
RETURN
_SplashImg_Profile_MediaVideo:
SplashImage, D:\Admin\Config\AutoHOTKEY\PROFILES\POPUPS\MP4;MPC-HC.png, b x1470 y850
Gosub, _SplashSleep
SplashImage, Off
RETURN
_SplashImg_Profile_MediaAudio:
SplashImage, D:\Admin\Config\AutoHOTKEY\PROFILES\POPUPS\MP3;Aimp.png, b x1470 y850
Gosub, _SplashSleep
SplashImage, Off
RETURN
_SplashImg_Profile_SuperMario:
SplashImage, D:\Admin\Config\AutoHOTKEY\PROFILES\POPUPS\MP3;SPC-Play.png, b x1470 y850
Gosub, _SplashSleep
SplashImage, Off
RETURN
_SplashImg_Profile_PaintNet:
SplashImage, D:\Admin\Config\AutoHOTKEY\PROFILES\POPUPS\IMG;PAINT.NET.png, b x1470 y850
Gosub, _SplashSleep
SplashImage, Off
RETURN
_SplashImg_Profile_USBSUDOKU:
SplashImage, D:\Admin\Config\AutoHOTKEY\PROFILES\POPUPS\USB;SUDOKU.png, b x1470 y850
Gosub, _SplashSleep
SplashImage, Off
RETURN
; ╔═══════════════════════════╗
; ════════════════════╣ IMPORTED/MODIFIED SCRIPTS ╠════════════════════
; ╚═══════════════════════════╝
; ######################################
; ALWAYS ON TOP - TOP-LEFT SQUARE IDENTIFIER
; ######################################
_AlwaysOnTopBorder:
SetTimer, CheckBorder, 25, -10
Id := WinActive("A"), t := 5 ; t = border thickness
WinGet, ExStyle, ExStyle, ahk_id %Id%
if (ExStyle & 0x8)
{
WinSet, AlwaysOnTop, Off, ahk_id %Id%
WinClose,% "ahk_id " Red%ID%
WinIDs := StrReplace(WinIDs, "," ID), Red%ID% := ""
Return
}
WinSet, AlwaysOnTop, On , ahk_id %Id%
MakeBorder:
WinGetpos, x, y, w, h, ahk_id %Id%
Gui, New, +ToolWindow -Caption +LastFound +AlwaysOnTop +E0x20 +HwndRed
Gui, Color, Red
WinSet, Region,% "0-0 "w "-0 "w "-"h " 0-"h " 0-0 "t "-"t " "w-t "-"t " "w-t "-"h-t " "t "-"h-t " "t "-"t
; Gui, Show, x%x% y%y% w%w% h%h% NoActivate ; CREATES BORDER AROUND WINDOW
Gui, Show, x%x% y%y% w4 h4 NoActivate ; CREATES RED-LINE FLUSH AT TOP/ABOVE WINDOW
Red%ID% := Red, Pos%ID% := x y w h, WinIDs .= "," ID
RETURN
CheckBorder:
DetectHiddenWindows, On
Loop, Parse, WinIDs, CSV
{
IF !ID := A_LoopField
Continue
IF !WinExist("ahk_id " ID)
{
WinClose,% "ahk_id " Red%ID%
WinIDs := StrReplace(WinIDs, "," ID), Red%ID% := ""
Break
}
WinGetpos, x, y, w, h, ahk_id %ID%
IF (x y w h) = Pos%ID%
Continue
WinClose,% "ahk_id " Red%ID%
WinIDs := StrReplace(WinIDs, "," ID), Red%ID% := ""
Goto, MakeBorder
}
RETURN
; ###################################
; CLICK THROUGH ANY WINDOW SCRIPT
; ###################################
_ClickThroughOn:
counter++
MouseGetPos, x, y, hwnd%counter%
WinSet, ExStyle, +0x00000020, % "ahk_id " hwnd%counter%
RETURN
_ClickThroughOff:
Loop, %counter%
WinSet, ExStyle, -0x00000020, % "ahk_id " hwnd%A_Index%
counter:=0 ; reset counter
KeyWait, RShift
Send {RShift}
RETURN
; #############################################
; WITHIN WINDOW VICINITY DRAG/NO TITLEBAR LIMIT
; #############################################
_WindowDragOn:
MouseGetPos, MX1, MY1, WinID
WinExist("ahk_id " . WinID)
WinGetPos, WX, WY
While _WindowDragHotkey = 1
{
MouseGetPos, MX2, MY2
If (MX1 <> MX2) || (MY1 <> MY2)
{
WX += MX2 - MX1
WY += MY2 - MY1
WinMove, WX, WY
MX1 := MX2
MY1 := MY2
}
}
Return
RETURN
_WindowDragOff:
WindowDragHotkey = 0
RETURN
; ###############################
; WINDOW TRANSPARENCY/TRANSLUCENT
; ###############################
_WinTransparentUp:
DetectHiddenWindows, on
WinGet, curtrans, Transparent, A
if ! curtrans
curtrans = 255
newtrans := curtrans + 16
if newtrans > 0
{
WinSet, Transparent, %newtrans%, A
}
else
{
WinSet, Transparent, OFF, A
WinSet, Transparent, 255, A
}
return
RETURN
_WinTransparentDown:
DetectHiddenWindows, on
WinGet, curtrans, Transparent, A
if ! curtrans
curtrans = 255
newtrans := curtrans - 16
if newtrans > 0
{
WinSet, Transparent, %newtrans%, A
}
return
RETURN
; ########################
; KEYBOARD LAYOUT SWITCHER
; ########################
_KBRD_Layout_Switcher:
ControlGet, hClock, hwnd,, InputIndicatorButton1, ahk_class Shell_TrayWnd
accClock := AccObjectFromWindow(hClock, OBJID_CLIENT := 0xFFFFFFFC)
accClock.accDoDefaultAction(0)
AccObjectFromWindow(hWnd, idObject = 0) {
static IID_IDispatch := "{00020400-0000-0000-C000-000000000046}"
, IID_IAccessible := "{618736E0-3C3D-11CF-810C-00AA00389B71}"
, OBJID_NATIVEOM := 0xFFFFFFF0, VT_DISPATCH := 9, F_OWNVALUE := 1
, h := DllCall("LoadLibrary", "Str", "oleacc", "Ptr")
VarSetCapacity(IID, 16), idObject &= 0xFFFFFFFF
DllCall("ole32\CLSIDFromString", "Str", idObject = OBJID_NATIVEOM ? IID_IDispatch : IID_IAccessible, "Ptr", &IID)
if DllCall("oleacc\AccessibleObjectFromWindow", "Ptr", hWnd, "UInt", idObject, "Ptr", &IID, "PtrP", pAcc) = 0
Return ComObject(VT_DISPATCH, pAcc, F_OWNVALUE)
}
RETURN
; ╔══════════════════════════════════╗
; ════════════════════╣ UNIVERSAL MOUSE/KEYBOARD CONFIGS ╠════════════════════
; ╚══════════════════════════════════╝
; #########################################
; KEYCHRON KEYBOARD, F1 to F12 Manual Remap
; #########################################
; ReDragon Mouse doesn't support F13-toF24 (it does however support Browser_ and Launch_ but I didn't botherwith those)
; Thus, I assigned F1-toF12 to Mouse's 12x custom buttons/Launch_App1 for the top custom bottom
; Having a Keychron Keyboard, reprogrammed Keyboard'S F1-to-F12 as F13-to-F24 instead.
; This "seamlessly" disables mouse's single-button press, by sending a null-ouput key (help)
F1::HELP
F2::HELP
F3::HELP
F4::HELP
F5::HELP
F6::HELP
F7::HELP
F8::HELP
F9::HELP
F10::HELP
F11::HELP
F12::HELP
; This re-enables keyboard's F1-to-F12
F13::F1
F14::F2
F15::F3
F16::F4
F17::F5
F18::F6
F19::F7
F20::F8
F21::F9
F22::F10
F23::F11
F24::F12
; ########################
; UNIVERSAL ADDED FEATURES
; ########################
; DRAG FROM ANYWHERE
; TRANSPARENT (WHEEL)
; ALWAYS ON TOP
; CLICKTHROUGH (WHEEL)
Launch_App1 & WheelUp::Gosub, _WinTransparentUp
Launch_App1 & WheelDown::Gosub, _WinTransparentDown
Launch_App1 & LButton::Gosub, _AlwaysOntopBorder
Launch_App1 & RButton::Gosub, _ClickThroughOn
~RButton & Launch_App1::Gosub, _ClickThroughOff
~LButton & Launch_App1::
_WindowDragHotkey = 1
Gosub _WindowDragOn
RETURN
~LButton Up::
WindowDragHotkey = 0
RETURN
; ╔══════════════════════╗
; ════════════════════╣ APP'S PROFILE GOSUBS ╠════════════════════
; ╚══════════════════════╝
; ###############################
; PER-APP'S PROFILE ACTION GOSUBS
; ###############################
; ##################################
; MEDIA PLAYER CLASSIC - HOME CINEMA
; ##################################
_MPC_PlayPause:
Send {Space}
RETURN
_KBRD_PlayPause:
Send Media_Play_Pause
RETURN
_MPC_Step_Backwards:
Send {Ctrl Down}{Left}{Ctrl Up}
RETURN
_MPC_Step_Forward:
Send {Ctrl Down}{Right}{Ctrl Up}
RETURN
_MPC_Seek_Backwards:
Send {Left}
RETURN
_MPC_Seek_Forward:
Send {Right}
RETURN
_MPC_Audio_Prev:
Send {LShift Down}{a}{LShift Up}
RETURN
_MPC_Audio_Next:
Send {a}
RETURN
_MPC_Chap_Prev:
Send {PgUp}
RETURN
_MPC_Chap_Next:
Send {PgDn}
RETURN
_MPC_VidFrame_ZoomIn:
Send {Numpad9 8}
RETURN
_MPC_VidFrame_ZoomOut:
Send {Numpad1 8}
RETURN
_MPC_VidFrame_Reset:
Send {Numpad5}
RETURN
_MPC_VidFrame_MoveUp:
Send {LCtrl Down}{Numpad8 3}{LCtrl Up}
RETURN
_MPC_VidFrame_MoveDown:
Send {LCtrl Down}{Numpad2 3}{LCtrl Up}
RETURN
_MPC_VidFrame_MoveLeft:
Send {LCtrl Down}{Numpad4 2}{LCtrl Up}
RETURN
_MPC_VidFrame_MoveRight:
Send {LCtrl Down}{Numpad6 2}{LCtrl Up}
RETURN
_MPC_Subtitles_Download:
Send {d}
RETURN
_MPC_Subtitles_Enable:
Send {w}
RETURN
_MPC_Subtitle_Prev:
Send {LShift Down}{s}{LShift Up}
RETURN
_MPC_Subtitle_Next:
Send {s}
RETURN
_MPC_Subtitle_TextBigger:
Send {Ctrl Down}{NumpadAdd}{Ctrl Up}
RETURN
_MPC_Subtitle_TextSmaller:
Send {Ctrl Down}{NumpadSub}{Ctrl Up}
RETURN
_MPC_Jump_Beginning:
Send {Home}
RETURN
_MPC_Playback_SpeedUp:
Send {Ctrl Down}{Up}{Ctrl Up}
RETURN
_MPC_Playback_SpeedDown:
Send {Ctrl Down}{Down}{Ctrl Up}
RETURN
_MPC_Playback_SpeedReset:
Send {Ctrl Down}{r}{Ctrl Up}
RETURN
; ##################################
; MEDIA PLAYER CLASSIC - HOME CINEMA
; ##################################
#IF Profile = 1
F1 & WheelUp::Gosub, _MPC_Audio_Prev
F1 & WheelDown::Gosub, _MPC_Audio_Next
F2 & WheelUp::Gosub, _MPC_Subtitle_Prev
F2 & WheelDown::Gosub, _MPC_Subtitle_Next
F2 & MButton::Gosub, _MPC_Subtitles_Download
F2 & XButton1::Gosub, _MPC_Subtitles_Enable
F3 & WheelUp::Gosub, _MPC_Chap_Prev
F3 & WheelDown::Gosub, _MPC_Chap_Next
F3 & MButton::Gosub, _MPC_Jump_Beginning
F4 & WheelUp::Gosub, _MPC_Seek_Backwards
F4 & WheelDown::Gosub, _MPC_Seek_Forward
F4 & MButton::Gosub, _MPC_PlayPause
F5 & WheelUp::Gosub, _MPC_Step_Backwards
F5 & WheelDown::Gosub, _MPC_Step_Forward
F5 & MButton::Gosub, _MPC_Playback_SpeedReset
F6 & WheelUp::Gosub, _MPC_Playback_SpeedUp
F6 & WheelDown::Gosub, _MPC_Playback_SpeedDown
F6 & MButton::Gosub, _MPC_Playback_SpeedReset