I have this code:
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.
SetBatchLines, -1
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
;;;Core Code
#If
WatchProg_1 = ahk_exe Notepad++.exe
WatchProg_2 = ahk_exe WINWORD.exe
#Persistent
SetTimer, WatchMouse, 10
Return
WatchMouse:
;;Key Remapper for Notepad++
#If WinActive(WatchProg_1)
WinGet, WinID_1, ID, % WatchProg_1
MouseGetPos,,, CurID_1,, 1
w::
If (CurID_1 = WinID_1) {
Send Any a text (%CurID_1% = %WinID_1%)
} Else {
Send Any b text (%CurID_1% = %WinID_1%)
}
Return
;;Key Remapper for Doc
#If WinActive(WatchProg_2)
WinGet, WinID_2, ID, % WatchProg_2
MouseGetPos,,, CurID_2,, 1
w::
If (CurID_2 = WinID_2) {
Send Any c text (%CurID_2% = %WinID_2%)
} Else {
Send Any d text (%CurID_2% = %WinID_2%)
}
Return
;;;
;;;Suspend hotkeys
#If
Scrolllock::
Send {Scrolllock}
Suspend
Return
;;;
1)If I move the code from Suspend hotkeys section above Core Code section, then binding on W key stops working. How I can fix it without move Suspend hotkeys section below Core Code section?
2)Code in the Key Remapper for Doc section doesn't working, why and how solve this problem? The code in Key Remapper for Notepad++ section is working fine (As I understand it, the problem is that CurID_2 and WinID_2 doesn't get values, but I don't understand why)
I'm more than sure that I make very stupid errors in the code, but I can't find them very long time, please help.
Thanks for reading.