AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

StarCraft II - Mouse Scroll (edge of screen) while windowed
Goto page 1, 2  Next
 
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
Bkid



Joined: 26 Sep 2005
Posts: 65
Location: GA

PostPosted: Thu Apr 22, 2010 4:31 am    Post subject: StarCraft II - Mouse Scroll (edge of screen) while windowed Reply with quote

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.

Code:
;
;    Author:      Bkid <Bkid@bemaniso.ws>
;   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 (Bkid@bemaniso.ws).`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--
Back to top
View user's profile Send private message Visit poster's website AIM Address
Guest






PostPosted: Fri Apr 23, 2010 9:09 am    Post subject: Reply with quote

Shouldn't you be busy with hon???
Back to top
Bkid



Joined: 26 Sep 2005
Posts: 65
Location: GA

PostPosted: Fri Apr 23, 2010 2:12 pm    Post subject: Reply with quote

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--
Back to top
View user's profile Send private message Visit poster's website AIM Address
Bkid



Joined: 26 Sep 2005
Posts: 65
Location: GA

PostPosted: Tue May 04, 2010 6:47 pm    Post subject: Reply with quote

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--
Back to top
View user's profile Send private message Visit poster's website AIM Address
MasterFocus



Joined: 08 Apr 2009
Posts: 3035
Location: Rio de Janeiro - RJ - Brasil

PostPosted: Tue May 04, 2010 8:29 pm    Post subject: Reply with quote

Not everyone is able to play this SC 2 Beta.
I am not. Evil or Very Mad
_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"

Antonio França
My stuff: Google Profile
Back to top
View user's profile Send private message Visit poster's website
Bkid (Not Logged In)
Guest





PostPosted: Wed May 05, 2010 8:47 pm    Post subject: Reply with quote

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. :[
Back to top
cool
Guest





PostPosted: Wed May 12, 2010 3:56 am    Post subject: Reply with quote

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.
Back to top
WulfTheSaxon
Guest





PostPosted: Thu May 20, 2010 12:20 pm    Post subject: Windows 7 and Vista Reply with quote

Thanks. Ran across this thread while searching for a solution to the windowed-mode mouse-scrolling issue, and discovered AutoHotkey at the same time. Smile

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



Joined: 01 Jun 2010
Posts: 1

PostPosted: Tue Jun 01, 2010 1:42 pm    Post subject: Reply with quote

Bkid wrote:
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.
Back to top
View user's profile Send private message
Guest






PostPosted: Mon Jun 28, 2010 1:51 am    Post subject: Reply with quote

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
Back to top
Guest






PostPosted: Mon Jun 28, 2010 3:11 am    Post subject: Reply with quote

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 Smile Smile Smile
Back to top
Guest






PostPosted: Mon Jun 28, 2010 3:32 am    Post subject: RESOLVED Reply with quote

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-Cool

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



Joined: 18 May 2010
Posts: 1015
Location: Sweden

PostPosted: Sun Jul 04, 2010 7:19 pm    Post subject: Reply with quote

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 [url="http://www.teamliquid.net/forum/viewmessage.php?topic_id=104154"]day[9][/url] referred to the lack of this functionality in an episode somewhere.
Back to top
View user's profile Send private message Visit poster's website
erick1473



Joined: 13 Jul 2010
Posts: 1

PostPosted: Tue Jul 13, 2010 2:28 am    Post subject: Reply with quote

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! =)
Back to top
View user's profile Send private message
tidbit



Joined: 09 Mar 2008
Posts: 1807
Location: Minnesota, USA

PostPosted: Tue Jul 13, 2010 2:41 am    Post subject: Reply with quote

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*
Note: My name is all lowercase for a reason.
Even monkeys fall from trees. - Japanese proverb
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group