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
 Bug and Issues
 Known Issues
 [WORKAROUND] Often Crash for special Lua script
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

Kingron

39 Posts

Posted - 03/09/2012 :  03:36:16  Show Profile
I wanna using a gesture to run Google search, but the script often make the whole system crashed or S+ crashed.
My goal:
select some text in any program, draw G gesture, and it auto search the selected text using google

I set gesture as G, the script is

acSendKeys("{DELAY=50}^c")
acDebugPrint('====Google Gesture====')
local s = acGetClipboardText()
acDebugPrint(s)
s = 'https://www.google.com/search?hl=en&newwindow=1&output=search&q=' .. s
acDebugPrint(s)
acShellExecute("open", s, "", "", 1)

Rob

USA
2615 Posts

Posted - 03/09/2012 :  07:13:04  Show Profile  Visit Rob's Homepage
ShellExecute is really meant for verbs against a file. ShellExecuteEx can technically work (though S+ isn't using it internally), even then there can be issues from what I've read.

I would recommend calling rundll32 instead like below; also notice I've added a small delay after sending CTRL+C to allow time for the text to be copied.

acSendKeys("{DELAY=50}^c")
acDelay(50)
local s = acGetClipboardText()
s = 'https://www.google.com/search?hl=en&newwindow=1&output=search&q=' .. s
acShellExecute("open","rundll32.exe", "url.dll,FileProtocolHandler "..s, nil, 1)

P.S. Very handy action! Going to stick this under the action script forum =)

Edit: I see that it is acceptable to run a URL with ShellExecute, but I've also read about people having problems which is why I suggested the rundll32 option.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/09/2012 :  07:28:22  Show Profile  Visit Rob's Homepage
Also, is there any consistency to when it crashes? Certain text? Try the script using rundll32 for a while and let me know how it goes.

I've also added a try/catch block around the ShellExecute call, so that may help prevent any errors from bringing down the system. Will be there in 1.7.9.
Go to Top of Page

Kingron

39 Posts

Posted - 03/09/2012 :  08:52:09  Show Profile
Even I don't call the shellexecute, it is often crash.
The crash is random.
When crash, a windows error report dialog shown, and the system is hung.

I guess because the acGetClipboardText might cause this, because I don't add the delay after sent Ctrl + C keys
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/09/2012 :  08:57:50  Show Profile  Visit Rob's Homepage
Are you ever copying a non-English character? Just wondering if it's a Unicode issue.
Go to Top of Page

Kingron

39 Posts

Posted - 03/09/2012 :  09:43:53  Show Profile
Doesn't matter the charset.

add the acDelay(80) before Get clipboard text works fine!

I guess the cause for this issue:
after sent Ctrl + C, system lock the clipboard and copy the select text, if we don't wait it's finish, and try to get the clipboard text, then S+ can't lock clipboard and return.
Go to Top of Page

Rob

USA
2615 Posts

Posted - 03/09/2012 :  10:10:04  Show Profile  Visit Rob's Homepage
That would make sense.
Go to Top of Page

Kingron

39 Posts

Posted - 03/24/2012 :  01:46:07  Show Profile
Yesterday, When I run the Google search script in Word 2010, it crashed again.

I had to increase the sleep time to avoid again, but this isn't the final solution.

We prefer to solved this problem thoroughly.

My problem is, when S+ crashed, the whole system performance is terrible until we close the windows error dialog.
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