StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
icceeeee  
#1 Posted : Monday, September 6, 2021 12:42:52 PM(UTC)
icceeeee

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/5/2021(UTC)
Posts: 8
Macedonia

Thanks: 2 times
Hi everyone! BigGrin

Basically, I'm trying to create a script that works like this:

When I roll my mousewheel forward it cycles through a set range in the Numpad (1-4).

When I roll my mousewheel backwards it cycles through another set range in the Numpad (5-9).

In other words, with every 'click' of cycling my mousewheel forward will result in "123412341234..." and every 'click' backwards will result in "5678956789..."

I've already discovered so many cool snippets of scripts from the forum which I have customised...but this one has me drawing a blank.

Thanks again Rob for creating this incredible software, I can't get enough of it right now ThumpUp
Rob  
#2 Posted : Friday, September 10, 2021 2:54:34 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
You can certainly leverage Global Actions > Mouse Events > Mouse Wheel to have a script which does this.

But I will caution that mouse wheel events can happen fast and in high volume, so you need to make sure things are done in a way which doesn't cause a negative experience while using the mouse wheel normally.

Can you expand on the use case?
Do you only want this to happen for certain apps?
Is this for a game?
- If so, S+ would have to be enabled like normal, which you may not want a stroke button interfering, etc.
How many times is the sequence (1234) repeated per wheel tick?
Anything else which may be helpful to know?
thanks 1 user thanked Rob for this useful post.
icceeeee on 9/12/2021(UTC)
icceeeee  
#3 Posted : Sunday, September 12, 2021 1:17:40 AM(UTC)
icceeeee

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/5/2021(UTC)
Posts: 8
Macedonia

Thanks: 2 times
Originally Posted by: Rob Go to Quoted Post
Can you expand on the use case? Is this for a game?
Yes it is for a game. Each number is a hotkey ingame, and I would like to cycle through them quickly using the mousewheel (I checked and it is not against the rules).
Originally Posted by: Rob Go to Quoted Post
Can you expand on the use case? How many times is the sequence (1234) repeated per wheel tick?
I would like it to function like this: *wheel tick forward* 1 *wheel tick forward* 2 *wheel tick forward* 3...

So with each wheel tick forward, it moves the number forward by one (1-4). And for wheel tick backwards it does the same thing (with 5-9).

I have added some code so it works ingame (script included below).
Originally Posted by: Rob Go to Quoted Post
If so, S+ would have to be enabled like normal, which you may not want a stroke button interfering, etc. Do you only want this to happen for certain apps?
Yes I have encountered this problem, my right-click gesture strokes interferes with the game, and the only solution I have found is to manually change it to X1 temporarily (X1/2 gestures doesn't seem to work with S+ for my mouse).

If there's an easier way to display the gesture strokes for specific applications I would love to know that.
Originally Posted by: Rob Go to Quoted Post
Anything else which may be helpful to know?
Yes, I can share the code which I have created from all the snippets I read from the forum.

The middle-click > release streamlines the attack move: ("a") > left-click. and the mousewheel does the same thing (with mousewheel tick forward > backwards).

Thanks Rob! Appreciate your help BigGrin
Code:
//MIDDLE MOUSE CLICK

if(click.Down 
      && click.Window.Process.MainModule.ModuleName == "StarCraft.exe"
  ) {
    sp.SendKeys("a");
} else {
    //Up event, this will never happen for stroke buttons
    //Use Release tab
}

//RELEASE MIDDLE MOUSE CLICK

if(click.Button == MouseButtons.Middle 
      && click.Window.Process.MainModule.ModuleName == "StarCraft.exe"
  ) {
    sp.MouseClick(sp.GetCurrentMousePoint(), MouseButtons.Left, true, true);
}

//MOUSE-WHEEL

if(wheel.Window.Process.MainModule.ModuleName == "StarCraft.exe") {
    if(parseInt(wheel.Y) <= (parseInt(wheel.Window.Rectangle.Top) + 1920)) {//is the mouse in the top 64 pixel area of the window?
        if(wheel.Delta > 0) {
            //mouse wheel scrolled up
            sp.SendKeys("A");
        } else {
            //mouse wheel scrolled down
            sp.MouseClick(sp.GetCurrentMousePoint(), MouseButtons.Left, true, true);
        }
    
    } else {
        //Default, pass mouse wheel message onto the original control
        wheel.Control.PostMessage(host.cast(uint, 0x020A), new IntPtr(wheel.WParam), new IntPtr(wheel.LParam));
    }
} else {
    //Default, pass mouse wheel message onto the original control
    wheel.Control.PostMessage(host.cast(uint, 0x020A), new IntPtr(wheel.WParam), new IntPtr(wheel.LParam));
}
Rob  
#4 Posted : Tuesday, September 14, 2021 1:48:02 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,359
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 419 time(s) in 356 post(s)
Okay, so few couple things.

1) See if you can use something other than the EXE name in your wheel script, as it is a very expensive call to make (by a lot). Class name or title is the most efficient. You can use the App Definition or Ignored List sections, click and drag the magnifying glass icon over the StarCraft window and release the mouse to have S+ tell you what it sees.

2) If you're using the mouse wheel script, then the mouse hook will have to be enabled, so yeah, setting the stroke button to something else is the only workaround.

3) Use this instead of wheel.Control.PostMessage(host.cast(uint, 0x020A), new IntPtr(wheel.WParam), new IntPtr(wheel.LParam));

Code:
sp.MouseWheel(wheel.Point, false, wheel.Delta);


4) Here is an example snippet for the wheel scrolling, tweak as needed:
Code:
    if(wheel.Delta > 0) {
        // Scroll up
        var numberToPress = sp.GetStoredNumber("StarCraftWheelUp");
        // If stored number is not between 1 and 4, set to 1
        if(numberToPress < 1 || numberToPress > 4) {
            numberToPress = 1; 
        }
        // Send the appropriate key
        switch(numberToPress) {
            case 1:
                sp.SendVKey(vk.VK_1);
                break;
            case 2:
                sp.SendVKey(vk.VK_2);
                break;
            case 3:
                sp.SendVKey(vk.VK_3);
                break;
            case 4:
                sp.SendVKey(vk.VK_4);
                break;
        }
        // Increment to the next number
        numberToPress++;
        // Save the number for the next scroll
        sp.StoreNumber("StarCraftWheelUp", numberToPress);
        // If scrolled up, reset scroll down back to 5
        sp.StoreNumber("StarCraftWheelDown", 5);
    } else {
        // Scroll down
        var numberToPress = sp.GetStoredNumber("StarCraftWheelDown");
        // If stored number is not between 5 and 9, set to 5
        if(numberToPress < 5 || numberToPress > 9) {
            numberToPress = 5; 
        }
        // Send the appropriate key
        switch(numberToPress) {
            case 5:
                sp.SendVKey(vk.VK_5);
                break;
            case 6:
                sp.SendVKey(vk.VK_6);
                break;
            case 7:
                sp.SendVKey(vk.VK_7);
                break;
            case 8:
                sp.SendVKey(vk.VK_8);
                break;
            case 9:
                sp.SendVKey(vk.VK_9);
                break;
        }
        // Increment to the next number
        numberToPress++;
        // Save the number for the next scroll
        sp.StoreNumber("StarCraftWheelDown", numberToPress);
        // If scrolled down, reset scroll up back to 1
        sp.StoreNumber("StarCraftWheelUp", 1);
icceeeee  
#5 Posted : Wednesday, September 15, 2021 11:19:19 AM(UTC)
icceeeee

Rank: Newbie

Reputation:

Groups: Approved
Joined: 9/5/2021(UTC)
Posts: 8
Macedonia

Thanks: 2 times
Thanks Rob! I had to make a few tweaks to get it working but now it's perfect.

I'll include my final code below to serve as a reference for people in the future, hopefully some fellow Brood War nerds will find it useful LOL


Code:
if(wheel.Window.Title.startsWith("Brood War")){
    if(parseInt(wheel.Y) <= (parseInt(wheel.Window.Rectangle.Top) + 1920)) {
        if(wheel.Delta > 0) {
        // Scroll up
        var numberToPress = sp.GetStoredNumber("StarCraftWheelUp");
        // If stored number is not between 1 and 4, set to 1
        if(numberToPress < 1 || numberToPress > 4) {
            numberToPress = 1; 
        }
        // Send the appropriate key
        switch(numberToPress) {
            case 1:
                sp.SendVKey(vk.VK_1);
                break;
            case 2:
                sp.SendVKey(vk.VK_2);
                break;
            case 3:
                sp.SendVKey(vk.VK_3);
                break;
            case 4:
                sp.SendVKey(vk.VK_4);
                break;
        }
        // Increment to the next number
        numberToPress++;
        // Save the number for the next scroll
        sp.StoreNumber("StarCraftWheelUp", numberToPress);
        // If scrolled up, reset scroll down back to 5
        sp.StoreNumber("StarCraftWheelDown", 5);
        
    } else {
        // Scroll down
        var numberToPress = sp.GetStoredNumber("StarCraftWheelDown");
        // If stored number is not between 1 and 4, set to 1
        if(numberToPress < 5 || numberToPress > 9) {
            numberToPress = 5; 
        }
        // Send the appropriate key
        switch(numberToPress) {
            case 5:
                sp.SendVKey(vk.VK_5);
                break;
            case 6:
                sp.SendVKey(vk.VK_6);
                break;
            case 7:
                sp.SendVKey(vk.VK_7);
                break;
            case 8:
                sp.SendVKey(vk.VK_8);
                break;
            case 9:
                sp.SendVKey(vk.VK_9);
                break;
        }
        // Increment to the next number
        numberToPress++;
        // Save the number for the next scroll
        sp.StoreNumber("StarCraftWheelDown", numberToPress);
        // If scrolled down, reset scroll up back to 1
        sp.StoreNumber("StarCraftWheelUp", 1);
}
}
}

Edited by user Wednesday, September 15, 2021 11:24:28 AM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.