This App is No Longer Maintained. Visit the Replacement at StrokesPlus.net

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

 All Forums
 Lua Scripts
 General Action Scripts
 Looking to have StrokesPlus do something?
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Rob

USA
2615 Posts

Posted - 02/19/2012 :  19:38:10  Show Profile  Visit Rob's Homepage
Don't be afraid to post. Sometimes I see people are searching Google for various "strokesplus" + {do something in particular}.

I'm happy to make a script to handle most common things. Just post here and I'll definitely respond and most likely with a functioning script for you.

Rob

zosix

8 Posts

Posted - 02/28/2012 :  17:48:13  Show Profile
Hi Rob and thanks for StrokesPlus - very light, quick and powerful - (donation coming your way)

i'm trying to send a key which i cannot find mapped anywhere for UK keyboard: it is the backslash [\] - which in uk sits next to the left shift. i found VK_OEM_5 (US) - tried different numbers but no luck.

do you know it?

Thanks
Max
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/28/2012 :  17:54:08  Show Profile  Visit Rob's Homepage
Out of curiosity, have you entered it with an escaping backslash? Lua strings must have special characters, like \, escaped.

Meaning something like this:

acSendKeys("\\")

Which would only send a single backslash.

Just trying to eliminate the quick solutions first :-)

Responding from my phone, so I can't test anything out at the moment, but let me know!
Go to Top of Page

zosix

8 Posts

Posted - 02/28/2012 :  18:01:45  Show Profile
Rob, thanks for the quick reply - will give it a try.. (edit: it works!!)

incidentally whenever you have time, could you show me how to script 'show windows side by side'.

it is not in the 'window placement actions' but i find it very useful..no hurry


Edited by - zosix on 02/28/2012 18:03:05
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/28/2012 :  18:05:00  Show Profile  Visit Rob's Homepage
Sure, I'll put something together for side-by-side. Sounds like something a lot of folks may find useful.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/28/2012 :  18:06:06  Show Profile  Visit Rob's Homepage
Glad to hear it's working for you!
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/28/2012 :  18:12:13  Show Profile  Visit Rob's Homepage
Just post an example scenario for side-by-side, keeping in mind that S+ needs some way to identify the windows in question. Immediately, I envision a gesture which you start drawing on one window and end the gesture on the other. Then the lua would get each window and resize/reposition based on the size of the monitor, probably the using the screen on which the first window resides (to handle multiple monitors).

Does that make sense?
Go to Top of Page

zosix

8 Posts

Posted - 02/28/2012 :  18:25:56  Show Profile
your idea is more advanced than mine, and sounds very interesting being able to choose the windows to snap..

in my case would simply be to tile the already opened windows vertically
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/28/2012 :  19:31:36  Show Profile  Visit Rob's Homepage
What's funny is that resizing all open windows is actually the more challenging request, considering that I'd have to loop through all open windows. Not this it's something which can't be done, but would require a new action to be built into S+ to provide that functionality.

However, this script will do what I mentioned above. Ideally, you would select a sweeping gesture, like I used X to test this script. X starts on the left and ends on the right, ensuring both the start and end window can be landed on during the gesture. Where this falls short is when you have two windows open (one maximized in front of you) and you just want to tile both, as with this script, both windows have to be in view, so the gesture start/ends on them both. Hopefully that makes sense. I'll add tile vertical/horizontal actions to the TODO list. In the meantime, this should give you the idea of how to do it from this perspective.

Honestly, you could even tweak this to handle the other scenario. Get the window in the foreground, then minimize it and get the window below, then restore the first and the core of this script would take care of the positioning. S+ is very powerful and granular; I don't think there are many (if any) people who have really flexed its power. This is actually the most complex action I think I've put together thus far too!

NOTE: The action help for acSetWindowSize is wrong, it doesn't accept left and top. I've updated the Help on the website and will include the updated local files in the next release. (I decided to leave that up to acMoveWindow but never updated the files)

Lua Script: (everything below is fine, lines starting with "--" are comments which the Lua engine will ignore)

--Get the window below where the gesture began
local hFirstWindow = acGetOwnerWindowByPoint(gsx, gsy)

--Get the window below where the gesture ended
local hSecondWindow = acGetOwnerWindowByPoint(gex, gey)

--Get the screen dimensions, work area only for the monitor where the gesture began
local hScreen = acGetMonitorFromPoint(gsx, gsy)
local iScreenRight = acGetMonitorRight(hScreen, 1)
local iScreenLeft = acGetMonitorLeft(hScreen, 1)
local iScreenWidth = iScreenRight - iScreenLeft
local iScreenBottom = acGetMonitorBottom(hScreen, 1)
local iScreenTop = acGetMonitorTop(hScreen, 1)
local iScreenHeight = iScreenBottom - iScreenTop

--Restore both windows (in case either are Maximized)
acRestoreWindow(hFirstWindow, 0, 0)
acRestoreWindow(hSecondWindow, 0, 0)

--Move them into position
acMoveWindow(hFirstWindow, 0, 0, iScreenLeft, iScreenTop)
acMoveWindow(hSecondWindow, 0, 0, iScreenLeft+(iScreenWidth/2), iScreenTop)

--Size them accordingly
acSetWindowSize(hFirstWindow, 0, 0, iScreenWidth/2, iScreenHeight)
acSetWindowSize(hSecondWindow, 0, 0, iScreenWidth/2, iScreenHeight)
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/28/2012 :  19:49:33  Show Profile  Visit Rob's Homepage
Also, see this post for info about Lua strings:

http://www.strokesplus.com/forum/topic.asp?TOPIC_ID=85
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/28/2012 :  20:02:14  Show Profile  Visit Rob's Homepage
..and see my second comment here for an even fancier way of picking the two windows you want tiled:

http://www.strokesplus.com/forum/topic.asp?whichpage=1&TOPIC_ID=255
Go to Top of Page

zosix

8 Posts

Posted - 02/29/2012 :  04:08:27  Show Profile
that works, handy when you actually want to choose which windows to tile.

meantime i found this
http://www.vistax64.com/tutorials/144512-show-windows-stacked-side-side-create-shortcuts.html

inside the sidebyside.vbs file i found this - don't know if it is useful - inside are these commands:
dim objShell
set objShell = CreateObject("Shell.Application")
objShell.TileVertically
set objShell = nothing


will try assign the sidebyside.vbs to a S+ action.



Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/29/2012 :  09:28:09  Show Profile  Visit Rob's Homepage
That should work fine for the interim. I should note that when I said it would be more challenging, I just meant in the sense that there's no script I could give you to do it. Adding the actions into S+ will be pretty easy and will likely have them in today or tomorrow...weekend at the latest. There's already code for looping through windows (like for acFindWindow), I just have to add an extra parameter to get the screen dimensions, sum the total visible windows, divide the available space, and tile them accordingly.

But at least you found a workaround for the interim!

By the way, acShellExecute is likely what you want to use, then you can just specify the VBS file instead of running wscript and passing it in as a parameter.
Go to Top of Page

zosix

8 Posts

Posted - 02/29/2012 :  11:01:19  Show Profile
i tried this but no 'luck'

acShellExecute(open, SideBySide.vbs, , C:\\- APPZ\\SHELL\\StrokesPlus\\- SCRIPTS\\ShowWindows\\, hidden)

still.. i placed a link to the vbs on the taskbar - assigned a key shortcut and then made S+ run the key - this works fine.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/29/2012 :  11:39:33  Show Profile  Visit Rob's Homepage
The template which is inserted isn't code-ready.

It would have to be something like:

acShellExecute("open", "SideBySide.vbs", "", "C:\\- APPZ\\SHELL\\StrokesPlus\\- SCRIPTS\\ShowWindows\\", 0)

The last parameter must be a number, from the nShowCmd parameter listed here (0 = SW_HIDE [hidden]):

http://msdn.microsoft.com/en-us/library/windows/desktop/bb762153 v=vs.85 .aspx

S+ is definitely more of an advanced gesture app, considering that scripting experience is almost required; so I expect some folks to have difficulties, which is why I want them to post (like you did) when they're simply stumped =)

In other news, I've added acTileWindows to 1.7.3. There may be some problem apps (like MediaMonkey with full skinning enabled) which don't behave, but it seems to work for me thus far. I'm sure I'll continue to fine-tune it.

So you would call acTileWindows(1,0) to tile open windows vertically on the current screen the app under the gesture resides on. Though, there's no reason you can't use the shortcut key and VBS file too =)
Go to Top of Page

zosix

8 Posts

Posted - 02/29/2012 :  12:19:01  Show Profile
Rob, thanks for the explanation - i think i get a bit more about the sintax now.. 1.73 is working just great (win 7 x64)

i'm sure more questions will be on the way - i tried a quite a few gesture apps - but this is the best i've tried... Many Thanks!


EDIT: apart from pressing an ignore key - i haven't found a keyboard shortcut to temporarily disable S+. perhaps it would be good to have..

Edited by - zosix on 02/29/2012 12:23:20
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/29/2012 :  14:16:03  Show Profile  Visit Rob's Homepage
CTRL+SHIFT+WIN+Z

=)
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/29/2012 :  14:53:25  Show Profile  Visit Rob's Homepage
Double-clicking the tray icon and acDisable() will disable S+ as well.
Go to Top of Page

skurdifur

Iceland
12 Posts

Posted - 02/29/2012 :  16:54:01  Show Profile
Hey Rob and thanks again for your great support on your brilliant app!

When I used StrokeIt before I switched to your app, I had a gesture to type in a password for some websites and email client at work. I haven´t digged so much into the programming in S+, so I´m a bit lost how to do a simple typing of password when a certain site or application is up in S+?

Can you show a simple code for how to managed that?

Thanks!
bjarki rafn
Go to Top of Page

Rob

USA
2615 Posts

Posted - 02/29/2012 :  19:57:43  Show Profile  Visit Rob's Homepage
Have you checked out the post here? http://www.strokesplus.com/forum/topic.asp?TOPIC_ID=25

In the most simplest form, you would just use acSendKeys("yourpassword"). Now, all that would do is send "yourpassword", so the focus would have to be in the password field, this also doesn't press enter.

So you start with the basics and build up! For example, from the post above:

This line gets the title of the window and stores it into the variable (like a container) named sTitle; "local" just says don't save the sTitle container after this script is done. I use this to identify what website I'm at. Note that this would be the full title, like when you hover the mouse over the taskbar button when you're at the website/program. You don't HAVE to do this, I only do because I have one large login script which goes through a bunch of different titles, using a different method/account info depending on the website.

local sTitle = acGetWindowTitle(nil,sp_gesture_start_x, sp_gesture_start_y)

Here, I'm checking to see if the title matches the title when I am at my bank's website. Note that one = sign is an assignment, meaning set something to equal something. Two = signs is a comparison; is something equal to something.

if sTitle == "Publix Employees Federal Credit Union - Google Chrome" then

If the browser is at my bank's website, send the TAB key 3 times, that puts the focus in the USERNAME field (just test this out on your own, walk through what keys you'd have to press to get to the right fields)

acSendKeys("{DELAY=50}{TAB}{TAB}{TAB}")

Wait for 40 milliseconds, you'll find delays are helpful to ensure the program/browser has had a chance to process the keyboard messages

acDelay(40)

Now, type my username and press Enter (~)

acSendKeys("{DELAY=50}username~")

Wait 3000 ms (3 seconds) for the password page to load (the way my bank does it)

acDelay(3000)

Now, send my password and press Enter (~) (the password field automatically has focus on that page, so I don't need to send the TAB key at all)

acSendKeys("{DELAY=50}password~")

The next line just closes the "if sTitle == "Publix Employees Federal Credit Union - Google Chrome" then" above, each IF has an END to define what should happen IF the condition is met, but after END, that code would execute regardless.

end
Go to Top of Page

skurdifur

Iceland
12 Posts

Posted - 03/01/2012 :  06:15:17  Show Profile
Brilliant! I'll give it a spin!

Thanks!
Go to Top of Page

heydre

1 Posts

Posted - 11/14/2012 :  00:32:05  Show Profile
Rob....been using S+ with Firefox and Chrome. Plays nice with Windows/Apps but noticing a weird issue with a script for closing a tab.

If you load/play a video in a tab and then stop it you can't close the tab with the gesture. If you switch to another tab and back to it or reload the tab then you gesture it will close it. My tab close script is:

acSendKeys("{DELAY=50}^w")

Any ideas?
Go to Top of Page

breakcore

Russia
74 Posts

Posted - 11/14/2012 :  06:47:31  Show Profile
quote:
Originally posted by heydre

Rob....been using S+ with Firefox and Chrome. Plays nice with Windows/Apps but noticing a weird issue with a script for closing a tab.

If you load/play a video in a tab and then stop it you can't close the tab with the gesture. If you switch to another tab and back to it or reload the tab then you gesture it will close it. My tab close script is:

acSendKeys("{DELAY=50}^w")

Any ideas?



This is probably not a S+ issue. Some flash player interfaces override the browser keyboard shortcuts. You can try to click to the empty area of the page and then make a gesture.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 11/14/2012 :  08:58:44  Show Profile  Visit Rob's Homepage
breakcore is correct.

See this thread: http://www.strokesplus.com/forum/topic.asp?TOPIC_ID=332
Go to Top of Page

Chris

28 Posts

Posted - 03/18/2013 :  03:43:29  Show Profile
I was trying to make a "disable StrokesPlus temporarily on currently active windows" script, but it won't work.

Here's the script that I made:
local iHandle = acGetForegroundWindow()
local iHandle2 = acGetForegroundWindow()
while iHandle == iHandle2 do
iHandle2 = acGetForegroundWindow()
acDelay(300)
end

Basically I want the script to tell S+ to always on the Delay loop (thus, S+ is disabled) when current active window is still active (iHandle). And when active window (iHandle) is not active anymore, S+ will work normally again.
I think it is useful for apps that always on full screen mode which give users difficulties using "Find Window" feature in order to put them on ignore list. Or would be useful for users who don't want to use ignore list. And also, this way, users can disable S+ immediately when users forgot to disable S+ via tray or forgot the hot-keys.
That script would make me to keep on the while loop.

One more question, I tried the {VOLUP} command. It seemed wouldn't work on my computer. The acToggleMute() works ok tho. Maybe it needs specific services on XP?

Edited by - Chris on 03/18/2013 14:48:32
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/18/2013 :  17:00:55  Show Profile  Visit Rob's Homepage
Yes, {VOLUP} just sends the keystroke, an app or Windows would need to do something with it.

These should work fine:
Volume Up:
local iVolume = 0
iVolume = acGetVolume()
iVolume = iVolume + ((sp_wheel_delta / 1200) * 20)
if iVolume > 100 then
iVolume = 100
end
if iVolume < 0 then
iVolume = 0
end
acSetVolume(iVolume, 0)


Volume Down:
local iVolume = 0
iVolume = acGetVolume()
iVolume = iVolume + ((sp_wheel_delta / 1200) * 20)
if iVolume > 100 then
iVolume = 100
end
if iVolume < 0 then
iVolume = 0
end
acSetVolume(iVolume, 0)


Regarding your script, I see what you're trying to do and if it weren't for the fact that disabling S+ causes the Lua states to be destroyed, that might have been an option (though there's no acEnable() action, either). If your mouse doesn't have an X2 button (or if it wouldn't need to be used in this scenario), you could simply change the stroke button to X2 while the window is active, then change it back to Right when something else gains focus:
local iHandle = acGetForegroundWindow()
local iHandle2 = acGetForegroundWindow()
while iHandle == iHandle2 do
acPostMessage(acFindWindow("STROKESPLUS"),273,136) --set X2 as the stroke button	
iHandle2 = acGetForegroundWindow()
acDelay(300)
end
acPostMessage(acFindWindow("STROKESPLUS"),273,125) --set Right as the stroke button
Not a perfect solution, but might work fine for now.
Go to Top of Page

Chris

28 Posts

Posted - 03/19/2013 :  07:35:17  Show Profile
Smart workaround. Thank you.

Now, I was thinking to create an automated scroll with StrokesPlus.
This how it works: when I fire the gesture, the script will store the current mouse position. And while holding the Stroke button, when I move the mouse lower than the initial position, the script will scroll down automatically slowly. And if I move further below from the initial position, the script will scroll faster.
And after, I could simply release the Stroke button.
Maybe it can be used to scroll left n right, to make things faster and easier.
The scrolling action can be done from the link you provided me before:
http://www.strokesplus.com/forum/topic/469/ctrlwheel-up-impossible-with-lua

However, after looking through the Action Functions, I could not find function that could check whether the Stroke button is down or up. With the current release, can it be done?
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/19/2013 :  09:51:07  Show Profile  Visit Rob's Homepage
No, however you can use alien to call the GetKeyState Windows API call.

For the Global Lua tab code, you may need to tweak if you already have alien defined, etc. In the action script, the delay is so you can allow the script time to wait for the S+ Cancel Delay timer to lapse; if you hold the right button, S+ consumes it until the Cancel Delay has passed (Windows won't think it's down during the time where S+ has the right button captured). So you execute the action (letting go of right button), then press and hold right button quickly after (for the purposes of this test) and keep it held until the delay is over, then you'll see a message showing you if the button is down (can do left and right at the same time as well).


Global Lua tab:
aliencore = alien.core
user32 = aliencore.load("user32.dll")

-- ************ GetKeyState ************

VK_LBUTTON = 0x01
VK_RBUTTON = 0x02

gGetKeyState = user32.GetKeyState
gGetKeyState:types{ ret = 'short', abi = 'stdcall', 'uint' }

function aGetKeyState(VK)
	return gGetKeyState(VK)
end

Action:
acDelay(3000)
local bRight = false
local bLeft = false
local iRightKeyState = 0
local iLeftKeyState = 0
iRightKeyState = aGetKeyState(VK_RBUTTON)
iLeftKeyState = aGetKeyState(VK_LBUTTON)
if bit32.band(iRightKeyState,0x80) ~= 0 then
	bRight = true
end
if bit32.band(iLeftKeyState,0x80) ~= 0 then
	bLeft = true
end
--acMessageBox(iRightKeyState,"iRightKeyState Value",nil)
--acMessageBox(iLeftKeyState,"iLeftKeyState Value",nil)
if bRight then
	acMessageBox("Right button down","GetKeyState Return Value",nil)
end
if bLeft then
	acMessageBox("Left button down","GetKeyState Return Value",nil)
end

The action code could certainly be refactored to be much smaller, but I like to post scripts in a verbose form as it's easier for novices to follow.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/19/2013 :  11:07:50  Show Profile  Visit Rob's Homepage
FYI, version 2.7.1 now includes acDisableCapture() and acEnableCapture(), which is what you really needed. It disables just the capture, hotkeys still work and the Lua states are maintained, but S+ doesn't accept gestures nor interfere with right mouse button events.
local iHandle = acGetForegroundWindow()
local iHandle2 = acGetForegroundWindow()
while iHandle == iHandle2 do
acDisableCapture()
iHandle2 = acGetForegroundWindow()
acDelay(300)
end
acEnableCapture()
Go to Top of Page

Chris

28 Posts

Posted - 03/19/2013 :  23:20:55  Show Profile
Yes, it works. However the delay, to wait for the Cancel Delay to lapse, is slowing things down. I think I will use the left button to signal the end of the scrolling session.

Is there a simple but nice way to know whether the Lua is currently still working or not? Maybe like an indicator or something? I could simply move a small circle window below the mouse when a script runs, and remove it when the script ends using acMoveWindow. But, maybe there's an official way from StrokesPlus?
Anyway, I noticed acKillDisplayText on the help doesn't work.
http://www.strokesplus.com/help/#ActionReport

Thank's for the acDisableCapture() and acEnableCapture(). Can be useful for gamers, I had problem with game when I hold shift and press right mouse button.
Oh, and nice description on the Change Log.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/19/2013 :  23:36:59  Show Profile  Visit Rob's Homepage
No, there's no way official way to know if Lua is still executing. I'll keep that in mind when I tinker.

Fixed the link, thanks!
Go to Top of Page

aShai33

21 Posts

Posted - 07/28/2013 :  16:00:01  Show Profile
Okay Rob, I've been trying to find a script to open S+ config actions window, any help would be greatly appreciated.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 07/28/2013 :  16:18:33  Show Profile  Visit Rob's Homepage
acShowActions()
Go to Top of Page

aShai33

21 Posts

Posted - 07/28/2013 :  16:40:18  Show Profile
quote:
Originally posted by aShai33

Okay Rob, I've been trying to find a script to open S+ config actions window, any help would be greatly appreciated.



Awesome, Thanks!!!!!!!
Go to Top of Page

aShai33

21 Posts

Posted - 07/28/2013 :  22:42:32  Show Profile
Hi Rob I've been trying to make a script to open recycle bin, but I'm having a problem with the full path. Any help again would be appreciated.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 07/28/2013 :  22:48:38  Show Profile  Visit Rob's Homepage
This works on my system:
acShellExecute("open", "::{645FF040-5081-101B-9F08-00AA002F954E}", "", "", 1)

Note the first time I ran, it took a moment for Windows to show the window; probably since it's a virtual object and I hadn't opened it recently.
Go to Top of Page

aShai33

21 Posts

Posted - 07/28/2013 :  23:08:42  Show Profile
quote:
Originally posted by Rob

This works on my system:
acShellExecute("open", "::{645FF040-5081-101B-9F08-00AA002F954E}", "", "", 1)

Note the first time I ran, it took a moment for Windows to show the window; probably since it's a virtual object and I hadn't opened it recently.


Perfecto ........
Go to Top of Page

aShai33

21 Posts

Posted - 08/02/2013 :  02:04:03  Show Profile
Hi Rob now I'm trying to make a script to open MS Office Word 2010 but I'm having a problem with the full path like the recycle bin. Any help again would be appreciated.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 08/02/2013 :  15:31:28  Show Profile  Visit Rob's Homepage
The only thing I can suggest is to browse to Word.exe, probably under Program Files/Microsoft Office (?) from the Run box (Start -> Run or Win+R). Once you've selected Word.exe and get back to the Run box, copy the entire path, then change each \ with \\ and you should be good to go.
Go to Top of Page

aShai33

21 Posts

Posted - 08/02/2013 :  18:14:42  Show Profile
quote:
Originally posted by Rob

The only thing I can suggest is to browse to Word.exe, probably under Program Files/Microsoft Office (?) from the Run box (Start -> Run or Win+R). Once you've selected Word.exe and get back to the Run box, copy the entire path, then change each \ with \\ and you should be good to go.


Yeah I've pretty much tried everything before seeking your counsel, I think the path is similar to the one you provided me with in reference to the recycle bin. I'll keep searching. Thanks
Go to Top of Page

Rob

USA
2615 Posts

Posted - 08/03/2013 :  14:06:39  Show Profile  Visit Rob's Homepage
Hmm, I only have Office 2007, but this works for me:

acShellExecute("open", "C:\\Program Files (x86)\\Microsoft Office\\Office12\\WINWORD.EXE", "", "", 1)
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
StrokesPlus Forum © 2011-2018 Rob Yapchanyk Go To Top Of Page
Snitz Forums 2000