AutoHotkey Community

It is currently May 27th, 2012, 3:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: April 22nd, 2010, 5:31 am 
Offline

Joined: September 26th, 2005, 1:15 am
Posts: 66
Location: GA
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--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2010, 10:09 am 
Shouldn't you be busy with hon???


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: April 23rd, 2010, 3:12 pm 
Offline

Joined: September 26th, 2005, 1:15 am
Posts: 66
Location: GA
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--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2010, 7:47 pm 
Offline

Joined: September 26th, 2005, 1:15 am
Posts: 66
Location: GA
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--


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 4th, 2010, 9:29 pm 
Offline

Joined: April 8th, 2009, 8:23 pm
Posts: 3036
Location: Rio de Janeiro - RJ - Brasil
Not everyone is able to play this SC 2 Beta.
I am not. :evil:

_________________
"Read the manual. Read it again. Search the forum.
Try something before asking. Show what you've tried.
"
Image
Antonio França
My stuff: Google Profile


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 5th, 2010, 9:47 pm 
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. :[


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: May 12th, 2010, 4:56 am 
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.


Report this post
Top
  
Reply with quote  
 Post subject: Windows 7 and Vista
PostPosted: May 20th, 2010, 1:20 pm 
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”.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 1st, 2010, 2:42 pm 
Offline

Joined: June 1st, 2010, 2:41 pm
Posts: 1
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2010, 2:51 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2010, 4:11 am 
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 :) :) :)


Report this post
Top
  
Reply with quote  
 Post subject: RESOLVED
PostPosted: June 28th, 2010, 4:32 am 
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


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: July 4th, 2010, 8:19 pm 
Offline
User avatar

Joined: May 18th, 2010, 3:10 pm
Posts: 1179
Location: Sweden
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2010, 3:28 am 
Offline

Joined: July 13th, 2010, 3:20 am
Posts: 1
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! =)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 13th, 2010, 3:41 am 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
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.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 26 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group