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

Notification

Icon
Error

Options
Go to last post Go to first unread
popo3d  
#1 Posted : Saturday, January 20, 2024 8:12:00 AM(UTC)
popo3d

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/12/2022(UTC)
Posts: 7

How to send RIGHT Control key Down and Up using the script?
Tried sp.SendKeyDown(163) but that doesn't work. Confused
Rob  
#2 Posted : Friday, February 9, 2024 5:36:13 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)
Have you tried this?
Code:
StrokesPlus.Input.Keyboard.Keys.Press(vk.RCONTROL);
sp.Sleep(50);
StrokesPlus.Input.Keyboard.Keys.Release(vk.RCONTROL);
popo3d  
#3 Posted : Saturday, February 10, 2024 2:55:31 PM(UTC)
popo3d

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/12/2022(UTC)
Posts: 7

Originally Posted by: Rob Go to Quoted Post
Have you tried this?
Code:
StrokesPlus.Input.Keyboard.Keys.Press(vk.RCONTROL);
sp.Sleep(50);
StrokesPlus.Input.Keyboard.Keys.Release(vk.RCONTROL);


That doesn't seem to work too.
Rob  
#4 Posted : Sunday, February 11, 2024 2:31:58 AM(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)
What keyboard language/layout are you using?

What is it you're trying to accomplish, and is what program?
popo3d  
#5 Posted : Monday, February 12, 2024 11:18:37 AM(UTC)
popo3d

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/12/2022(UTC)
Posts: 7

Originally Posted by: Rob Go to Quoted Post
What keyboard language/layout are you using?

What is it you're trying to accomplish, and is what program?


I use one of your scripts from this forum. This is a gesture to open a link in browser in a New Tab if mouse is over the link (cursor = hand), or open a new blank tab if it itsn't. Here is the code:


Code:
action.Window.Activate();
sp.ConsumePhysicalInput(true);

var oppened = false;
var clicked = false;
var i = action.Start.Y; //action.Start is a Point, with .X and .Y properties
var i_end = i + 6;

while(i < i_end) {
    sp.MouseMove(new Point(action.Start.X, i));
    sp.Sleep(20);
    if(sp.GetCurrentMouseCursor() == "Hand") {
        oppened = true;
        if(!clicked) { 
            StrokesPlus.Input.Keyboard.Keys.Press(vk.RCONTROL);
            sp.Sleep(70);
            sp.MouseClick(new Point(action.Start.X, i), MouseButtons.Middle, true, true); 
            sp.Sleep(70);
            StrokesPlus.Input.Keyboard.Keys.Release(vk.RCONTROL);
        }
    } else {

    }
    i = i + 2;
}
if (!oppened) {
    sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_T]);
}

sp.ConsumePhysicalInput(false);
sp.MouseMove(action.End); //action.End is also a Point




The reason I need to press the right Control key is that I have another CPP program running that catches mouse (LowLevelMouseProc). It scrolls the text (SendMessage (WM_MOUSEWHEEL)) on mouse move while middle mouse button is pressed. It uses the right Control as a modification key to disable the scrolling functionality:
if (!(GetAsyncKeyState(VK_RCONTROL) & 0x8000)) {...}

So, when I press the right Control on my keyboard (Eng layout) this program doesn't scroll anything and middle mouse button is just a middle button. However, when I run the StrokesPlus gesture script listed above it moves the mouse cursor while the middle key is pressed (~50ms) and the web page content is scrolled like RControl isn't pressed at all.

I guess, the problem could be on both sides, so will try find the reason and the solution. But that would be great if you share any ideas you might have here.

Edited by user Monday, February 12, 2024 11:19:24 AM(UTC)  | Reason: Not specified

Rob  
#6 Posted : Monday, February 12, 2024 12:22:32 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)
Ah, I see.

Do you have the source for this CPP program?

If so, it would probably be easiest to just have S+ post a message to it - since you're consuming input and dealing with key/mouse events in both, there's a good chance of odd behavior/conflicts.

But if you can have the CPP app accept message from S+ to toggle on/off, that would be the simplest and airtight method.

popo3d  
#7 Posted : Monday, February 12, 2024 2:32:10 PM(UTC)
popo3d

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/12/2022(UTC)
Posts: 7

Originally Posted by: Rob Go to Quoted Post
Ah, I see.
Do you have the source for this CPP program?
If so, it would probably be easiest to just have S+ post a message to it - since you're consuming input and dealing with key/mouse events in both, there's a good chance of odd behavior/conflicts.
But if you can have the CPP app accept message from S+ to toggle on/off, that would be the simplest and airtight method.


Yes, I have the source code, it's a tiny 6kb C code app. I've been using it with the S+Net (and with the previous version of S+ too) with no problem for mouse handling.

The problem is that it doesn't catch keyboard input from the StrokesPlus.Input.Keyboard.Keys.Press(vk.RCONTROL) function. However, sp.SendControlDown() works fine and that seems to be the easiest point to stay on for this moment (loosing a bit of functionality of the left ctrl, but whatever).

Anyway, it is not clear from your answer how to post a message from S+ to an external app.
Do you mean sp.SendMessage(hwndTarget, messageID, wParam, lParam)?
How do I get the hwnd of my process if it doesn't have any window initialized?

Haven't found any documentation or examples on that for S+net.
Rob  
#8 Posted : Monday, February 12, 2024 6:33:21 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)
Are you calling RegisterClassEx in your app?
popo3d  
#9 Posted : Monday, February 12, 2024 7:07:57 PM(UTC)
popo3d

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/12/2022(UTC)
Posts: 7

Originally Posted by: Rob Go to Quoted Post
Are you calling RegisterClassEx in your app?


Ah, you are right. I create a message-only window to get external messages. Here is how I do it:

Code:

    WNDCLASS wc = {};
    wc.lpfnWndProc = WindowProc;
    wc.hInstance = GetModuleHandle(NULL);
    wc.lpszClassName = L"MyMessageOnlyWindowClass";

    RegisterClass(&wc);

    // Create the message-only window
    HWND hwnd = CreateWindowEx(
        0,
        L"MyMessageOnlyWindowClass",
        NULL,
        0,
        0, 0, 0, 0,
        HWND_MESSAGE,
        NULL,
        GetModuleHandle(NULL),
        NULL
    );


Should I use "MyMessageOnlyWindowClass" as the window title using sp.FindWindow()? Can you please provide a simple example of how to send the flag?
Rob  
#10 Posted : Monday, February 12, 2024 8:38:31 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)
Something kind of like below - I haven't tested any of it, but it should get you started anyway.

CPP App:
Code:
// WM_USER == 1024, defined by existing windows includes
// and defines the starting point for custom message IDs

// WM_COMMAND == 273, defined by existing windows includes

#define WM_MYAPPCONTROL (WM_USER + 1) 

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	switch (message)
	{	
		// ......
		case WM_COMMAND:
			switch(LOWORD(wParam)) {
				case WM_MYAPPCONTROL:
					if((int)LOWORD(lParam) == 0)
					{
						//DisableHook();
					} else {
						//EnableHook();
					}
					break;
			}
	}
}

StrokesPlus:
Code:
const WM_COMMAND = 273;
const WM_MYAPPCONTROL = 1025;

var cApp = sp.WindowFromClassOrTitle("MyMessageOnlyWindowClass", "");

//Disable
cApp.PostMessageObj(WM_COMMAND, WM_MYAPPCONTROL, "0");

//Enable
cApp.PostMessageObj(WM_COMMAND, WM_MYAPPCONTROL, "1");
Users browsing this topic
Guest
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.