| View previous topic :: View next topic |
| Author |
Message |
Infocatcher
Joined: 06 Aug 2007 Posts: 1431
|
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1066 Location: Poland
|
Posted: Wed Dec 19, 2012 9:01 pm Post subject: |
|
|
cnnnc
Script InsertNum.js
In order to avoid the suspension of the script, I would suggest a slight amendment.
In line 237, instead of:
AkelPad.MessageBox(hMainWnd, "\""+vLabel[i]+"\" "+sTxtNeedNum, sCaption, 0 /*MB_OK*/);
type:
AkelPad.MessageBox(hWnd, "\""+vLabel[i]+"\" "+sTxtNeedNum, sCaption, 0 /*MB_OK*/); |
|
| Back to top |
|
 |
cnnnc
Joined: 12 Jan 2008 Posts: 115 Location: Shantou, China
|
Posted: Thu Dec 20, 2012 7:29 am Post subject: |
|
|
KDJ
Done. Thanks!
Update InsertNum.js:
1) improve CheckNum function;
2) add SetReDraw function. |
|
| Back to top |
|
 |
VladSh
Joined: 29 Nov 2006 Posts: 2507 Location: Киев, Русь
|
Posted: Fri Dec 21, 2012 12:20 pm Post subject: |
|
|
| Пофиксил FullScreenEx.js, т.к. был баг при такой передаче параметра: `-ToolBar=["ToolBar","1"]`. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1066 Location: Poland
|
Posted: Sat Dec 22, 2012 5:10 pm Post subject: |
|
|
FindFiles.js
Added:
- Ctrl+Enter, Shift+Enter - open focused file for editing and select the found text (or close file if is currently edited),
- info on status bar: "NTFS stream". |
|
| Back to top |
|
 |
Instructor Site Admin
Joined: 06 Jul 2006 Posts: 4638
|
Posted: Wed Dec 26, 2012 9:31 am Post subject: |
|
|
KDJ
GoToEx.js: better to use AKD_GETMODELESS with MLT_GOTO instead of "User32::GetForegroundWindow". |
|
| Back to top |
|
 |
VladSh
Joined: 29 Nov 2006 Posts: 2507 Location: Киев, Русь
|
Posted: Wed Dec 26, 2012 9:47 am Post subject: |
|
|
| FullScreenEx.js обновлён; параметры изменилось правило задания аргументов на такое, как указано Instructor'ом. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1066 Location: Poland
|
Posted: Wed Dec 26, 2012 8:24 pm Post subject: |
|
|
Thanks Instructor. AKD_GETMODELESS - this is what was needed!
Improved: GoToEx.js |
|
| Back to top |
|
 |
cnnnc
Joined: 12 Jan 2008 Posts: 115 Location: Shantou, China
|
Posted: Thu Dec 27, 2012 4:02 am Post subject: |
|
|
KDJ
Good job!
And I'd like to see that Integrate "GotoEx.js" into "FindReplaceEx.js", then I can use it instead of "QSearch::DialogSwitcher".  |
|
| Back to top |
|
 |
VladSh
Joined: 29 Nov 2006 Posts: 2507 Location: Киев, Русь
|
Posted: Thu Dec 27, 2012 11:15 am Post subject: |
|
|
KDJ
I agree, good job!
But the script will beautiful, if add the argument, which can be set focus on specified button. Repeatedly been big debate about this, for example here.
It would also be good to get the inscription "Find" and "Replace" from the program, ie to be localized.
| cnnnc wrote: | | And I'd like to see that Integrate "GotoEx.js" into "FindReplaceEx.js", then I can use it instead of "QSearch::DialogSwitcher". | I do not vote for this proposal, because I think that these dialogues are completely different tasks. |
|
| Back to top |
|
 |
KDJ
Joined: 06 Mar 2010 Posts: 1066 Location: Poland
|
Posted: Thu Dec 27, 2012 7:25 pm Post subject: |
|
|
cnnnc, VladSh
All ideas are very good. Showing "Goto" can be parameterized (in .ini file).
I will try to do.
I don't know how to read by the script the localized strings "Find", "Replace", "Go to" from languages dlls.
Does anyone know how to do it? |
|
| Back to top |
|
 |
cnnnc
Joined: 12 Jan 2008 Posts: 115 Location: Shantou, China
|
Posted: Fri Dec 28, 2012 2:25 am Post subject: |
|
|
KDJ
It's needn't a ini file. I do the change to FindReplaceEx_Mod.js | Code: | // FindReplaceEx_Mod.js - ver. 2012-12-27
//
// "Find/Replace" dialog extended version
//
// Usage:
// Call("Scripts::Main", 1, "FindReplaceEx.js") - Find dialog
// Call("Scripts::Main", 1, "FindReplaceEx.js", "H") - Replace dialog
if (AkelPad.ScriptHandle(AkelPad.ScriptHandle(WScript.ScriptName, 3 /*SH_FINDSCRIPT*/), 13 /*SH_GETMESSAGELOOP*/) /*script already running*/
|| (! AkelPad.GetEditWnd()))
WScript.Quit();
var DT_DWORD = 3;
var IDCANCEL = 2;
var IDLINK = 3099;
var sTxtFind = "Find";
var sTxtReplace = "Replace";
var oSys = AkelPad.SystemFunction();
var hInstanceDLL = AkelPad.GetInstanceDll();
var hGuiFont = oSys.Call("Gdi32::GetStockObject", 17 /*DEFAULT_GUI_FONT*/);
var DLG_FIND = 0;
var DLG_REPLACE = 1;
var DLG_GOTO = 2;
var nDlgType = DLG_FIND;
var bContinue = true;
var hWndFR;
var hWndCancel;
var hSubClass;
if (WScript.Arguments.length)
{
if (WScript.Arguments(0).toUpperCase() == "H")
nDlgType = DLG_REPLACE;
else if (WScript.Arguments(0).toUpperCase() == "G")
nDlgType = DLG_GOTO;
}
while (bContinue)
{
bContinue = false;
if (nDlgType==DLG_FIND)
{
AkelPad.Command(4158 /*IDM_EDIT_FIND*/);
}
else if(nDlgType==DLG_REPLACE)
{
AkelPad.Command(4161 /*IDM_EDIT_REPLACE*/);
}
else if(nDlgType==DLG_GOTO)
{
AkelPad.Command(4162 /*IDM_EDIT_GOTO*/);
}
if ((! (hWndFR = GetFindReplaceDialog())) || (! (hWndCancel = oSys.Call("User32::GetDlgItem", hWndFR, IDCANCEL))))
break;
if (nDlgType==DLG_FIND)
{
sLink = sTxtReplace + " (Ctrl+H)";
}
else if(nDlgType==DLG_REPLACE)
{
sLink = sTxtFind + " (Ctrl+F)";
}
else if(nDlgType==DLG_GOTO)
{
sLink = "";
}
oSys.Call("User32::CreateWindowExW",
0, //dwExStyle
"SysLink", //lpClassName
"<a>" + sLink + "</a>", //lpWindowName
0x50000000, //dwStyle=WS_VISIBLE|WS_CHILD
GetLinkX(), //x
GetLinkY(), //y
GetLinkW(sLink), //nWidth
13, //nHeight
hWndFR, //hWndParent
IDLINK, //ID
hInstanceDLL, //hInstance
0); //lpParam
oSys.Call("User32::UpdateWindow", hWndFR);
hSubClass = AkelPad.WindowSubClass(hWndFR, FindReplaceCallback, 78 /*WM_NOTIFY*/, 256 /*WM_KEYDOWN*/, 2 /*WM_DESTROY*/);
AkelPad.ScriptNoMutex();
AkelPad.WindowGetMessage();
AkelPad.WindowUnsubClass(hWndFR);
}
function FindReplaceCallback(hWnd, uMsg, wParam, lParam)
{
if (uMsg == 78) //WM_NOTIFY
{
if ((wParam == IDLINK) && (AkelPad.MemRead(lParam + 8, DT_DWORD) == -2 /*NM_CLICK*/))
{
if (nDlgType==DLG_FIND)
{
nDlgType=DLG_REPLACE;
SwitchFindReplace();
}
else
{
nDlgType=DLG_FIND;
SwitchFindReplace();
}
}
}
else if (uMsg == 256) //WM_KEYDOWN
{
if (Ctrl() && (! Shift()))
{
if (((wParam == 0x46 /*F key*/) && !(nDlgType==DLG_FIND)))
{
nDlgType = DLG_FIND;
SwitchFindReplace();
}
else if(((wParam == 0x48 /*H key*/) && !(nDlgType==DLG_REPLACE)))
{
nDlgType = DLG_REPLACE;
SwitchFindReplace();
}
else if(((wParam == 0x47 /*G key*/) && !(nDlgType==DLG_GOTO)))
{
nDlgType = DLG_GOTO;
SwitchFindReplace();
}
}
}
else if (uMsg == 2) //WM_DESTROY
oSys.Call("User32::PostQuitMessage", 0); //Exit message loop
return 0;
}
function Ctrl()
{
return Boolean(oSys.Call("User32::GetKeyState", 0x11 /*VK_CONTROL*/) & 0x8000);
}
function Shift()
{
return Boolean(oSys.Call("User32::GetKeyState", 0x10 /*VK_SHIFT*/) & 0x8000);
}
function GetLinkX()
{
var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
var nX;
oSys.Call("User32::GetWindowRect", hWndCancel, lpRect);
oSys.Call("User32::ScreenToClient", hWndFR, lpRect);
nX = AkelPad.MemRead(lpRect, DT_DWORD);
AkelPad.MemFree(lpRect);
return nX;
}
function GetLinkY()
{
var lpRect = AkelPad.MemAlloc(16); //sizeof(RECT)
var nY;
oSys.Call("User32::GetClientRect", hWndFR, lpRect);
nY = AkelPad.MemRead(lpRect + 12, DT_DWORD) - 28;
AkelPad.MemFree(lpRect);
return nY;
}
function GetLinkW(sText)
{
var hDC = AkelPad.SystemFunction().Call("User32::GetDC", hWndCancel);
var lpSize = AkelPad.MemAlloc(8); //sizeof(SIZE)
var nW;
AkelPad.SystemFunction().Call("Gdi32::SelectObject", hDC, hGuiFont);
AkelPad.SystemFunction().Call("Gdi32::SetMapMode", hDC, 1 /*MM_TEXT*/);
AkelPad.SystemFunction().Call("Gdi32::GetTextExtentPoint32W", hDC, sText, sText.length, lpSize);
nW = AkelPad.MemRead(lpSize, DT_DWORD);
AkelPad.SystemFunction().Call("User32::ReleaseDC", hWndCancel, hDC);
AkelPad.MemFree(lpSize);
return nW;
}
function GetFindReplaceDialog()
{
var lpMLT = AkelPad.MemAlloc(4);
var hWnd = AkelPad.SendMessage(AkelPad.GetMainWnd(), 1275 /*AKD_GETMODELESS*/, 0, lpMLT);
var hDlg = 0;
if (AkelPad.MemRead(lpMLT, 3 /*DT_DWORD*/) == 3 /*MLT_FIND*/)
{
nDlgType = DLG_FIND;
hDlg = hWnd;
}
else if (AkelPad.MemRead(lpMLT, 3 /*DT_DWORD*/) == 4 /*MLT_REPLACE*/)
{
nDlgType = DLG_REPLACE;
hDlg = hWnd;
}
else if (AkelPad.MemRead(lpMLT, 3 /*DT_DWORD*/) == 5 /*MLT_GOTO*/)
{
nDlgType = DLG_GOTO;
hDlg = hWnd;
}
AkelPad.MemFree(lpMLT);
return hDlg;
}
function SwitchFindReplace()
{
bContinue = true;
AkelPad.SendMessage(hWndFR, 273 /*WM_COMMAND*/, IDCANCEL, hWndCancel);
} |
.
And I think there need to keep the changed of IDC_SEARCH_FIND when Switching between Dlg_Find and Dlg_Replace without click "Find Next" to rember that. |
|
| Back to top |
|
 |
FeyFre
Joined: 07 Aug 2007 Posts: 1888 Location: Vinnitsa, Ukraine
|
Posted: Fri Dec 28, 2012 10:05 am Post subject: |
|
|
| cnnnc, I'm going to disappoint You. Concept of configuration files was made in order to ease life for users and developers. They made in order to tune up functionality and behaviour of program not cloning it. It will be hell for developer - to support dozen different sources, propagating all tiny changes into each of them. It will be hell for user - to keep updated all versions of program and not to use wrong version. So ini file is preferred, if not required. |
|
| Back to top |
|
 |
VladSh
Joined: 29 Nov 2006 Posts: 2507 Location: Киев, Русь
|
Posted: Fri Dec 28, 2012 10:15 am Post subject: |
|
|
cnnnc
I support FeyFre, as have nearly identical 100500 scripts does not matter. Variant with the option in ini is better.
And it is always better to allocate the common code in Include, not a copy of the script in the script. |
|
| Back to top |
|
 |
FeyFre
Joined: 07 Aug 2007 Posts: 1888 Location: Vinnitsa, Ukraine
|
Posted: Fri Dec 28, 2012 10:20 am Post subject: |
|
|
KDJ, typical code is
| Code: | HMODULE hModule = LoadLibrary("lang.dll");
HRSRC hRes = FindResourceEx(hModule, IDS_STRING, RT_STRING, langid);
HGLOBAL hResData = LoadResource(hModule,hRes);
LPVOID pointer= LockResource(hResData);//! Actual pointer to string. String may not include ending zero AFAIR.
DWORD sz = SizeofResource(hModule,hRes);//! Actual size of string
//! Copy string from pointer to separate memory
FreeLibrary(hModule); //! Free when not needed, if handle was obtained by LoadLibrary.
|
HMODULE , HRSRC, HGLOBAL - typical windows handles of size equal to size of pointer in running architecture.
DWORD - 4 bytes in all architectures.
All function located in kernel32.dll See more at MSDN |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|