strokesplus吧 关注:498贴子:970
  • 32回复贴,共1

用鼠标滚轮连续切换窗口手势教程

只看楼主收藏回复

LZ用S+有一阵子了,昨天突然想能不能通过鼠标滚轮来切换窗口呢?类似于ALT+TAB的功能。于是在S+的论坛上查找,还真找到有人提问如何用鼠标右键+滚轮来实现ALT+TAB的功能。据网友和S+作者Rob的讨论,S+的脚本只有按键“按下(Down)”和“弹起(Up)”,没有“按住(Hold)”的功能,直接用acSendKeys()或者acSendAltKeys()都不行,也不是acPreviousApplication(),acNextApplication()这种一次只能换一个窗口的效果,最后还是Rob给出了可行的方案:
首先S+必须是2.6.3以后的版本,当然推荐最新的2.8.2版。官方下载:http://www.strokesplus.com/downloads/推荐大家下载zip版,安装版不能装中文语言包。
中文包:http://www.strokesplus.com/forum/topic/273/chinese,把文件放在S+的根目录即可。
步骤如下:
1.首先在设置中勾上“允许after Release脚本”、“每次鼠标滚轮滚动都触发相应的操作”、“允许在手势键按下时获取修饰键状态”这3项。
2.进入“全局Lua”,在最后加入如下脚本:
bTaskMode = 0
iTaskCount = 0
iTaskPosition = 0
function sp_after_release()
bTaskMode = 0
iTaskCount = 0
iTaskPosition = 0
end
aliencore = alien.core
user32 =aliencore.load("user32.dll")
-- ************ IsIconic************
gIsIconic = user32.IsIconic
gIsIconic:types{ ret ='long', abi = 'stdcall', 'long'}
function aIsIconic(iWnd)
return gIsIconic(iWnd)
end
3.回到“配置操作”的页面(就是设置手势那),在“全局操作”下点击“添加操作”,操作名就叫“Scroll Up”,然后在右侧选择空白手势,勾选“鼠标滚轮向上”,并在lua脚本中写下如下代码:
if bTaskMode == 0 then
bTaskMode = 1
acGetAllWindows(1)
for num, handle in pairs(sp_all_windows) do
iTaskCount = iTaskCount + 1
end
end
local iStartingPosition =iTaskPosition
::top::
iTaskPosition =iTaskPosition - 1
if iTaskPosition < 0 then
iTaskPosition = iTaskCount-1
end
--get the window class totest for excluded windows
local sClass =acGetClassName(sp_all_windows[iTaskPosition],0,0)
--exclude these windows
if sClass ~="SearchPane" and sClass ~= "Shell_CharmWindow"
and sClass ~="ImmersiveLauncher" and sClass ~= "Snapped Desktop"
and sClass ~="ImmersiveBackgroundWindow" and sClass ~= "NativeHWNDHost"
and sClass ~="MetroGhostWindow" then
--if the window is minimized, restore it
if aIsIconic(sp_all_windows[iTaskPosition]) ~= 0 then
acRestoreWindow(sp_all_windows[iTaskPosition])
end
--activate the window
acActivateWindow(sp_all_windows[iTaskPosition])
else
--the line below ensures the script won't get stuck in arecursive loop
--if there are only excluded windows present
if iTaskPosition ~= iStartingPosition then
goto top
end
end
4.同理又在“全局操作”下点击“添加操作”,操作名就叫“Scroll Down”,然后在右侧选择空白手势,勾选“鼠标滚轮向下”,并在lua脚本中写下如下代码:
if bTaskMode == 0 then
bTaskMode = 1
acGetAllWindows(1)
for num, handle in pairs(sp_all_windows) do
iTaskCount = iTaskCount + 1
end
end
local iStartingPosition =iTaskPosition
::top::
iTaskPosition =iTaskPosition + 1
if iTaskPosition >=iTaskCount then
iTaskPosition = 0
end
--get the window class totest for excluded windows
local sClass =acGetClassName(sp_all_windows[iTaskPosition],0,0)
--exclude these windows
if sClass ~= "SearchPane"and sClass ~= "Shell_CharmWindow"
and sClass ~="ImmersiveLauncher" and sClass ~= "Snapped Desktop"
and sClass ~="ImmersiveBackgroundWindow" and sClass ~= "NativeHWNDHost"
and sClass ~="MetroGhostWindow" then
--if the window is minimized, restore it
if aIsIconic(sp_all_windows[iTaskPosition]) ~= 0 then
acRestoreWindow(sp_all_windows[iTaskPosition])
end
--activate the window
acActivateWindow(sp_all_windows[iTaskPosition])
else
--the line below ensures the script won't get stuck in a recursiveloop
--if there are only excluded windows present
if iTaskPosition ~= iStartingPosition then
goto top
end
end
5.点击确认。
这样就可以通过按下右键,在不松开右键的情况下滚动滚轮来连续的切换窗口了!
附上两幅截图:



IP属地:四川1楼2014-04-22 14:44回复
    好资源,非常感谢


    2楼2014-05-01 08:01
    回复
      2025-05-15 21:42:10
      广告
      试了下 真的成功了
      PS、安装版也可以用语言包 下载文件名中有ansi的就没问题


      IP属地:上海3楼2014-05-15 09:35
      回复
        谢谢你!


        4楼2015-08-08 01:41
        回复
          非常感谢分享


          IP属地:广东5楼2016-02-29 17:21
          收起回复
            中文版照样可以,非常实用,谢谢LZ!!!


            IP属地:湖南6楼2016-03-09 23:02
            收起回复
              向你请教一个问题:如何实现按下右键激活当前窗口,我是win764系统,有些窗口用手势总是关不掉,一定要左键点击一下激活才能用手势关掉,一直也没找到解决的办法!


              IP属地:湖南7楼2016-03-13 00:01
              收起回复
                @owlwen
                --窗口 - 关闭同类全部窗口
                gShowScreenMessage("关闭同类全部窗口", 1, gsx, gsy) --显示文本
                local exe_name = acGetExecutableName(acGetOwnerWindowByPoint(gsx, gsy),0,0)
                -- get all windows and search for exe_name
                acGetAllWindows(1)
                for num, handle in pairs(sp_all_windows) do
                -- close all application for exe_name
                local exe = acGetExecutableName(handle,0,0)
                if exe == exe_name then
                acCloseApplication(handle, nil, nil)
                end
                end


                IP属地:浙江8楼2016-03-13 14:23
                收起回复