StrokesPlus Forum
                       
StrokesPlus Forum
Home | Profile | Register | Active Topics
Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Feature Updates
 New Features
 [ADDED] Global Before and After Functions *UPDATE
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Rob

USA
2605 Posts

Posted - 06/09/2012 :  19:04:20  Show Profile  Visit Rob's Homepage  Reply with Quote
sp_after_action functionality has been removed as of 1.9.7 due to unknown issues happening for some users.

sp_after_action has been added back in 1.9.8, but only by enabling the Allow After Action Script* option.



Beginning with StrokesPlus version 1.9.5, the following actions may be defined in StrokesPlus.lua (by you) if you'd like certain Lua code to fire before and/or after all of your action scripts. For example, some people may wish to have a call to acActivateWindow before all actions scripts.

To utilize this functionality, you must define the function(s) you wish S+ to fire using the template(s) below:

Before all actions:
function sp_before_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)
	--your code here
end

After all actions:
function sp_after_action(gnm, gsx, gsy, gex, gey, gwd, gapp, gact)
	--your code here
end

Note that sp_before_action is called after the local variables are set (gnm, gsx, gsy, etc.) so your code can work with them as needed.

edited to reflect function template changes in 1.9.6

Andreasvb

Sweden
46 Posts

Posted - 06/09/2012 :  20:06:05  Show Profile  Reply with Quote
Can you give an example for acActivateWindow?

I tried following:
function sp_before_action(gnm, gsx, gsy, gex, gey, gwd)
	acActivateWindow(nil, gsx, gsy)
end

but I get an error when doing a gesture:
quote:
Lua Script Error!
[string "ActionScript"]:22: <eof> expected near 'end'

Thanks.

Edit:
Seems something happened in the latest version.
My gestures for next/previous tab in Google Chrome is generating that error message.

--acActivateWindow(nil, gsx, gsy)
acSendKeys("{DELAY=50}^{TAB}")
--acActivateWindow(iHandle, nil, nil)


Edit2:
Seems to work if I remove the last line, which shouldn't trigger as it's commented. Bug?



Edited by - Andreasvb on 06/09/2012 20:20:48
Go to Top of Page

Rob

USA
2605 Posts

Posted - 06/09/2012 :  20:37:32  Show Profile  Visit Rob's Homepage  Reply with Quote
I think it's because I didn't add a \n before the after Lua in the code. try adding an Enter (blank line) after a script and see if that resolves it (before I release under that assumption).

Thanks!
Go to Top of Page

Andreasvb

Sweden
46 Posts

Posted - 06/09/2012 :  20:43:53  Show Profile  Reply with Quote
Yes, that seems to work.

I "solved" it by moving it up one step.
Go to Top of Page

Rob

USA
2605 Posts

Posted - 06/09/2012 :  21:08:14  Show Profile  Visit Rob's Homepage  Reply with Quote
Ok, try 1.9.51 and let me know if that works as expected.
Go to Top of Page

Andreasvb

Sweden
46 Posts

Posted - 06/09/2012 :  21:17:16  Show Profile  Reply with Quote
Yes, it works.

And I think the new Lua is working also. :)

Now I can remove all acActivateWindow from each action.
Great addition.

One thing that could be useful is to bypass it on some actions, though it might defeat its purpose as it must look at the action first to see the bypass-string.
Or, have a checkmark to bypass it, and look if it's set instead.

Anyway, thanks for the new version.
Go to Top of Page

Rob

USA
2605 Posts

Posted - 06/09/2012 :  21:22:31  Show Profile  Visit Rob's Homepage  Reply with Quote
You could always add a global var for that. Something like:

StrokesPlus.lua:

bSkipBefore = false  --creates this as a global variable, accessible by action scripts and the before/after functions

function sp_before_action(gnm, gsx, gsy, gex, gey, gwd)

        if bSkipBefore == false then
             --your code here
        end

        --reset the check flag here
        bSkipBefore = false

end

In your action:
bSkipBefore = true
--your code here, the before function will be skipped
Go to Top of Page

Rob

USA
2605 Posts

Posted - 06/09/2012 :  21:23:01  Show Profile  Visit Rob's Homepage  Reply with Quote
I haven't tested that code exactly, but you get the idea =)
Go to Top of Page

Rob

USA
2605 Posts

Posted - 06/09/2012 :  22:43:09  Show Profile  Visit Rob's Homepage  Reply with Quote
Duh, I just realized my poorly thought out code above...the before function fires before the action script, so setting it in the action script would have no effect.

Maybe I'll add some additional variables available to all scripts like app and action name, then you could use those in the before function to determine things like skipping for certain conditions.
Go to Top of Page

Rob

USA
2605 Posts

Posted - 06/10/2012 :  00:38:34  Show Profile  Visit Rob's Homepage  Reply with Quote
I've added app and action name in 1.9.6, this also affects the sp_before_action and sp_after_action function templates. See the release post or help page for details.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000