StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
2014218866  
#1 Posted : Friday, May 31, 2019 1:56:14 PM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

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.



Rob  
#2 Posted : Friday, May 31, 2019 3:33:59 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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
2014218866  
#3 Posted : Saturday, June 1, 2019 3:47:50 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

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?
Rob  
#4 Posted : Saturday, June 1, 2019 6:17:04 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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}");
}
2014218866  
#5 Posted : Saturday, June 1, 2019 8:54:08 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

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.
Rob  
#6 Posted : Saturday, June 1, 2019 3:01:10 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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.
zyxi  
#7 Posted : Saturday, June 1, 2019 3:22:36 PM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

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!
2014218866  
#8 Posted : Saturday, June 8, 2019 9:41:46 AM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

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.
Rob  
#9 Posted : Saturday, June 8, 2019 12:14:34 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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.
Rob  
#10 Posted : Saturday, June 8, 2019 12:43:38 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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

zyxi  
#11 Posted : Saturday, July 6, 2019 12:30:11 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

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.
Rob  
#12 Posted : Tuesday, July 9, 2019 1:30:52 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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
}
zyxi  
#13 Posted : Wednesday, July 10, 2019 10:20:15 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

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.
Rob  
#14 Posted : Wednesday, July 10, 2019 3:59:41 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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
}
zyxi  
#15 Posted : Thursday, July 11, 2019 5:08:00 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

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.
Rob  
#16 Posted : Thursday, July 11, 2019 1:39:59 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 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.
Rob  
#17 Posted : Thursday, July 11, 2019 1:52:29 PM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 1,349
United States
Location: Tampa, FL

Thanks: 28 times
Was thanked: 416 time(s) in 354 post(s)
You shouldn't get the error message in 0.3.2.6.
zyxi  
#18 Posted : Friday, July 12, 2019 12:22:20 AM(UTC)
zyxi

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 3/30/2019(UTC)
Posts: 74
China

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.
2014218866  
#19 Posted : Saturday, April 25, 2020 2:23:18 PM(UTC)
2014218866

Rank: Advanced Member

Reputation:

Groups: Approved
Joined: 5/6/2019(UTC)
Posts: 111
China

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.
Users browsing this topic
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.