StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
use one gesture that does different actions
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Hello everyone
is it possible to use one gesture that does different actions by depending on the file type?
1)use one gesture that does different actions
as an example: by doing the up gesture it could do for - .exe and folders: open it - .gif : Open the location of the file - .rar: unpack it - .mp4: play it - if its a marked text: copy it and similar things.
2)Different software performs different functions
in EXCEL.EXE , WORD.EXE and POWERPOINT.EXE:it can achieve "ENTER" , but in chrome.exe and Acrobat.exe it's "^{TAB}"
3)Different gestures are performed in different areas:
For example, the window is divided into 6 rows and 6 columns. In first row it executes "right" and in column 3 executes "up" but it performs "left" in the fourth column in the second row.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
1) This is somewhat possible, but you will likely run into a lot of challenges trying to get it to work just right. See the Script Help window, Operation System > GetSelectedFilesInExplorer You will have to handle different scenarios like if the file is already selected, selecting if not, handling if multiple files are selected, etc. This also only works in the main (right) pane of explorer, not on the left tree view
2) It might be easier to just make new applications for these apps, using the same gesture, but different scripts. But you can do this within an action's script if you want, via checking the main process's EXE name, e.g. if(action.Window.Process.MainModule.ModuleName == "chrome.exe") {//your code here}
3) See Regions - You can define these under an application's App Definition tab, or for Global Actions under the Settings tab. You can also perform region calculations manually in a script, see the Script Help window > Regions section
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
OK, but there is a question in the main process's EXE name ,
var exeName = action.Window.Process.MainModule.ModuleName; if ( exeName == "chrome.exe"|| "Acrobat.exe"||"WORD.EXE"){ sp.SendKeys("^{TAB}")}
All three software can't work properly or one of them doesn't work, especially after restarting the computer
Can you help me solve this problem?
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
I haven't tested this, but your if logic wasn't correct: Code:var exeName = action.Window.Process.MainModule.ModuleName;
if (exeName == "chrome.exe" || exeName == "Acrobat.exe" || exeName == "WORD.EXE"){
sp.SendKeys("^{TAB}");
}
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Well, I have tried this before asking the question, but the result is the same. Only if each “if logic” is separated can it work properly I don't know if my logic is wrong or if it's a bug.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
This is pretty simple code, so there's definitely not a bug. However, you might need to do some testing or debugging to find where the logic issue is. I did this on my system to copy the exeName to the clipboard so I could see the string being compared: Code:var exeName = action.Window.Process.MainModule.ModuleName;
clip.SetText(exeName); //See what the exeName variable is
if (exeName == "chrome.exe" || exeName == "Acrobat.exe" || exeName == "WINWORD.EXE"){
sp.SendKeys("^{TAB}");
}
I found that WORD.EXE for me was WINWORD.EXE, so I changed it to that, the gesture works fine in Chrome and Word; I don't have Acrobat installed, so I can't test that one.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
Dear, Rob
I know what you mean. There should be a logic problem. I'll debug it further to find out why.
Thank you for taking your precious time to answer my questions.
Best wishes!
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Hello, dear Rob. Thank you for your prompt. I also want to ask a question if you like. I set hiding gesture traces In the Global Actions, but I want to let “Snip Screen Area” draw gesture traces alone. Is this possible?
Thank you.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Unfortunately not. There's no way S+ can know it will be the Snip Screen Area gesture until you've already drawn most of it.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
The only thing I can think of is if you made a separate action or hot key to toggle the gesture tracing with this script: Code:sp_config.DrawGesture = true;
Then add this to the end of the Snip Screen Area script to turn the gesture tracing off again: Code:sp_config.DrawGesture = false;
So you would execute the first action to turn on tracing, then draw the Snip Screen Area gesture. Edited by user Saturday, June 8, 2019 12:44:41 PM(UTC)
| Reason: Not specified
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
Hello, everyone.
I want to know if this function ("GetSelectedFilesInExplorer") can achieve the following functions. If the selected file is only one recycle bin, it is emptied. If the selected file is only this computer, it will start the task manager. If any other file (one or more) is selected, it will perform deletion.
It's a little difficult for me to implement this function. So I need your help. Thank you for your reply.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
This worked for me. Just note that sp.GetSelectedFilesInExplorer only works in the right panel of a File Explorer window, it doesn't work on the Desktop nor in the left side tree view in File Explorer. This is not something I created, it already existed as a call using Microsoft's SHDocVw object, so I can't just make it work for other panels/windows. Code:var files = sp.GetSelectedFilesInExplorer(action.Window.HWnd);
if(files.Length == 1 && files[0] == "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}") {
//This PC/My Computer/This Computer
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.ESCAPE]);
} else if(files.Length == 1 && files[0] == "::{645FF040-5081-101B-9F08-00AA002F954E}") {
//Recycle Bin
sp.EmptyRecycleBins();
} else if(files.Length > 0) {
//At least one file is selected
sp.SendVKey(vk.DELETE);
} else {
//No files selected
}
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
I've tried this feature myself, and it doesn't work on the desktop either. This is indeed a pity. But thank you all the same, Rob.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
I've added a new function, sp.GetSelectedFilesOnDesktop() in 0.3.2.5 which (hopefully) works right on different systems and configurations. It doesn't use a clean shell/COM method of getting the desktop items, just SendMessage requesting the ListView items, etc...so I wouldn't be surprised if it runs into problems for some people or after a later Windows update. Code:var files = sp.GetSelectedFilesOnDesktop();
if(files.Length == 1 && files[0] == "This PC") {
//This PC/My Computer/This Computer
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.ESCAPE]);
} else if(files.Length == 1 && files[0] == "Recycle Bin") {
//Recycle Bin
sp.EmptyRecycleBins();
} else if(files.Length > 0) {
//At least one file is selected
sp.SendVKey(vk.DELETE);
} else {
//No files selected
}
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
Dear Rob, it works perfectly on my computer. Thank you very much for improving S+. By the way, since version 0.3.2.4, when I started S+, It always prompted for errors. It couldn't find the C++ execution environment, Shcore. DLL 126, and it couldn't find the specified module. But in fact, I have installed the VC2015 you provided in my computer. I don't know why.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
Ah, I added some extra error messaging to better diagnose someone else having a VC runtime issue, but I forgot about another call made to that function to check if SHCore.DLL exists, so it shouldn't show a message there as it's not critical.
What version of Windows do you have? SHCore.DLL should be there for Windows 8.1 and later.
|
|
|
|
Rank: Administration
Groups: Translators, Members, Administrators Joined: 1/11/2018(UTC) Posts: 1,359 Location: Tampa, FL Thanks: 28 times Was thanked: 419 time(s) in 356 post(s)
|
You shouldn't get the error message in 0.3.2.6.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 3/30/2019(UTC) Posts: 74 Thanks: 8 times Was thanked: 1 time(s) in 1 post(s)
|
My computer system is Win7. Both computers have this problem. The latest edition has solved this problem. Thank you, Rob.
|
|
|
|
Rank: Advanced Member
Groups: Approved
Joined: 5/6/2019(UTC) Posts: 111 Thanks: 19 times Was thanked: 1 time(s) in 1 post(s)
|
Code:var files = sp.GetSelectedFilesOnDesktop();
if(files.Length == 1 && files[0] == "This PC") {
//This PC/My Computer/This Computer
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.ESCAPE]);
} else if(files.Length == 1 && files[0] == "回收站") {
//Recycle Bin
sp.EmptyRecycleBins();
} else if(files.Length > 0) {
//At least one file is selected
sp.SendVKey(vk.DELETE);
}else {
sp.SendModifiedVKeys([vk.LCONTROL,vk.LSHIFT], [vk.VK_N]);
}
This script cannot create new files in other folders, but it can delete some files in other folders. I don't know why. I want to implement the following functions: if the recycle bin is selected, then S + will empty the recycle bin; if the file is selected, S + will delete it, if the file is not selected, S + will create a new folder, the above script will work normally on the desktop , But it does not work properly in non-desktop folders.
|
|
|
|
StrokesPlus.net Forum
»
General Discussion
»
Scripts
»
use one gesture that does different actions
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.
Important Information:
The StrokesPlus.net Forum uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close