AutoHotkey Community

It is currently May 26th, 2012, 3:15 pm

All times are UTC [ DST ]




Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 155 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 11  Next
Author Message
 Post subject:
PostPosted: March 4th, 2009, 9:05 am 
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. :) 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 :D


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2009, 1:02 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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. :? 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().


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 4th, 2009, 4:20 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
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. :? 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... :roll:
Let's see how other functions do it (OnChar) and just implement it then...

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2009, 9:41 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
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 :D).

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2009, 10:48 pm 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
fincs wrote:
what language are they going to be in? AutoHotkey or C++?
AutoHotkey.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 5th, 2009, 11:05 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
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 :(
gcc -O -shared -mwindows -o module.dll lua51.a main.c
EDIT: Nevermind, found the solution :D
EDIT2: The test MsgBox dll works great! Now to make the actual DLL!

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2009, 5:53 am 
Offline

Joined: December 17th, 2008, 5:36 am
Posts: 80
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2009, 5:19 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
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 :D:oops:

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 6th, 2009, 8:08 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
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... :D

EDIT: Post #200! WOOT!!

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 12:05 am 
Offline

Joined: April 30th, 2006, 6:23 pm
Posts: 358
Location: Shigle Springs
#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. :) 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!
8)

_________________
CPULOCK.com
virusSWAT.com
Computer Repair Computer Service.com
911PCFIX.com


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 3:37 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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)
}


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 10:39 am 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
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 :lol:).
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 :)
Anyway, as AutoHotkey_L is compiled with VC++ 2008 Express, it is
Windows 2000+ too :P

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 11:24 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 11:38 am 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
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 :)
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 :)

_________________
fincs
Highly recommended: AutoHotkey_L (see why) (all my code snippets require it)
Formal request to polyethene - I support the unity of the AutoHotkey community
Get SciTE4AutoHotkey v3.0.00 (Release Candidate)
[My project list]


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 7th, 2009, 11:43 am 
Offline

Joined: October 17th, 2006, 4:15 pm
Posts: 7502
Location: Australia
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.)


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 155 posts ]  Go to page Previous  1, 2, 3, 4, 5 ... 11  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: No registered users and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group