Reposted b/c full text not viewable.
So I'm trying to use the healthbar script that POINTS [thanks] created (with some hotkey customixation for my needs) with the mousemove code from jtbalogh. They're not functioning together and I'm not sure why.
Here's the code for the healthbars, hotkeys, etc.
Code:
#SingleInstance force ;force a single instance
#HotkeyInterval 0 ;disable the warning dialog if a key is held down
#InstallKeybdHook ;Forces the unconditional installation of the keyboard hook
#UseHook On ;might increase responsiveness of hotkeys
#MaxThreads 20 ;use 20 (the max) instead of 10 threads
SetBatchLines, -1 ;makes the script run at max speed
SetKeyDelay , -1, -1 ;faster response (might be better with -1, 0)
;Thread, Interrupt , -1, -1 ;not sure what this does, could be bad for timers
;;;;; Make the icon the TFT icon (Author: NiJo?) ;;;;;
regread, war, HKEY_CURRENT_USER, Software\Blizzard Entertainment\Warcraft III, ProgramX
menu, tray, Icon, %War%, 1, 1
;;;;; Variables ;;;;;
InChatRoomOn := False
HealthBarOn := False
FollowOn := False
;;;;; Timers ;;;;;
;; this timer checks to see if warcraft is active and turns on the health bars
settimer, timer_Warcraft, 1000 ;check every 1 second
timer_Warcraft:
{
ifWinActive, Warcraft III
{
if (HealthBarOn == False)
{
Send, {[ Down}
Send, {] Down}
HealthBarOn := True
}
}
else ifWinNotActive, Warcraft III
{
;; turn off stuff
if (HealthBarOn == True)
{
Send, {[ Up}
Send, {] Up}
HealthBarOn := False
}
;; same for scrollLock
if (FollowOn == True)
{
Send, {LButton Up}
FollowOn := False
}
}
}
OnExit, ExitSub
return
ExitSub:
ExitApp ;The only way for an OnExit script to terminate itself is to use ExitApp
;;;;; Hotkeys ;;;;;
#ifWinActive, Warcraft III ;*new to ver 1.0.41.00* only run when war3 is running
;;;;; Enable/disable all hotkeys ;;;;;
;; For some reason the *~ commands do not work with warcraft
*Enter::
Suspend, Permit
Send, {Blind}{Enter}
if (InChatRoomOn == True)
return
Suspend
if (A_IsSuspended == 1)
SoundPlay,*64
else
SoundPlay,*48
return
;; use numpadenter to turn off hotkeys if we press esc or some how mess it up
*NumpadEnter::
Suspend, Permit
Send, {Blind}{NumpadEnter}
Suspend, Off
SoundPlay,*48
return
;;;; Scroll Lock to toggle follow mode (useful in replays) ;;;;;
*ScrollLock::
Send, {Blind}{ScrollLock} ; toggle the light
if FollowOn
Send, {LButton Up}
else
Send, {LButton Down}
FollowOn := not FollowOn
return
Escape:: ; end message
Suspend, Permit ; disable all hotkeys, except this one and other permitted ones
Send, {Escape}
Suspend, off
if (A_IsSuspended == 0) ; notify done (0=off, 1=on)
SoundPlay,*64
return
*Pause::
Suspend, Permit
if (InChatRoomOn == False)
{
Suspend, On
InChatRoomOn := True
SoundPlay,*64
}
else
{
Suspend, Off
InChatRoomOn := False
SoundPlay,*48
}
return
;;;;; Use 1 to toggle health on/off ;;;;;
;; the health bars are automatic now and cannot be turned off
;; however if for some reason they get turned off, pressing caps will turn it on
*1::
if (HealthBarOn == False)
{
Send, {[ Down}
Send, {] Down}
HealthBarOn := True
}
else
{
Send, {[ Up}
Send, {] Up}
HealthBarOn := False
}
return
;;;;; Use CapsTabShifttgb instead of KEYPAD for inventory ;;;;;
Tab::Send {Numpad7}
CapsLock::Send {Numpad4}
`::Send {Numpad1}
t::Send {Numpad8}
g::Send {Numpad5}
b::Send {Numpad2}
;;;;; Use Middle Mouse Button or 5 instead of F1 to select hero ;;;;;
5::Send {F1}
MButton::Send {F1}
;;;; use Wheel for tab and LeftControl to add units to a group;;;;;
*WheelUp::send, +{Tab}
*WheelDown::Send {Tab}
And here is the mousemove code, which only ran for me after deleting the "XButton1:: alternative, if available" and "XButton1 up:: alternative, if available" lines. By itself or running as a separate script this works great.
The problem is that if I run them simultaneously as two separate scripts I have no space bar in the message prompt. Apaintoread,
Code:
;------------------------------
; Mousemove
;------------------------------
BackupX := 0
BackupY := 0
TrackMapPan := False
TrackRadius := floor(A_ScreenWidth / 50) ; small distance mouse travels before moving map
;TrackSpeed := ... not possible since scroll speed is in gameplay options
;------------------------------
; Restore mouse position when moving map
;------------------------------
timer_map_pan:
{
ifWinActive, Warcraft III
{
;BlockInput ; not needed
Coordmode, Mouse, Screen ; mouse-coordinates are related to the whole screen
if (TrackMapPan == True) {
MouseGetPos, X, Y, , , 1
tempx := X
tempy := Y
tempxradius := X - BackupX
tempyradius := Y - BackupY
if (tempxradius > TrackRadius) {
Send, {blind}{Left up}
Send, {blind}{Right down}
tempx := BackupX +TrackRadius
} else if (tempxradius < -TrackRadius) {
Send, {blind}{Right up}
Send, {blind}{Left down}
tempx := BackupX -TrackRadius
} else {
Send, {blind}{Right up}
Send, {blind}{Left up}
}
if (tempyradius > TrackRadius) {
Send, {blind}{Up up}
Send, {blind}{Down down}
tempy := BackupY +TrackRadius
} else if (tempyradius < -TrackRadius) {
Send, {blind}{Down up}
Send, {blind}{Up down}
tempy := BackupY -TrackRadius
} else {
Send, {blind}{Down up}
Send, {blind}{Up up}
}
MouseMove, tempx, tempy, 0 ; restore mouse cursor position
}
}
}
OnExit, ExitSub
return
ExitSub:
ExitApp ;The only way for an OnExit script to terminate itself is to use ExitApp
;------------------------------
^Space::Space ; Ctrl-Space replaces Space to center on events.
;^Space up::Space up ; does not work, so use code in *Space up::
;------------------------------
Space::
if (TrackMapPan == False) { ; first call, since holding key repeats script continuously
BackupX := A_ScreenWidth / 2
BackupY := A_ScreenHeight / 2
MouseMove, BackupX, BackupY, 0 ; center on screen for easy viewing
;MouseGetPos, BackupX, BackupY, , , 1 ; already determined
TrackMapPan := True
SetTimer, timer_map_pan, 0
}
return
;------------------------------
Space up::
SetTimer, timer_map_pan, Off
;MouseMove, BackupX, BackupY, 0 ; leave mouse as is
Send, {blind}{Right up} ; not needed anymore
Send, {blind}{Left up}
Send, {blind}{Down up}
Send, {blind}{Up up}
TrackMapPan := False
Send, {Space up}
Send, {XButton up}
return
When I drop the mousemove code into the healthbars script (after deleting the extra ExitSub lines to avoid an error) the spacebar works in the message prompt but when pressed in the game just scrolls the map quickly down and right.
Any ideas? I'm sure there's something I'm missing, I'm a bit new to this.
Thanks, Dre.
PS- POINTS, warkeys is great. Thanks for your efforts there and here.
PPS-Far less important, how can I modify the suspend/permit sounds? Or turn them off?