Jump to content

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

StarCraft II - Mouse Scroll (edge of screen) while windowed


  • Please log in to reply
25 replies to this topic
Bkid
  • Members
  • 91 posts
  • Last active: Apr 02 2015 05:58 PM
  • Joined: 26 Sep 2005
I really enjoyed the fact that you can scroll the map by moving your mouse to the very edge of the screen, but I wasn't happy with the fact that the game didn't lock your mouse into its window if you play the game in windowed mode.

I wanted to have the best of both worlds, so I came up with this script. It's a good amount of borrowed code from "corrupt", a user here on the AHK forums. I've modified the code a little so that it doesn't go all the way to the top of the window (bar and all), and doesn't go to the very edges of any side of the screen. Also, it's now activated with CapsLock.

;
; 	Author:		Bkid <[email protected]>
;	Thanks to corrupt for the original mouse locking code.
;
;	This script finds the size of the SC2 window, its edges, and locks
;	the mouse into the window. This way, you can use the mouse scroll,
;	even if you're windowed. You can lock the mouse by turning CapsLock on,
;	and unlock it by turning CapsLock off.

#SingleInstance Force
#Persistent
Menu, Tray, NoStandard
Menu, Tray, Add, Credits
Menu, Tray, Add, Exit
TrayTip, Mouse lock v1.0 for SC2, CapsLock on = Lock the mouse to the StarCraft 2 window.`nCapsLock off = Release the mouse., 5, 1
SetCapsLockState, Off
SetTimer, LockCheck, 5

LockCheck:
GetKeyState, CapsState, CapsLock, T
If CapsState = D
{
Lock("StarCraft II")
Suspend, Off
WinActivate, StarCraft II
Return
} else {
Lock()
Suspend, On
return
}

Lock(llwindowname="")
{
  VarSetCapacity(llrectA, 16)
  WinGetPos, llX, llY, llWidth, llHeight, %llwindowname%
  If (!llWidth AND !llHeight) {
    DllCall("ClipCursor")
    Return, False
  }
  Loop, 4 {
    DllCall("RtlFillMemory", UInt,&llrectA+0+A_Index-1, UInt,1, UChar,(llX + 4) >> 8*A_Index-8)
    DllCall("RtlFillMemory", UInt,&llrectA+4+A_Index-1, UInt,1, UChar,(llY + 30) >> 8*A_Index-8)
    DllCall("RtlFillMemory", UInt,&llrectA+8+A_Index-1, UInt,1, UChar,(llWidth + llX - 4)>> 8*A_Index-8)
    DllCall("RtlFillMemory", UInt,&llrectA+12+A_Index-1, UInt,1, UChar,(llHeight + llY - 4) >> 8*A_Index-8)
  }
  DllCall("ClipCursor", "UInt", &llrectA)
Return, True
}

Credits:
MsgBox, 262144,, Mouse lock v1.0 for StarCraft II by Bkid ([email protected]).`n`nThanks to corrupt on the AutoHotKey forums for the`ninitial mouse locking code.
return

Exit:
exitapp



What needs to be added/changed:

* A better way to activate the window (right now it can be screwed up if you have a folder open named "StarCraft II"

* Bug fixes/things I haven't realized are wrong yet. :p

* Code clean up
--Bkid--

  • Guests
  • Last active:
  • Joined: --
Shouldn't you be busy with hon???

Bkid
  • Members
  • 91 posts
  • Last active: Apr 02 2015 05:58 PM
  • Joined: 26 Sep 2005
But I don't play HoN..



Also, on a script-related note, I'm going to throw in a hotkey to exit the script, just in case anything goes wrong and your mouse is stuck (shouldn't happen). Sure, you can ctrl+alt+delete and navigate with your keyboard to kill it, but that's a pain.
--Bkid--

Bkid
  • Members
  • 91 posts
  • Last active: Apr 02 2015 05:58 PM
  • Joined: 26 Sep 2005
bump..

I was hoping more people would try this out and give feedback..I guess I can't expect a lot of people to browse the AHK forums AND just so happen to play SC, huh? :p
--Bkid--

MasterFocus
  • Moderators
  • 4323 posts
  • Last active: Jan 28 2016 01:38 AM
  • Joined: 08 Apr 2009
Not everyone is able to play this SC 2 Beta.
I am not. :evil:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Antonio França -- git.io -- github.com -- ahk4.net -- sites.google.com -- ahkscript.org

Member of the AHK community since 08/Apr/2009. Moderator since mid-2012.


Bkid (Not Logged In)
  • Guests
  • Last active:
  • Joined: --
I can play through my friend's account, but not very often. Also, my laptop fan just went out on me, so I'm out of a gaming computer altogether for another week or so. :[

cool
  • Guests
  • Last active:
  • Joined: --
Ya, the code works find.
Except you will need to change the controls for minimap ping in order to use it.
Which you probably already figured out.

WulfTheSaxon
  • Guests
  • Last active:
  • Joined: --
Thanks. Ran across this thread while searching for a solution to the windowed-mode mouse-scrolling issue, and discovered AutoHotkey at the same time. :)

One note: In Windows 7 and Vista, the first three occurrences of “4” need to be changed to “8”.

zendex
  • Members
  • 1 posts
  • Last active: Jun 01 2010 01:42 PM
  • Joined: 01 Jun 2010

bump..

I was hoping more people would try this out and give feedback..I guess I can't expect a lot of people to browse the AHK forums AND just so happen to play SC, huh? :p


OS: Windows 7

Bug: The mouse doesn't reach the top of the window so that it scrolls upwards.

  • Guests
  • Last active:
  • Joined: --
It works...sorta. This is the TYPE of software I have been looking for, i really want to be able to play windowed (not fullscreeN) and be able to still use the side scrolling, now here is my problem with this:

When I move the mouse to the edge to scroll, sometimes the mouse actually passes the GAME, and stops on the BORDER of the window, and with the cursor on the border of the window it does not scroll, so I need to move the mouse back a couple pixels to make it scroll

I hope that makes sense, and I really hope there is a fix to it (in the coding or someting) or even if theres a way I can remove my border on the window? I think that would work, idk how to do that tho

I use Windows Vista 64 by the way

  • Guests
  • Last active:
  • Joined: --
Ok, regarding the above mentioned error: that can be fixed by removing the borders in windows vista by going to Appearance, advanced, turning border padding to 0, this fixes everything EXCEPT

the TOP still cannot be scrolled, PLEASE fix this :) :) :)

  • Guests
  • Last active:
  • Joined: --
Ok, I was the above poster of both of above comments, and I have resolved both of them, heres how:

The problem of the cursor not stoppig and going into the window border is resolved just by changing your computers Appearance Settings in advanced to Border="0" instead of 4 or w/e the number is, this way now the cursor stops right where the SC2 video ends

The second problem was not being able to scroll up. I messed around in the script and resolved this, all you need to do is modify the original script at ONE part in the script:

UChar,(llY + 30) >> 8*A_Index-8)

Just change the 30 to a 25 and BINGO, save the script, close the script, reopen it, done

sumon
  • Moderators
  • 1317 posts
  • Last active: Dec 05 2016 10:14 PM
  • Joined: 18 May 2010
Awesome script! I just helped a guy who needed help with SC2 with it, and he was most grateful. If I played Windowed mode, I'd love it.

Heck, I even think day[9] referred to the lack of this functionality in an episode somewhere.

erick1473
  • Members
  • 1 posts
  • Last active: Jul 13 2010 02:21 AM
  • Joined: 13 Jul 2010
Hi, I'm a complete newb to using scripts and I'm just where exactly am I supposed to put the above script in my Stacraft 2 folder?

Thanks in advance! =)

tidbit
  • Administrators
  • 2709 posts
  • Hates playing Janitor
  • Last active: Jan 15 2016 11:37 PM
  • Joined: 09 Mar 2008
This is the AUTOHOTKEY forum. not the STARCRAFT 2 MACRO forum.
therefore you need AUTOHOTKEY to run these scripts. AUTOHOTKEY is not designed for STARCRAFT. AUTOHOTKEY is designed for Windows and anything Windows related.

so now learn where you are and what you need to download (hint: AUTOHOTKEY). and after that, read the tutorial to learn how to use it.

ps: you will also be banned if caught.

rawr. be very afraid
*poke*
. Populate the AutoHotkey city. Pointless but somewhat fun. .