Rank: Advanced Member
Groups: Moderators, Approved Joined: 4/23/2020(UTC) Posts: 159  Thanks: 46 times Was thanked: 21 time(s) in 17 post(s)
|
The tool will show an input textbox in the middle of the Window, and it will jump to the default browser to search the words that are input. The idea from the Power Toys or the quick launch program Listary. Both the above are great programs on Windows10, and they can be started by S+net. But I prefer to the following tool to do the search. You should input the words like 'g Words'. The first char g will judge which search engine to do the search. There is a Space between the first char and the words you search. There are some search engines inside it to change and do the search, b Bing d Duckduckgo g Google w Wikipedia y Youtube Keypress actions: RETURN/ENTER, do the search action. ESC, disappear the input textbox. You also can drag the input textbox by double left click the textbox. I set a default Hotkey Ctrl+Shift+J to activate the input textbox, and it will disappear when I press the hotkey again. By the way, the input textbox will give you the text input, and you can do anything with the text.
Code:var ht = sp.ForegroundWindow().Screen.Bounds.Height;
var wd = sp.ForegroundWindow().Screen.Bounds.Width;
var input = "";
var Forms = forms.System.Windows.Forms;
var form = new Forms.Form;
form.StartPosition = Forms.FormStartPosition.Manual;
form.FormBorderStyle = Forms.FormBorderStyle.FixedToolWindow;
form.TopMost = true;
form.ControlBox = false;
form.ShowInTaskbar = false;
form.Margin = new Forms.Padding(0);
form.Padding = new Forms.Padding(1);
form.MinimumSize = new Size(100, 10);
//form.Size = new Size(300, 26);
form.Size = new Size(300, 34);
//form.Location = currentMouseLocation;
form.Location = new Point(wd/2 - 150, ht/2 - 60);
form.AutoSize = true;
form.GetType().GetProperty("DoubleBuffered",
host.flags(clr.System.Reflection.BindingFlags.NonPublic,
clr.System.Reflection.BindingFlags.Instance))
.SetValue(form, true);
form.BackColor = Color.WhiteSmoke;
var textBox = new Forms.TextBox;
textBox.Size = new Size(150, 20);
textBox.Location = new Point(50, 5);
//textBox.Font = new System.Drawing.Font("Microsoft YaHei", 8, FontStyle.Regular);
textBox.Font = new System.Drawing.Font("Microsoft YaHei", 13, FontStyle.Regular);
textBox.Text = "";
textBox.Dock = System.Windows.Forms.DockStyle.Fill;
form.Controls.Add(textBox);
dragMoveBlind = ShowImageBindDragMove(form, form);
dragMoveBlind = ShowImageBindDragMove(form, textBox);
var form_shown =
form.Shown.connect(
function (sender, args) {
form.TopMost = true;
form.Activate();
});
var textBox_KeyPress =
textBox.KeyPress.connect(
function (sender, e) {
// The keypressed method uses the KeyChar property to check
// whether the ENTER key is pressed.
// then, do action and close the Form
if (e.KeyChar == 13)
{
input = textBox.Text;
form.Close();
// The keypressed method uses the KeyChar property to check
// whether the ESCAPE key is pressed.
// then close the Form
} else if(e.KeyChar == 27) {
form.Close();
}
});
var textBox_KeyDown =
textBox.KeyDown.connect(
function (sender, e) {
// The keydown method uses the KeyChar property to check
// whether the Ctrl+SHIFT+J key is pressed.
// then, close the Form
var hk = e.KeyCode
if((e.Control) && (e.KeyCode==System.Windows.Forms.Keys.J) && (e.Shift)) {
form.Close();
StrokesPlus.Console.Log('OK');
}
});
// Enable to double click the mouse right button to
// drag the From
var textBox_doubleClick =
textBox.DoubleClick.connect(
function (sender, args) {
dragMoveBlind = ShowImageBindDragMove(form, textBox);
});
var form_doubleClick =
form.DoubleClick.connect(
function (sender, args) {
dragMoveBlind = ShowImageBindDragMove(form, form);
});
Forms.Application.Run(form);
function ShowImageBindDragMove(form, item) {
var Cursors = forms.System.Windows.Forms.Cursors;
var ReleaseCapture = sp_config.GetType().Assembly.GetType("API").GetMethod("ReleaseCapture");
var item_mouseMove =
item.MouseMove.connect(
function (sender, e) {
var hitResize = form.Height + form.Width - (e.X + e.Y) < 30;
var cursor = hitResize ? Cursors.SizeNWSE : Cursors.IBeam;
if (item.Cursor != cursor) item.Cursor = cursor;
if (e.Button == MouseButtons.Left) {
ReleaseCapture.Invoke(null, null);
sp.WindowFromHandle(form.Handle).SendMessageObj(0x0112,
hitResize ? 0xF008 : 0xF012, 0);
}
});
return [item_mouseMove];
}
if((input !== '')) {
var kwd = input.slice(2);
var str = '';
if(input.slice(0, 2) == 'b ') {
str = 'https://www.baidu.com/s?wd=';
} else if(input.slice(0, 2) == 'd ') {
str = 'https://duckduckgo.com/?q=';
} else if(input.slice(0, 2) == 'g ') {
str = 'https://www.google.com/search?q=';
} else if(input.slice(0, 2) == 'w ') {
str = 'https://zh.wikipedia.org/w/index.php?search=';
} else if(input.slice(0, 2) == 'y ') {
str = 'https://www.youtube.com/results?search_query=';
}
if(str !== '') {
sp.RunProgram(str + kwd, '', 'open', 'normal', true, false, false);
}
}
Edited by user Saturday, March 12, 2022 3:39:07 PM(UTC)
| Reason: Not specified
|
 1 user thanked soooulp for this useful post.
|
|