Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Warcraft III - Healthbars always on and use tgbyhn for inv


  • Please log in to reply
47 replies to this topic
POINTS
  • Members
  • 290 posts
  • Last active: Oct 13 2010 02:12 AM
  • Joined: 17 Jan 2006
Although we can modify some of the keys of Warcraft III using the customkeys.txt, it leaves much to be desired.

From the ideas of this thread at wcreplays:
http://www.wcreplays...hp/t-18200.html
I compiled a script that basically keeps the healthbars on all the time as well as use tgbyhn for the inventory (instead of the numpad).

You can download the compiled program here:
https://ahknet.autoh...POINTS/war3.exe

And the source code here:
https://ahknet.autoh...POINTS/war3.ahk

The code does these things:
Automatically turns on Healthbars when the warcraft III window is active
Automatically disables hotkeys when warcraft III is inactive

Uses tgbyhn instead of KEYPAD for inventory
Uses TAB like CTRL to set Control Groups
Uses Wheel like tab (to change active members of group)

Capslock: Resets healthbars if they get turned off
Pause: freezes the script (ie for chat room chatting)
ScrollLock: holds down the left mouse button to follow (if you put the cursor over the heros picture for example you can then follow the hero, I use this in replays because I dislike the auto camera)

#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

*Pause::
Suspend, Permit
if (InChatRoomOn == False)
{
  Suspend, On
  InChatRoomOn := True
  SoundPlay,*64
}
else
{
  Suspend, Off
  InChatRoomOn := False
  SoundPlay,*48
}
return

;;;;; Use CAPSLOCK 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
*Capslock::
if (HealthBarOn == False)
{
  Send, {[ Down}
  Send, {] Down}
  HealthBarOn := True
}
else
{
  Send, {[ Up}
  Send, {] Up}
  HealthBarOn := False
}
return

;; the send command allows us to hold down a key and it will repeat
;; useful for casting spells (ie summons) and tp-ing asap
q::Send q
+q::Send Q
w::Send w
+w::Send W
e::Send e
+e::Send E
r::Send r
+r::Send R

a::Send a
+a::Send A
s::Send s
+s::Send S
d::Send d
+d::Send D
f::Send f
+f::Send F

z::Send z
+z::Send Z
x::Send x
+x::Send X
c::Send c
+c::Send C
v::Send v
+v::Send V


;;;;; Use tgbyhn instead of KEYPAD for inventory ;;;;;
t::Send, {Numpad7}
g::Send, {Numpad4}
b::Send, {Numpad1}
y::Send, {Numpad8}
h::Send, {Numpad5}
n::Send, {Numpad2}

+t::Send, +{Numpad7}
+g::Send, +{Numpad4}
+b::Send, +{Numpad1}
+y::Send, +{Numpad8}
+h::Send, +{Numpad5}
+n::Send, +{Numpad2}


;;;;; Use TAB like CTRL to set Control Groups ;;;;;
~Tab & 1::Send, ^1
~Tab & 2::Send, ^2
~Tab & 3::Send, ^3
~Tab & 4::Send, ^4
~Tab & 5::Send, ^5
~Tab & 6::Send, ^6
~Tab & 7::Send, ^7
~Tab & 8::Send, ^8
~Tab & 9::Send, ^9
~Tab & 0::Send, ^0


;;;; use Wheel for tab ;;;;;
*WheelUp::send, {Tab}
*WheelDown::Send +{Tab}

Related Topic: Warkeys
http://www.autohotke...pic.php?p=46507

toralf
  • Moderators
  • 4035 posts
  • Last active: Aug 20 2014 04:23 PM
  • Joined: 31 Jan 2005
Nice script and good structured.

Just a minor short remark, you could simplify the code a bit, e.g.
*ScrollLock:: 
  Send, {Blind}{ScrollLock}
  if FollowOn
      Send, {LButton Up}
  Else
      Send, {LButton Down} 
  FollowOn := not FollowOn 
return

Ciao
toralf
 
I use the latest AHK version (1.1.15+)
Please ask questions in forum on ahkscript.org. Why?
For online reference please use these Docs.

POINTS
  • Members
  • 290 posts
  • Last active: Oct 13 2010 02:12 AM
  • Joined: 17 Jan 2006
That does make it look better. I'll go ahead and make the change thanks.

jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
Thanks @Points for the info. It got me started in the right direction. Just happened to be looking for warcraft hotkeys and noticed your code. Would the following changes be okay to make it better?

1. Escape cancels a message too and needs suspend to permit it. Your NumpadEnter routine did not seem to work for me. Supposedly safe to use at anytime regardless what is on the screen. Enter still starts and stops a message, as you indicated before. Add the following code to help. WARNING: Watch out if the Enter key is used for anything other than messaging, like during the "press any key" load screens, save game screens, etc. Since the suspend will be activated, Escape must be used to cancel it.

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

2. Pause can disable hotkeys while in a message in emergencies if suspend does not toggle properly. Supposedly safe to use at anytime regardless what is on the screen. Add the following code to help.

Pause:: ; force to disable hotkeys in emergency
;Suspend, Permit ; ignore since remains suspended
;Send, {Pause} ; ignore since may still be in message
Suspend, on
return

3. Allow health bars to remain on all the time but with an option to be disabled. Allow for either friendly or enemy units. Use the original "[" or "]" or whatever. Backup the state when warcraft is no longer active so it can be restored. Add the following code to help, and change the timer routine.

;------------------------------
; Variables
;------------------------------
HealthBarOnFriendly := False
HealthBarOnEnemy := False
BackupHealthBarOnFriendly := False
BackupHealthBarOnEnemy := False

;------------------------------
; Timer
; Restores toggled items like health when warcraft III window is active
;------------------------------
settimer, timer_Warcraft, 1000 ; check every 1 second
timer_Warcraft:
{
  ifWinActive, Warcraft III ; restore state once
  {
    if (BackupHealthBarOnFriendly == True) {
      Send, {[ Down}
      HealthBarOnFriendly := True
      BackupHealthBarOnFriendly := False ; not needed anymore
    }
    if (BackupHealthBarOnEnemy == True) {
      Send, {] Down}
      HealthBarOnEnemy := True
      BackupHealthBarOnEnemy := False ; not needed anymore
    }
  } else ifWinNotActive, Warcraft III ; backup state once
  {
    ; temporarily turn off
    if (HealthBarOnFriendly == True) {
      Send, {[ Up}
      BackupHealthBarOnFriendly := True
      HealthBarOnFriendly := False ; not needed anymore
    }
    if (HealthBarOnEnemy == True) {
      Send, {] Up}
      BackupHealthBarOnEnemy := True
      HealthBarOnEnemy := False ; not needed anymore
    }
  }
}
OnExit, ExitSub
return

;------------------------------
; Health
; [ disables/enables health bar for friendly units
; ] disables/enables health bar for enemy units
;------------------------------
*[::
if (HealthBarOnFriendly == False) {
  Send, {[ Down}
  HealthBarOnFriendly := True
} else {
  Send, {[ Up}
  HealthBarOnFriendly := False
}
return

*]::
if (HealthBarOnEnemy == False) {
  Send, {] Down}
  HealthBarOnEnemy := True
} else {
  Send, {] Up}
  HealthBarOnEnemy := False
}
return


POINTS
  • Members
  • 290 posts
  • Last active: Oct 13 2010 02:12 AM
  • Joined: 17 Jan 2006
Your ideas are really helpful, I'm glad to get so much feedback to improve my script! I think the escape idea is great (why didn't I think of that?!). The main reason I added the numpad enter thing was when I pressed escape.

I think Pause (or another key) should be used to Suspend even the suspend,permit keys (such as enter), so we can pause the script and use enter (in a chat room mainly).

It's probably ok, but we should make sure that capslock will still reset the health bars if they get messed up. I'll double check this.

I'll add your code to my script and repost it when I get a chance. And check out my warkeys script (like Keycraft) too:
http://www.autohotke...pic.php?p=46507

jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
*Point, would you or anyone have an idea how to add Shift-WASD in Autohotkey to replace the cursor or NumpadUp keys? The script runs but warcraft ignores {Up}, regardless if set up as a static or dynamic declaration. The same problem if I try to remap the {Alt} key, {Escape}, etc. just to test.

+w::Send, {Up} ; (script runs, but game does not respond to sent key)
+a::Send, {Left} ; (script runs, but game does not respond to sent key)
+s::Send, {Down} ; (script runs, but game does not respond to sent key)
+d::Send, {Right} ; (script runs, but game does not respond to sent key)
m::Send {Alt} ; (script runs, but game does not respond to sent key)

; other choices,
w::Send, {Up} ; (script runs, but game does not respond to sent key)
+w::Send, {NumpadUp} ; (script runs, but game does not respond to sent key)
+w::Send, {vk26sc148} ; (script runs, but game does not respond to sent key)
Up::Send, {Up} ; (script runs, but game does not respond to sent key)
Up::Send, {Blind}{Up} ; (script runs, but game does not respond to sent key)

; dynamically,
Hotkey, *Up, MoveUp
Hotkey, *Up, on
MoveUp::Send, {Up} ; (script runs, but game does not respond to sent key)

;~Up::return ; (works, so autokey is sending something, but what?)

If this could work, a more advanced script (based on the ruler.ahk, at http://www.autohotke...ess/Bedienhilfe) can be written to move the warcraft map by pressing Shift and just moving the mouse while the cursor stays in the same spot. Would be nice to avoid the edge of the screen to move the map all the time. Currently, pressing the middle mouse button can activate a scroll lock, but warcraft moves the map in the opposite direction while the mouse is moved off the screen.

You are right about the chatroom needing the Enter key. You already have the code, to help force enter to stay in chat. Just change *Pause to ^Pause. The regular Pause can setup messaging, and ^Pause can setup chatrooms.

InChatRoomOn := False

^Pause:: ; force to disable hotkeys in chatroom
Suspend, Permit 
if (InChatRoomOn == False) 
{ 
  Suspend, On 
  InChatRoomOn := True 

  (see the rest of your code you wrote)

You can use Alt Up, instead of Capslock, for convenience to reset the health bars since Alt was doing something like that originally. For example,

;LAlt:: ; left as is, for something else later ...
*RAlt::Send, {blind}{RAlt down} ; use Alt as usual for normal operation
*RAlt Up:: ; turn off health bars in emergencies
Send, {Blind}{RAlt Up}
Send, {[ Up} 
HealthBarOnFriendly := False 
Send, {] Up} 
HealthBarOnFriendlyEnemy := False 
return

Good luck with the Warkey program. Most of my QWERTY in customkeys.txt are okay for me, so I would not need a program right now. It definitely could help others that do not have a good customkeys.

jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
Never mind though about the problem with cursor keys and others. I forgot to mention, I use Win2K/XP, and game runs in fullscreen. One thread specifically addresses this problem,

http://www.autohotke...topic.php?t=829

and some others,
http://www.autohotke...opic.php?t=5908
http://www.autohotke...opic.php?t=7439
http://www.autohotke...opic.php?t=6619
http://www.autohotke...opic.php?t=6887
http://www.autohotke...opic.php?t=7211

For now, it only works without using 'Send' and I can not customize it.

+w::Up ; works
+a::Left
+s::Down
+d::Right

+w::Send, {Up} ; does not work
+a::Send, {Left}
+s::Send, {Down}
+d::Send, {Right}


jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
GOOD NEWS. Game responds with 'Send' command for those problem keys. I do not need to use SetKeyDelay anymore either. I knew there had to be a solution once I made SetKeyDelay longer and longer causing warcraft to eventually respond to something, though not reliably.

SetKeyDelay , -1, -1 ; no delay needed

+w::   Send, {Up down}
+w up::Send, {Up up}
+a::   Send, {Left down}
+a up::Send, {Left up}
+s::   Send, {Down down}
+s up::Send, {Down up}
+d::   Send, {Right down}
+d up::Send, {Right up}

*Space::Send, {Alt down}
*Space up::Send, {Alt up}
*Alt::Send, {Alt down}
*Alt up::Send, {Alt up}

Wow. Using Shift-WASD to move and Shift-mouseclick to set waypoints is really easy. Never thought of that.

POINTS
  • Members
  • 290 posts
  • Last active: Oct 13 2010 02:12 AM
  • Joined: 17 Jan 2006

Wow. Using Shift-WASD to move and Shift-mouseclick to set waypoints is really easy. Never thought of that.


Yeah this is going to be great! I hate using the arrow keys or mousing over to the edge the of screen.

I think your code here will be best since it doesn't use the send command
+w::Up ; works
+a::Left
+s::Down
+d::Right 

Direct mapping is always preferred except in the case where you want to hold down a key and have it auto repeat. This is why I have all those a::Send, a lines in there. But if it works it works.

I working on making holding down the space bar and pressing wasd moves the map, but I have to remap space bar to control.
space::ctrl

^w::Up
^a::Left
^s::Down
^d::Right 

Also, be careful of making alt a sticky key! You don't want to alt-q-q yourself to a gg!

jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
Luckily, I do not worry about LAlt-q-q because I never use LAlt anymore. I use [ ], thanks to your new code.

Using direct mapping is fine. I just wanted to be sure 'Send' also worked in case we ever needed the extra customization (like in my next script).

You can use Tab-WASD. I was planning on using Space for something else (maybe my next script), but you decide what is best. Unfortunately, Tab and Shift-Tab disable some diagonal movement. Tab also very difficult to use with Shift. I can not think of any other keys to use for this feature.

Ctrl-Space could center on events from now on. Ctrl by itself does a lot of things in the game so may be confusing.

The Space-mousemove script is completed. You can move the map without having to move the mouse to the edge of the screen. You do not need to use cursors either. I could simultaneously press Space to move, Shift for waypoints and QWERTY for selections. Unfortunately, I could not slow down the keyboard or mouse scroll speed because it is controlled by the gameplay options. 'Space'-mousemove would fail if 'Space' were previously used as a prefix in other declarations. (Use XButton1 too if available because may be easier than using Space)

;------------------------------
; Mousemove
;------------------------------
BackupX := 0
BackupY := 0
TrackMapPan := False
TrackRadius := floor(A_ScreenWidth / 5) ; 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
      if (X - BackupX >= TrackRadius) {
        Send, {blind}{Left up}
        Send, {blind}{Right down}
        tempx := BackupX +TrackRadius
      } else if (X - BackupX <= -TrackRadius) {
        Send, {blind}{Right up}
        Send, {blind}{Left down}
        tempx := BackupX -TrackRadius
      } else {
        Send, {blind}{Right up}
        Send, {blind}{Left up}
      }
      if (Y - BackupY >= TrackRadius) {
        Send, {blind}{Up up}
        Send, {blind}{Down down}
        tempy := BackupY +TrackRadius
      } else if (Y - BackupY <= -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::
XButton1:: alternative, if available
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::
XButton1 up:: alternative, if available
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


jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
In summary, if this what you guys were thinking too, we could end up with,

º Assuming custom keys in Warcraft are already QWERTY
º [ ] holds health bars, RAlt resets health bars.
º TYGHBN is inventory.
º Enter,Ctrl-Enter,Shift-Enter, for messages. Enter or Escape to exit.
º F12 for chatroom. F12 or Escape to exit.
º F6 starts a save screen. Enter or Escape ends it.
º Mouse can exit messages or chatroom too, so need to press Escape too.
º Pause disables hotkeys for line message in emergencies.
º Ctrl-Break disables hotkeys for chatroom in emergencies.
º Escape enables hotkeys for game in emergencies.
º Scrolllock to help follow in replays.
º Holding QWERTY to repeat spells, attacks, etc.
º Tab+# replaces hard to use Ctrl-#. Tab still functions normally.
º LAlt-WASD replaces cursors or moving mouse to screen edges.
º Space-mousemove replaces moving mouse to screen edges (or use XButton1)
º Space centers mouse on screen in case hard to see or find during battle.
º Ctrl-Space replaces Space.
º LAlt-Tab to switch properly back to desktop .
º LAlt disabled for safety. Might still show health bars on downstroke though.
º RAlt-q, RAlt-s, etc. still available to access menu and options.
º Mouse middle button to quickly attack/move. Mouse right button just move as usual.
º Pgup/Pgdn to quickly zoom in/out.

P.S. I had to fix the Ctrl-Space code shown right before this post, so that it sends Space up properly.

jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
I forgot to show the code to disable LAlt so no one has to worry about it screwing anything up. Also code to force LAlt-Tab to switch properly back to desktop in emergencies. Also the code to move the cursor, LAlt-WASD, if that helps anyone. Also code to zoom in/out faster. Also code for middle button to attack/move and leave right button for regular move. Also code to cover messages and chatroom.

LAlt::return ; disabled for safety, use RAlt for normal operation
LAlt up::return
Alt::return ; disabled for safety, use RAlt for normal operation
Alt up::return

LAlt & Tab::AltTab ; force alt-tab to switch properly back to desktop
; Move map with LAlt-WASD
LAlt & w::   Send, {blind}{Up down}
LAlt & w up::Send, {blind}{Up up}
LAlt & a::   Send, {blind}{Left down}
LAlt & a up::Send, {blind}{Left up}
LAlt & s::   Send, {blind}{Down down}
LAlt & s up::Send, {blind}{Down up}
LAlt & d::   Send, {blind}{Right down}
LAlt & d up::Send, {blind}{Right up}

LAlt & q::return ; disable so not accidently used
LAlt & e::return
LAlt & r::return
LAlt & f::return
LAlt & z::return
LAlt & x::return
LAlt & c::return
LAlt & v::return
; Mouse middle button to attack/move.
; Mouse right button, as usual for normal operation.
; Available even if Shift for waypoints.
*MButton::Send, R{LButton}
+MButton::Send, {Shift down}R{LButton}

; Quickly zoom in/out
*Pgup::Send, {Pgup 6}
*Pgdn::Send, {Pgdn 6}
;------------------------------
; Messages
; Enter,Ctrl-Enter,Shift-Enter starts line message. Enter or Escape ends it.
; F12 starts a chatroom. F12 or Escape ends it.
; F6 starts a save screen. Enter or Escape ends it.
; Mouse can end message and chatroom too, so need to press Escape too.
; Pause disables hotkeys for line message in emergencies.
; Ctrl-Break disables hotkeys for chatroom in emergencies.
; Escape enables hotkeys for game in emergencies.
;------------------------------
*Enter:: ; disable hotkeys to start message, or enable to end message
Suspend, Permit ; disable all hotkeys, except this one and other permitted ones
Send, {Blind}{Enter}
if (isChatRoom == True)
  return ; remain in chatroom
Suspend ; toggle
if (A_IsSuspended == 0) ; notify done (0=off, 1=on)
  SoundPlay,*64
return

F12:: ; disable hotkeys to start chatroom, or enable to end chatroom
Suspend, Permit ; disable all hotkeys, except this one and other permitted Send, {F12}
if (isChatroom == False) {
  isChatroom := True
  Suspend, on
} else {
  isChatroom := False
  Suspend, off
}
return

!F6:: ; disable hotkeys to start save screen
;Suspend, Permit ; ignore since remains suspended
Send, {Blind}{Alt}s
Suspend, on
return

;F6, as usual for normal operation, for quicksave
;Alt-L, as usual for normal operation, for load screen

*Pause:: ; force to disable hotkeys in messages in emergency
;Suspend, Permit ; ignore since remains suspended
;Send, {Pause} ; ignore since may still be in message
Suspend, on
return

*^CtrlBreak:: ; force to disable hotkeys in chatroom in emergency
;^Pause:: ; same as CtrlBreak
;Suspend, Permit ; ignore since remains suspended
;Send, {CtrlBreak} ; ignore since may still be in message
isChatroom := True
Suspend, on
return

Escape:: ; end message or chatroom
Suspend, Permit ; disable all hotkeys, except this one and other permitted ones
Send, {Escape}
isChatroom := False
Suspend, off
if (A_IsSuspended == 0) ; notify done (0=off, 1=on)
  SoundPlay,*64
return


  • Guests
  • Last active:
  • Joined: --
Hi guys, just wanted to let you know i've been following this thread and what you're doing is great.

At the mo I'm just using a small peice of your code to toggle the showing of health bars and my own script for the inv (press alt+q for inv 1 etc). I've also bound some of the inv's to my mouse for quicker pressing.

Works great! I can't beleive i never though of changing all of this stuff earlier.
Hopefully I can get in the habit of using it all now :)

cheers

jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
Sounds good. I am still trying to get in the habit too. I wish I had a 4th side button on the mouse to scroll rather than pressing Space or Alt. Oh well.

If anyone knows how, is it possible to,
1. add a selected unit to control group 1 by pressing LAlt-1. Never mind ... pressing Shift-1 already works in the game.

2. highlight units nearby the mouse cursor key by pressing one key. Autohotkey script could probably use LButton and move mouse to highlight a box of 200 pixels width and height around the original cursor location. Maybe a second key to do it with a larger box.

3. highlight units nearby a selected unit by pressing one key (Ctrl-c centers on the unit temporarily). Autohotkey script could probably press Ctrl-C, center the mouse and then use a similar feature in (2) above.

Correction:
Fixed code above with Space to move mouse. Forgot the floor() function which reduces errors. Size of box should also be bigger to help make it a little easier to manage. For example,
TrackRadius := floor(A_ScreenWidth / 5) ; distance mouse travels before moving map

Space::
XButton1:: alternative, if available
if (TrackMapPan == False) { ; first call, since holding key repeats script continuously
  BackupX := floor(A_ScreenWidth / 2)
  BackupY := floor(A_ScreenHeight / 2)
...


jtbalogh
  • Members
  • 35 posts
  • Last active: Oct 24 2006 06:57 PM
  • Joined: 05 Feb 2006
CORRECTION:
An alternative for Space-mousemove, shown earlier on February 6, is to NOT scroll constantly out of control. When the mouse stops moving, then the map should stop moving, assuming we only need to look around a small portion of the map where the battle is taking place anyway. Also there should be no need for the mouse to reach an edge of a box or screen to move, so keep mouse near center of screen. To reach far areas of the map, then as usual move mouse to edge of screen to scroll constantly for normal operation. Hope that helps.
;------------------------------ 
; 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:: 
XButton1:: alternative, if available 
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:: 
XButton1 up:: alternative, if available 
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