AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

[ARCHIVED THREAD] SciTE4AutoHotkey v2 Stable - Released.
Goto page Previous  1, 2, 3, ... 9, 10, 11  Next
 
This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
not-logged-in-fincs
Guest





PostPosted: Wed Mar 04, 2009 8:05 am    Post subject: Reply with quote

wtg wrote:
FYI, when I try to perform a web install I get an error message:

Can't download the file!
Make sure your Internet connection is active then
try to install the program again.

I took it's advice and tried again, rebooted, redownloaded install app, but still no go. Smile Not sure what's up as there's nothing special about my PC's setup. It's Windows XP with one network connection and nothing else seems to have trouble. The web install worked fine on my Vista laptop.

I downloaded the data file independently and then ran an offline install and that worked so I'm good to go, but I thought I'd let you know.

Thanks for your efforts. Nicely done!


Weird... The web install works correctly on my system... I'll try to fix that, don't worry Very Happy
Back to top
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Wed Mar 04, 2009 12:02 pm    Post subject: Reply with quote

fincs wrote:
So, maybe an interface implemented in LUA? Or a custom SciTE version?
As far as I can tell, OnMarginClick() in Lua doesn't provide any way to determine which margin was clicked, or at which line. Confused The only alternative I can think of for standard SciTE is to use:
  • mouse hotkeys to detect click;
  • SCI_GETMARGINWIDTHN to determine which margin was clicked, if any; and
  • SCI_POSITIONFROMPOINT and SCI_LINEFROMPOSITION to determine which line was clicked.
On the other hand, SCN_MARGINCLICK provides modifier key-state, position of the start of the line and margin number. A "custom SciTE version" could allow this (and other notifications!) to be hooked, or could add parameters to the lua OnMarginClick().
Back to top
View user's profile Send private message Visit poster's website
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Wed Mar 04, 2009 3:20 pm    Post subject: Reply with quote

Lexikos wrote:
fincs wrote:
So, maybe an interface implemented in LUA? Or a custom SciTE version?
As far as I can tell, OnMarginClick() in Lua doesn't provide any way to determine which margin was clicked, or at which line. Confused The only alternative I can think of for standard SciTE is to use:
  • mouse hotkeys to detect click;
  • SCI_GETMARGINWIDTHN to determine which margin was clicked, if any; and
  • SCI_POSITIONFROMPOINT and SCI_LINEFROMPOSITION to determine which line was clicked.
On the other hand, SCN_MARGINCLICK provides modifier key-state, position of the start of the line and margin number. A "custom SciTE version" could allow this (and other notifications!) to be hooked, or could add parameters to the lua OnMarginClick().

I would vote for the "custom SciTE" option. Then I have to figure out how to implement a new parameter in the Extension module... Rolling Eyes
Let's see how other functions do it (OnChar) and just implement it then...
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Thu Mar 05, 2009 8:41 pm    Post subject: Reply with quote

Ok, I've succesfully implemented two new parameters in the OnMarginClick message: position and margin! So I'm now going
to program a LUA extension DLL so I can send the messages to an AHK program that will implement the DBGp support
(I'm waiting for you to create the AutoHotkey_L debugging functions,
what language are they going to be in? AutoHotkey or C++? I would better
have AutoHotkey functions than C++ functions Very Happy).
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Thu Mar 05, 2009 9:48 pm    Post subject: Reply with quote

fincs wrote:
what language are they going to be in? AutoHotkey or C++?
AutoHotkey.
Back to top
View user's profile Send private message Visit poster's website
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Thu Mar 05, 2009 10:05 pm    Post subject: Reply with quote

Lexikos wrote:
fincs wrote:
what language are they going to be in? AutoHotkey or C++?
AutoHotkey.

Great! I'm now fighting with the compiler (MinGW) to link the Lua library (lua51.a) to the LUA expansion module (a .c file) to create the DLL,
but the compiler refuses to find the missing functions in the .a file Sad
gcc -O -shared -mwindows -o module.dll lua51.a main.c
EDIT: Nevermind, found the solution Very Happy
EDIT2: The test MsgBox dll works great! Now to make the actual DLL!
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
kdoske



Joined: 17 Dec 2008
Posts: 80

PostPosted: Fri Mar 06, 2009 4:53 am    Post subject: Reply with quote

No disrespect to all the other hard work put out there for all the other AHK editors but this is one is fantastic.

first editor I have used that feels like a real editor. Just wanted to say thanks for your efforts.
Back to top
View user's profile Send private message
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Fri Mar 06, 2009 4:19 pm    Post subject: Reply with quote

kdoske wrote:
No disrespect to all the other hard work put out there for all the other AHK editors but this is one is fantastic.

first editor I have used that feels like a real editor. Just wanted to say thanks for your efforts.

Thank you for your comments Very HappyEmbarassed
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Fri Mar 06, 2009 7:08 pm    Post subject: Reply with quote

I just got the message pumper working.
Here is the code, if you want to look at it (main.c):
Code:
// SciTE4AutoHotkey v2 LUA message pumper
// Build with: gcc -shared -o module.dll -I..\lualib\src main.c scite.la
// You've got to have a LUA distribution at ..\lualib (creates the src folder)
// for this to work.
// Also copy the scite.* files from http://luaforge.net/frs/download.php/3293/scite-debug.zip (scite.la, scite.def and scite.lib)

#include <windows.h>
#include "lauxlib.h"
#define DllExport __declspec(dllexport)
#define RET_OK 1
#define RET_FAIL 0
#define MAX_TITLE 255
#define SNDMSG_DELAY 8000

#ifndef PROCESS_VM_OPERATION
#define PROCESS_VM_OPERATION 0x0008
#endif
#ifndef PROCESS_VM_READ
#define PROCESS_VM_READ 0x0010
#endif
#ifndef PROCESS_VM_WRITE
#define PROCESS_VM_WRITE 0x0020
#endif
#ifndef MEM_COMMIT
#define MEM_COMMIT 0x1000
#endif
#ifndef PAGE_READWRITE
#define PAGE_READWRITE 4
#endif
#ifndef MEM_RELEASE
#define MEM_RELEASE 0x8000
#endif

HWND cWindow = 0, tWindow = 0;
char* cWinTitle;

// Private callback function to enumerate the windows.
BOOL CALLBACK _lib_winsearchproc(HWND hWnd, LPARAM lParam){
   char wTitle[MAX_TITLE+1];
   // Get window title
   GetWindowText(hWnd, wTitle, MAX_TITLE);
   if(!strncmp(wTitle, cWinTitle, lParam)){
      // Window found.
      cWindow = hWnd;
      return 0; // Cancel the enumeration
   }
   return 1; // Continue enumerating the windows
}

// localizewin(wintitle) -- Localizes the window with the specified window title to
//  further send messages to it. True = sucess, false = failure.
int lib_localizewin(lua_State* L){
   // set the global variables
   cWinTitle = (char*) luaL_checkstring(L, 1);
   tWindow = cWindow, cWindow = 0;

   // look for the window
   EnumWindows((WNDENUMPROC)_lib_winsearchproc, strlen(cWinTitle));
   if(!cWindow){ // no window found?
      // just restore the old window and return.
      cWindow = tWindow;
      lua_pushboolean(L, RET_FAIL);
      return 1;
   }
   lua_pushboolean(L, RET_OK);
   return 1;
}

// pumpmsg(msg, wparam, lparam) -- Sends a message to the current window.
//  Timeout of 8 seconds. It returns the value that the window returns.
int lib_pumpmsg(lua_State* L){
   int iMsg = luaL_checkint(L, 1);
   int wParam = luaL_checkint(L, 2);
   int lParam = luaL_checkint(L, 3);
   if(!IsWindow(cWindow))
      return luaL_error(L, "Invalid window handle.");
   int result;
   if(!SendMessageTimeout(cWindow, (UINT)iMsg, (WPARAM)wParam, (LPARAM)lParam, SMTO_ABORTIFHUNG, SNDMSG_DELAY, (PDWORD_PTR) &result)){
      return luaL_error(L, "Failed at SendMessage'ing the window!");
   }
   lua_pushnumber(L, result);
   return 1;
}

// pumpmsg(msg, wparam, lparam) -- Sends a message with lparam as string to the current window.
//  Timeout of 8 seconds. It returns the value that the window returns.
int lib_pumpmsgstr(lua_State* L){
   int iMsg = luaL_checkint(L, 1);
   int wParam = luaL_checkint(L, 2);
   const char* lParam = luaL_checkstring(L, 3);
   int lParamSize = strlen(lParam);

   if(!IsWindow(cWindow))
      return luaL_error(L, "Invalid window handle.");

   // Inject the string at the process.
   DWORD pID;
   GetWindowThreadProcessId(cWindow, &pID);
   HANDLE hProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE, 0, pID);
   if(!hProcess)
      return luaL_error(L, "Couldn't open the memory of the window!");
   void* rlParam = VirtualAllocEx(hProcess, 0, lParamSize, MEM_COMMIT, PAGE_READWRITE);
   if(!rlParam)
      return luaL_error(L, "Couldn't allocate the memory at the window!");
   if(!WriteProcessMemory(hProcess, rlParam, lParam, lParamSize, NULL))
      return luaL_error(L, "Couldn't inject the string parameter at the window!");

   // Send the message to the window.
   int result;
   if(!SendMessageTimeout(cWindow, (UINT)iMsg, (WPARAM)wParam, (LPARAM)rlParam, SMTO_ABORTIFHUNG, SNDMSG_DELAY, (PDWORD_PTR) &result)){
      return luaL_error(L, "Failed at SendMessage'ing the window!");
   }

   // Free the memory used by the string
   if(!VirtualFreeEx(hProcess, rlParam, 0, MEM_RELEASE))
      return luaL_error(L, "Failed to free the memory at the window!");
   if(!CloseHandle(hProcess))
      return luaL_error(L, "Couldn't close the process handle!");

   lua_pushnumber(L, result);
   return 1;
}

int DllExport libinit(lua_State* L){
   // do the following for each function you want to add to the LUA engine
   lua_register(L, "localizewin", lib_localizewin);
   lua_register(L, "pumpmsg", lib_pumpmsg);
   lua_register(L, "pumpmsgstr", lib_pumpmsgstr);
   return 0;
}

Now I'm patiently waiting for Lexikos to release his functions... Very Happy

EDIT: Post #200! WOOT!!
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
DeWild1



Joined: 30 Apr 2006
Posts: 358
Location: Shigle Springs

PostPosted: Fri Mar 06, 2009 11:05 pm    Post subject: Reply with quote

#1 YOU ROCK....

#2 I got it too on one of my servers.. I will PM instructions on how to log in via Remote Desktop if you want to see it and test. (its my VOIP server so please do not reboot unless it is after 10pm PST.
wtg wrote:
FYI, when I try to perform a web install I get an error message:

Can't download the file!
Make sure your Internet connection is active then
try to install the program again.

I took it's advice and tried again, rebooted, redownloaded install app, but still no go. Smile Not sure what's up as there's nothing special about my PC's setup. It's Windows XP with one network connection and nothing else seems to have trouble. The web install worked fine on my Vista laptop.

I downloaded the data file independently and then ran an offline install and that worked so I'm good to go, but I thought I'd let you know.

Thanks for your efforts. Nicely done!
Cool
_________________
CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com
Back to top
View user's profile Send private message Visit poster's website
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Sat Mar 07, 2009 2:37 am    Post subject: Reply with quote

Is it safe to use SendMessageTimeout - i.e. does the window still eventually process the message if it times out? If it times out and SciTE frees the memory, it obviously won't be valid when the window processes the message... Actually, I think it may time out while the window is processing the message. You may confirm with something like:
Code:
OnMessage(..., "Timeout")
...
Timeout() {
    DllCall("Sleep", "int", 10000)
}
Back to top
View user's profile Send private message Visit poster's website
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Sat Mar 07, 2009 9:39 am    Post subject: Reply with quote

Lexikos wrote:
Is it safe to use SendMessageTimeout - i.e. does the window still eventually process the message if it times out? If it times out and SciTE frees the memory, it obviously won't be valid when the window processes the message... Actually, I think it may time out while the window is processing the message. You may confirm with something like:
Code:
OnMessage(..., "Timeout")
...
Timeout() {
    DllCall("Sleep", "int", 10000)
}

I haven't really tested the timeout but what I can say is that the memory allocated by
pumpmsgstr() is not freed if SendMessageTimeout() fails (timeout). And,
to ensure reliability I've decided to set the timeout to 1 minute (to be
realistic, no message handler is gonna take 1 minute to process a message unless it's an über slow PC Laughing).
If it does, the most probable thing is that the window is hung and that
situation is already handled by the function call (ABORTIFHUNG).
Anyway, how are those DBGp interface functions going?
And I forgot to say: as this DLL uses some calls that are Windows 2000+ only,
the DBGp debugging feature will only be available for those systems Smile
Anyway, as AutoHotkey_L is compiled with VC++ 2008 Express, it is
Windows 2000+ too Razz
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Sat Mar 07, 2009 10:24 am    Post subject: Reply with quote

fincs wrote:
I haven't really tested the timeout but what I can say is that the memory allocated by
pumpmsgstr() is not freed if SendMessageTimeout() fails (timeout).
Ah, so you're happy with memory leaks in that case?
Quote:
to ensure reliability I've decided to set the timeout to 1 minute
How does that ensure reliability? I suppose it would be more reliable to NOT time out; i.e. use SendMessage instead of SendMessageTimeout. If you want to avoid sending a message to a "hung" window, you may call IsHungAppWindow before-hand.
Quote:
Anyway, how are those DBGp interface functions going?
Slowly, partly because I intend to support multiple asynchronous connections. One major problem with XDebugClient is that the user interface freezes while the script is running; i.e. it sends a command like "run" and does not update the UI until it receives a response (i.e. a breakpoint is hit or the script exits). Ideally the debugger client will send a command, and be notified when a response is received and for which script.
Back to top
View user's profile Send private message Visit poster's website
fincs



Joined: 05 May 2007
Posts: 1163
Location: Seville, Spain

PostPosted: Sat Mar 07, 2009 10:38 am    Post subject: Reply with quote

Lexikos wrote:
fincs wrote:
I haven't really tested the timeout but what I can say is that the memory allocated by
pumpmsgstr() is not freed if SendMessageTimeout() fails (timeout).
Ah, so you're happy with memory leaks in that case?
Quote:
to ensure reliability I've decided to set the timeout to 1 minute
How does that ensure reliability? I suppose it would be more reliable to NOT time out; i.e. use SendMessage instead of SendMessageTimeout. If you want to avoid sending a message to a "hung" window, you may call IsHungAppWindow before-hand.

Then show me how to detect errors on the SendMessage routine Smile
I chose the SendMessageTimeout() function because it returns the
error code instead of the value that the window returns (it puts it in an output parameter).
Anyway, if I do a bunch of checks before I think it won't be necessary Smile
_________________
fincs
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]
Back to top
View user's profile Send private message
Lexikos



Joined: 17 Oct 2006
Posts: 7299
Location: Australia

PostPosted: Sat Mar 07, 2009 10:43 am    Post subject: Reply with quote

What errors are there to detect? You shouldn't be passing it an invalid window handle; if in doubt, use IsWindow. (Edit: I see you already do.)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This topic is locked: you cannot edit posts or make replies.    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Goto page Previous  1, 2, 3, ... 9, 10, 11  Next
Page 2 of 11

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group