Home
Download
Screenshots

Wiki
Plugins
Translations
Developers
Donate

Forums/Help
Contact Us

StrokeIt

Mouse click at gesture start fails on a tablet/tabletPC

Posted by mr_deimos 
Mouse click at gesture start fails on a tablet/tabletPC
January 17, 2010 05:13PM
First of all, thanks for this great software, Jeff - keep up the good work :)

I recently purchased the pro version of StrokeIt, mainly because of its mouse plugin capable of sending mouse clciks at gesture start.
Back in 9.6 version i used to use a hackish and not very efficient autohotkey script to achieve this result: one instance of the script was constantly running in the background intercepting _all_ right mouse button clicks and remembering coordinates of the last one. If strokeIt recognized a proper gesture it launched a second instance of the script which sent a WM_MESSAGE to the first instance to trigger the middle mouse button click at last recorded coordinates and exit so that the new instance could take over monitoring right-clicks and wait for a WM_MESSAGE from the next instance.
Complicated. isn't it? So i was really happy to find out that StrokeIt 9.7 pro finally can send mouse clicks at gesture start all by itself. It didn't take me long to get the license, especially since i already felt like donating ;)
Unfortunately it wasn't just as easy as that - most of the time the button click is sent at the end of gesture trail instead of the beginning. Anyway, the bug It's described thoroughly here:
http://www.tcbmi.com/strokeit/bugs/view.php?id=8
I'm sure it will eventually get fixed, however for now i'm looking for a workaround.

Since i know that autohotkey can send mouse clicks properly even on a tablet, the logical course of action would be to create a simple script that would only just click the mouse button on proper coordinates (actually, already did that part ;) ). My question is: how do i pass these coordinates as command line parameters from strokeIt to autohotkey? I can compile the script to an exe that would accept two command line parameters: x and y coordinates of the desired mouse click. So something like this:

--!SI:Click mouse:ahk_click()

function ahk_click()  
  local start_x, start_y = gesture.point(0)
  local ahk_cmd =  "C:\\Program Files\\AutoHotkey\\mouse_click.exe" .. " " .. tostring(start_x) .. " " .. tostring(start_y)
  os.execute(ahk_cmd)
end

should theoretically work, however i didn't succeed in actually running anything with it. It just flashes the command line window and doesn't do anything else. Running some another program this way, even without parameters has exactly the same effect. I verified that the ahk_cmd string contains proper command by MessageBox.
I guess that a better way would be to call the strokeIt exec plugin from lua and pass the command line parameters to it. But how do i do that? Currently the lua scripting documentation is a bit... incomplete ;)
Or maybe the run plugin can already do this natively without help of scripting? I read trough its source bum maybe i'm missing something here?

Any help would be appreciated.
Leo
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 17, 2010 06:05PM


--!SI:Click mouse:ahk_click()

function ahk_click()  
  local start_x, start_y = gesture.point(0)
  local ahk_cmd =  "\"".."C:\\Program Files\\AutoHotkey\\mouse_click.exe".."\"" .. " " .. tostring(start_x) .. " " .. tostring(start_y)
  os.execute(ahk_cmd)
end

spacebar is the killer



Edited 1 time(s). Last edit at 01/17/2010 06:07PM by Leo.
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 06:57AM
Ok, thanks for your help.
However i still have some problems with that: first, the os.execute command seems to invoke the command line window in the middle of the screen and most of the time any emulated mouse licks would hit the console window instead of the intended target. So,do you know how to use plugin.call("Run"...)? Using it should fix this problem.
The second, more serious problem is that any script function i bind to a gesture can be triggered only once. Drawing gesture after that doesn't do anything. I have to open the strokeit configuration and reload the script there for it to worke again - once. After that i need to reload it again. Even the functions from example script "Call SI Plugins", "MB Default Args"...) work this way. It makes debugging a real pain ;) So, is there any special way i should exit the script or function to make it trigger again? Or is it happening only for me?
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 08:10AM
> The second, more serious problem is that any
> script function i bind to a gesture can be
> triggered only once. Drawing gesture after that
> doesn't do anything. I have to open the strokeit
> configuration and reload the script there for it
> to worke again - once. After that i need to reload
> it again. Even the functions from example script
> "Call SI Plugins", "MB Default Args"...) work this
> way. It makes debugging a real pain ;) So, is
> there any special way i should exit the script or
> function to make it trigger again? Or is it
> happening only for me?

No, I suffer from it, too. I by-passed it by not using the call structure. Currently I have no time to search its cause or a solution, but it is annoying, indeed.
Leo
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 12:44PM
--!SI:Click mouse:ahk_click()

function ahk_click()  
local params = string.format([["%s" "%s" "%s" "%s"]],'C:\\Program Files\\AutoHotkey\\mouse_click.exe','','start_x start_y','')
plugin.call("exec","run",params) 
end

I make osd after the script sometimes SI needs more time to execute.



Edited 1 time(s). Last edit at 01/28/2010 01:14PM by Leo.
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 02:33PM
Thanks, Leo.
Your solution didn't work right away - using your example the arguments passed to autohotkey script are two strings: "start_x" and "start_y" instead ofsleep numerical coordinates of gesture start, but at least it pointed me in the right direction :)

The solution that finally (kind of) works is:
--!SI:Click mouse:ahk_click()

function ahk_click()  
local start_x, start_y = gesture.point(0)
local params = string.format([["%s" "%s" "%d %d" "%s"]],'C:\\Program Files\\AutoHotkey\\mouseClick.exe','',start_x,start_y,'')    
plugin.call("exec","run",params) 
end
The start_x and start_y parameters are not strings, but integer values, therefore they should be represented by %d not %s in the formatting string.
So, i finally got strokeit to launch the mouseClick.exe program, pass gesture start coordinates to it, and the program successfully emulated a middle mouse button click at gesture start coordinates. Once... Then i have to reload the script in SI settings :( Adding OSD or delays before or after launching the script. I also tried to exit the ahk_click function by returning a value, i even tried to use os.exit to terminate the script - but it terminated entire strokeIt instead. I'm out of ideas.
It's a bit frustrating when software doesn't work the way it's supposed to because of a bug, and even more frustrating when finding a workaround to a bug is stopped by a second one :P But i guess i'll just have to wait for the next version of SI - hopefully both mouse click and lua script execution will be fixed by then.
Leo
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 03:05PM
so mr_deimos,

Please post the script perhaps I can help out ...


Regards

>one instance of the script was
> constantly running

This can be the failure ...


Leo



Edited 1 time(s). Last edit at 01/28/2010 03:11PM by Leo.
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 04:10PM
Ok, i think i didn't explain it very well. So here it goes: The script-running-in-background approach was the way i was emulating mouse click _before_ version 9.7. I hoped that 9.7's mouse plugin would eliminate the need for such messy and hackish solutions. However it turned out that mouse plugin is buggy on a tablet (as described on bug tracker).
But lua scripting plugin made another, a bit less messy and simpler workaround theoretically possible: obtaining gesture start coordinates directly form strokeit instead of trying to capture them with an external script.

So now all i try to do is to use this:
--!SI:Click mouse:ahk_click()

function ahk_click()  
local start_x, start_y = gesture.point(0)
local params = string.format([["%s" "%s" "%d %d" "%s"]],'C:\\Program Files\\AutoHotkey\\mouseClick.exe','',start_x,start_y,'')    
plugin.call("exec","run",params) 
end
Lua script to run this:
#NoTrayIcon
SetBatchLines , -1
CoordMode , Mouse , Screen
SetMouseDelay , 0
Click , %1%, %2%, M
ExitApp
autohotkey script compiled to an exe and pass gesture start coordinates to it. Just a matter of running one exe with two command line parameters. After the autohotkey script finishes, it quits so no running in background anymore background anymore.
It does work as intended now - middle mouse button is clicked at gesture start when "up" gesture is performed, even on a tablet.

However the problem i ran into now is that _any_ lua script (even the example included with SI) can be run by strokeit only once. I did some testing and it turned out that disabling and then enabling SI (by clicking the tray icon) doesn't help. What is even more interesting, quitting SI and running it again doesn't help either. Only after i open SI command editor, and click on the lua script command, it will trigger again and again only once. If i click any other entry on actions list and then click the script command, the script will be able to execute again, and as usual - only once. Doing some changes in the command - like changing the environment, or lua changing function called doesn't help. I have to select some other entry and then select the lua command again.

So even though i do have a working solution for my original problem (clicking mouse at gesture start coordinates) now, i still can't use it because of a bug in strokeit lua plugin. Now that's what i call bad luck ;)
Or am i doing something wrong?
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 04:58PM
No, you are not. You have the same or similar issue I posted here:
http://www.tcbmi.com/strokeit/forum/read.php?3,53887,54080#msg-54080 at EDIT4
http://www.tcbmi.com/strokeit/forum/read.php?3,53887,54107#msg-54107 at the EDIT part. I had Lua to summon a MessageBox. It did it only once. If I had the command editor open or reselected the function in it, it worked again but not more than once. Soon after I gave up on it. I think that using functions are still buggy and I decided not to use them as a workaround. All my Lua scripts are pure code now, I have to put them in separate files and cannot use parameters at all. So it's a failure so far :)
Re: Mouse click at gesture start fails on a tablet/tabletPC
January 28, 2010 06:00PM
Well, it's good to know that at least i'm not the only one with this problem :)
And this post:
http://www.tcbmi.com/strokeit/forum/read.php?3,53887,54187#msg-54187
Was really useful info for me since i don't need more than one function in a script, so thanks a lot for that.

Here's the working code:
function ahk_click()  
local start_x, start_y = gesture.point(0)
local params = string.format([["%s" "%s" "%d %d" "%s"]],'C:\\Program Files\\AutoHotkey\\mouseClick.exe','',start_x,start_y,'')    
plugin.call("exec","run",params) 
end

ahk_click()

Using the compiled autohotkey script i posted before i can now emulate the mouse click at the beginning of a gesture. It's still just a workaround, not a real solution but at least it works :D

Thanks for your help Leo and gemisigo.



Edited 2 time(s). Last edit at 01/28/2010 06:01PM by mr_deimos.
Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 15 plus 7?
Message: