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

Notification

Icon
Error

Options
Go to last post Go to first unread
dodying  
#1 Posted : Thursday, April 4, 2019 9:08:40 AM(UTC)
dodying

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/4/2019(UTC)
Posts: 3

How to recur:
1. set the hotkey written below
2. keydown ctrl, keydown c, keyup c
3. keydown c, keyup c
4. keyup ctrl

What happen:
the word "c" is put in

Desired result:
no "c", and popupMenu shown


Hotkey: Control+C
Script:
Code:

sp.SendModifiedVKeys([vk.LCONTROL], [vk.VK_C])
// sp.ConsumePhysicalInput(true)

var interval = 1
var browser = 'D:\\GreenSoftware\\_Basis\\CentBrowser\\chrome.exe'
var lists = [
  {
    name: 'AlternativeTo(&A)',
    url: 'https://alternativeto.net/browse/search/?q=%clipboard%&ignoreExactMatch=true'
  },
  {
    name: 'NsaneForums(&N)',
    sep: true,
    url: 'https://duckduckgo.com/?q=%clipboard%+site%3Ansaneforums.com'
  }, {
    name: 'explorer',
    func: 'sp.RunProgram(sp.ExpandEnvironmentVariables("%SystemRoot%")+"\\\\explorer.exe", "", "", "", false, false, false);'
  }
]

var last = sp.GetStoredString('copy')
var now = DateTime.Now.ToFileTimeUtc()
now = now.toString()
sp.StoreString('copy', now)
if (last) {
  var sep = (now - last) / 1000 / 1000 / 10
  if (sep <= interval) {
    var popupMenuInfo = new PopupMenuInfo()
    for (let i of lists) {
      popupMenuInfo.Items.Add(i.name)
      if (i.sep) popupMenuInfo.Items.Add('-')
    }
    popupMenuInfo.Location = sp.GetCurrentMousePoint()
    popupMenuInfo.Callback = 'PopupMenuCallback'
    var res = sp.ShowPopupMenu(popupMenuInfo)
  }
}
// sp.ConsumePhysicalInput(false)

function PopupMenuCallback (id) {
  let item = lists[id - 1]
  if (item.url) {
    sp.RunProgram(browser, item.url.replace('%clipboard%', encodeURIComponent(clip.GetText())), 'open', 'normal', true, false, false)
  } else if (item.func) {
    eval(item.func)
  }
}

Rob  
#2 Posted : Thursday, April 4, 2019 9:45:40 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 52
United States

Was thanked: 10 time(s) in 5 post(s)
When S+.net is sent the hotkey from Windows, it intentionally sends the command(s) to release the modifier keys to ensure they are not considered down before you get a chance to release them physically. This caused problems for people trying to send keys, for example, so I made the default behavior to have them released, since it is not difficult to override that as shown below.

Add this to the end of your hotkey script:

sp.SendVKeyDown(vk.LCONTROL);

Also just to mention it, the PopupMenuCallback function should be in your Global Actions > Load/Unload Scripts > Load Script. This ensures it is available to all script engines. If it is in your hotkey script, it is not guaranteed to stay available.
dodying  
#3 Posted : Friday, April 5, 2019 4:42:21 AM(UTC)
dodying

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/4/2019(UTC)
Posts: 3

is there a way to read the config file, or waht is the format of the config file?

when i update to the latest version, i forgot to backup my config file and then my config lost

i regain the config file use a recovery software, but unfortunately it can note be loaded.

but i determined it contains my config data.

could you tell me how to read the file


download url: StrokesPlus.net.bin
Rob  
#4 Posted : Friday, April 5, 2019 7:13:04 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 52
United States

Was thanked: 10 time(s) in 5 post(s)
It's stored using binary serialization (https://docs.microsoft.com/en-us/dotnet/standard/serialization/binary-serialization), it's not a custom format that I created, so I can't help much in how to deserialize it when the file is fragmented. The file is clearly broken as the beginning of the file had some other garbage text in it from another other app or something; I'm guessing you recovered it using something that performs an undelete.

I opened your file and mine in a hex editor and brought over the top section, it seems to load now, though it's possible some of your settings were lost (but I don't think so).

StrokesPlus.net.bin
Rob  
#5 Posted : Friday, April 5, 2019 7:23:04 AM(UTC)
Rob

Rank: Administration

Reputation:

Groups: Translators, Members, Administrators
Joined: 1/11/2018(UTC)
Posts: 52
United States

Was thanked: 10 time(s) in 5 post(s)
Also, add this to your Unload Script to backup your file each time you exit. It creates the folder in C:\Users\{USERNAME}\AppData\Roaming\StrokesPlus.net\Backup and copies the file there. You can change the location pretty easily at the top of the script.

Code:
var source = clr.System.IO.Path.Combine(clr.System.Environment.GetFolderPath(clr.System.Environment.SpecialFolder.ApplicationData), "StrokesPlus.net", "StrokesPlus.net.bin");
var dest = clr.System.IO.Path.Combine(clr.System.Environment.GetFolderPath(clr.System.Environment.SpecialFolder.ApplicationData), "StrokesPlus.net", "Backup");
if (!clr.System.IO.Directory.Exists(dest)) clr.System.IO.Directory.CreateDirectory(dest);
dest = clr.System.IO.Path.Combine(dest,"StrokesPlus.net_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".bin");
File.Copy(source, dest, true);

//Optional: Delete backup files more than 3 months old
//Note that if you exit frequently and have a large number of files in the backup folder, this loop could take several seconds to complete
var files = clr.System.IO.Directory.GetFiles(destdir);
for (i=0;i<files.Length;i++)
{
	var fi = new FileInfo(files[i]);
	//create new javascript based dates for proper comparison
	var lastAccessed = new Date(fi.LastAccessTime.Year, fi.LastAccessTime.Month, fi.LastAccessTime.Day, fi.LastAccessTime.Hour, fi.LastAccessTime.Minute, fi.LastAccessTime.Second);
	var currentDate = new Date(DateTime.Now.AddMonths(-3).Year, DateTime.Now.AddMonths(-3).Month, DateTime.Now.AddMonths(-3).Day, DateTime.Now.AddMonths(-3).Hour, DateTime.Now.AddMonths(-3).Minute, DateTime.Now.AddMonths(-3).Second);
	if (lastAccessed < currentDate){
		fi.Delete();
	}
}

Edited by user Friday, April 5, 2019 7:23:37 AM(UTC)  | Reason: Not specified

dodying  
#6 Posted : Friday, April 5, 2019 10:23:37 AM(UTC)
dodying

Rank: Newbie

Reputation:

Groups: Approved
Joined: 4/4/2019(UTC)
Posts: 3

i recovered my config and fixed the script

Thank you.
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.