AutoHotkey Community

It is currently May 26th, 2012, 3:16 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, 6 ... 11  Next
Author Message
 Post subject:
PostPosted: March 7th, 2009, 11:57 am 
Offline
User avatar

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

I've finished adding the IsHungAppWindowProc() checking and replacing
SendMessageTimeout() with a regular SendMessage(), so this is finished :)
Code:
// SciTE4AutoHotkey v2 LUA message pumper 1.0
// 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)

// Includes
#include <windows.h> // Windows include
#include "lauxlib.h" // LUA include

// Some defines
#define DllExport __declspec(dllexport)
#define RET_OK 1
#define RET_FAIL 0
#define MAX_TITLE 255
#define ADDFUNC(a) lua_register(L, #a, lib_##a)

// Those defines may not be present
#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

// Global variables
HWND cWindow = 0, tWindow = 0;
const char* cWinTitle; // variable pointer to constant char

// For IsHungAppWindowProc()
typedef BOOL (*IWAPtype)(HWND);
IWAPtype IsHungAppWindowProc;

// Dummy function that always returns false
BOOL _lib_ishungapp(HWND hWnd){ return 0; }

// Initializes the IsHungAppWindow() function.
void _lib_initprocs(){
   HMODULE user32 = LoadLibrary("user32");
   IsHungAppWindowProc = (IWAPtype) GetProcAddress(user32, "IsHungAppWindow");
   if(!IsHungAppWindowProc)
      IsHungAppWindowProc = (IWAPtype) _lib_ishungapp;
}

// 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 = 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 false.
      cWindow = tWindow;
      lua_pushboolean(L, RET_FAIL);
      return 1;
   }
   // return true.
   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){
   // get the parameters
   int iMsg = luaL_checkint(L, 1);
   int wParam = luaL_checkint(L, 2);
   int lParam = luaL_checkint(L, 3);

   if(!IsWindow(cWindow)) // invalid window?
      return luaL_error(L, "Invalid window handle.");
   if(IsHungAppWindowProc(cWindow))
      return luaL_error(L, "The window appears to be hung. Aborting...");

   // just dispatch the message to the window
   int result;
   result = (int) SendMessage(cWindow, (UINT)iMsg, (WPARAM)wParam, (LPARAM)lParam);
   
   // return the number that the window gave to us
   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){
   // get the parameters
   int iMsg = luaL_checkint(L, 1);
   int wParam = luaL_checkint(L, 2);
   const char* lParam = luaL_checkstring(L, 3);
   // get the string length
   int lParamSize = strlen(lParam);

   if(!IsWindow(cWindow)) // invalid window?
      return luaL_error(L, "Invalid window handle.");
   if(IsHungAppWindowProc(cWindow))
      return luaL_error(L, "The window appears to be hung. Aborting...");

   // 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!");

   // just dispatch the message to the window
   int result;
   result = (int) SendMessage(cWindow, (UINT)iMsg, (WPARAM)wParam, (LPARAM)lParam);

   // 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!");

   // return the number that the window gave to us
   lua_pushnumber(L, result);
   return 1;
}

int DllExport libinit(lua_State* L){
   // initialize the IsHungAppWindowProc() function
   _lib_initprocs();
   // add the following functions to the LUA engine
   ADDFUNC(localizewin);
   ADDFUNC(pumpmsg);
   ADDFUNC(pumpmsgstr);
   return 0;
}

_________________
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, 1:00 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Ok, I'm making a new toolbar for SciTE4AutoHotkey v2 that uses the
code that Lexikos provided me in conjunction with the Toolbar module by
majkinetor:
Image
And now a random screenshot showing a pre-Stable private build running on Windows 98:
Image
:)

_________________
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  
PostPosted: April 3rd, 2009, 10:28 am 
Offline

Joined: November 27th, 2008, 10:15 am
Posts: 16
Location: Johannesburg, South Africa
I prefer a command-line approach to editors, hence, I prefer a black background...
If you do too, replace your ahk.style.properties file innards with the following:

Code:
# Syntax-highlighting properties for AutoHotkey scripts
# Putting this in a separate file makes it easier to replace
# and mantain
#
# March 1, 2009 - fincs
#

# The current line
caret.line.back=#444444

# Base (background, base font)
style.ahk1.32=back:#030003,font:Courier New

# Default (everything not below: spaces, untyped parameters)
#style.ahk1.0=fore:#707070,bold
style.ahk1.0=fore:#8f8f8f,bold

# Line comment (; syntax)
#style.ahk1.1=fore:#008000,italics
style.ahk1.1=fore:#ff7fff,italics

# Block comment (/*...*/ syntax)
#style.ahk1.2=fore:#406040,italics
style.ahk1.2=fore:#bf9fbf,italics

# Escape (`x)
#style.ahk1.3=fore:#FF8000,bold
style.ahk1.3=fore:#007fff,bold

# Operator
#style.ahk1.4=fore:#7F200F,bold
style.ahk1.4=fore:#80dff0,bold

# Expression assignement operator
#style.ahk1.5=fore:#FF4F00,bold
style.ahk1.5=fore:#00b0ff,bold

# String
#style.ahk1.6=fore:#404040,bold
style.ahk1.6=fore:#bfbfbf,bold

# Number
#style.ahk1.7=fore:#2F4F7F,bold
style.ahk1.7=fore:#d0b080,bold

# Identifier (variable & function call)
# Not used by the lexer but by the style below and by hotkeys
#style.ahk1.8=fore:#CF2F0F
style.ahk1.8=fore:#30D0F0

# Variable dereferencing %varName%
#style.ahk1.9=$(style.ahk1.8),back:#E4FFE4,bold
style.ahk1.9=$(style.ahk1.8),back:#1B001B,bold

# Label & Hotstrings (& Function definition?). Also defines a bit of style for hotkeys.
#style.ahk1.10=fore:#000000,back:#FFFFA1
style.ahk1.10=fore:#FF00FF,back:#00005e

# Keyword - Flow of control
#style.ahk1.11=fore:#480048,bold,italics
style.ahk1.11=fore:#B7FFB7,bold,italics

# Keyword - Commands
#style.ahk1.12=fore:#004080,bold
style.ahk1.12=fore:#FFBF7F,bold

# Keyword - Functions
#style.ahk1.13=fore:#0F707F,italics
style.ahk1.13=fore:#F08F80,italics

# Keyword - Directives
#style.ahk1.14=fore:#F04020,bold,italics
style.ahk1.14=fore:#0FBFDF,bold,italics

# Keyword - Keys & buttons
#style.ahk1.15=fore:#FF00FF,bold
style.ahk1.15=fore:#00FF00,bold

# Keyword - Built-in Variables
#style.ahk1.16=fore:#CF00CF,bold,italics
style.ahk1.16=fore:#30FF30,bold,italics

# Keyword - special parameters ("Keywords")
#style.ahk1.17=fore:#0000FF
style.ahk1.17=fore:#FFFF00

# Keyword - User defined
#style.ahk1.18=fore:#800020,bold
style.ahk1.18=fore:#7FFFDF,bold

# Variable keyword (built-in) dereferencing %A_xxx%
#style.ahk1.19=$(style.ahk1.16),back:#F9F9FF
style.ahk1.19=$(style.ahk1.16),back:#060600

# Error (unclosed string, unknown operator, invalid dereferencing, etc.)
#style.ahk1.20=back:#FFC0C0
style.ahk1.20=back:#003F3F


Note: I've commented out all the original fincs style entries, so if you don't like something, change it back.

_________________
Keep it Real
Talismaniac
http://www.autohotkey.net/~Talisman


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 25th, 2009, 1:13 am 
Offline

Joined: March 24th, 2009, 10:17 am
Posts: 43
For me: The best one

Thanks a lot !!


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

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Moru wrote:
For me: The best one

Thanks a lot !!


You're welcome :)

_________________
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: April 30th, 2009, 4:48 am 
Offline

Joined: February 11th, 2009, 2:23 pm
Posts: 142
Location: India
I love this software but,

How canI can setup the default text zoom level to 150% in your program?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: April 30th, 2009, 11:22 am 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Montu wrote:
I love this software but,

How canI can setup the default text zoom level to 150% in your program?


I found this on the SciTE documentation:
Quote:
magnification - Sets the initial magnification factor of the edit pane. This is useful when you want to change the size of text globally, such as after changing the screen resolution without having to touch every style setting. 0 is default, negative values makes the size smaller and positive values make it larger.


So what you have to do is add the following line:
Code:
magnification = put number here
to the SciTEGlobal.properties file.

_________________
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: April 30th, 2009, 1:00 pm 
Offline

Joined: February 11th, 2009, 2:23 pm
Posts: 142
Location: India
fincs wrote:
Montu wrote:
I love this software but,

How canI can setup the default text zoom level to 150% in your program?


I found this on the SciTE documentation:
Quote:
magnification - Sets the initial magnification factor of the edit pane. This is useful when you want to change the size of text globally, such as after changing the screen resolution without having to touch every style setting. 0 is default, negative values makes the size smaller and positive values make it larger.


So what you have to do is add the following line:
Code:
magnification = put number here
to the SciTEGlobal.properties file.



thanks it wokred,
go to Option > User Options file
there is already magnification =1 line in it
I changed it to =2
and it works great!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 6th, 2009, 4:10 pm 
Offline

Joined: March 10th, 2008, 12:55 am
Posts: 1907
Location: Minnesota, USA
I was wondering how to change the caret color.
for the dark theme, it is quite hard to see where it is.

Great app BTW.

_________________
rawr. be very afraid
*poke*
Note: My name is all lowercase for a reason.
"I think Bigfoot is blurry, that's the problem. It's not the photographer's fault, Bigfoot is blurry. So there's a large, out-of-focus monster roaming the countryside."


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 10th, 2009, 11:09 pm 
Offline

Joined: August 7th, 2007, 8:36 pm
Posts: 8
Thank you very much for putting this all together, Fincs. After years of using jujuedit, I finally made the plunge to a new editor,
and it's splendid. I had only one problem, which I finally solved after hours of puttering around. I thought I would share the
solution, in case anyone else was as annoyed as I was.

When using 'Go' (F5) on a persistent script, SciTE would just wait for the script to end, which it never does. To relaunch the
script with changes, I would have to manually stop the old instance. Of course, the solution is so simple, it took me forever
to figure out. Just add this line: 'command.go.subsystem.$(file.patterns.ahk)=2' in the ahk.properties file and SciTE will make
the 'Go' command available at all times, instead of greying it out while a script is running.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 11th, 2009, 9:13 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Charon the Hand wrote:
Thank you very much for putting this all together, Fincs. After years of using jujuedit, I finally made the plunge to a new editor,
and it's splendid. I had only one problem, which I finally solved after hours of puttering around. I thought I would share the
solution, in case anyone else was as annoyed as I was.

When using 'Go' (F5) on a persistent script, SciTE would just wait for the script to end, which it never does. To relaunch the
script with changes, I would have to manually stop the old instance. Of course, the solution is so simple, it took me forever
to figure out. Just add this line: 'command.go.subsystem.$(file.patterns.ahk)=2' in the ahk.properties file and SciTE will make
the 'Go' command available at all times, instead of greying it out while a script is running.


Oh, thanks a lot! I was also being annoyed by that behavior :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: May 12th, 2009, 6:36 pm 
Offline

Joined: October 16th, 2007, 2:50 am
Posts: 10
Location: Las Vegas, NV, USA
Excellent work, fincs!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 16th, 2009, 2:56 am 
Offline

Joined: May 10th, 2009, 7:30 pm
Posts: 45
increased my productivity a LOT.

thanks a lot.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 17th, 2009, 8:31 pm 
Offline

Joined: March 2nd, 2004, 3:36 pm
Posts: 10720
I've finally posted a link to SciTE4AutoHotkey on the download page.

So that users have a place to post feedback, you might consider linking from www.autohotkey.net/~fincs/SciTE4AutoHotkey_2/web/ to this topic here.

Thanks for all the work that went into this impressive project.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: May 17th, 2009, 9:14 pm 
Offline
User avatar

Joined: May 5th, 2007, 7:24 pm
Posts: 1240
Location: Seville, Spain
Chris wrote:
I've finally posted a link to SciTE4AutoHotkey on the download page.

So that users have a place to post feedback, you might consider linking from www.autohotkey.net/~fincs/SciTE4AutoHotkey_2/web/ to this topic here.

Thanks for all the work that went into this impressive project.

Oh, what an honor! :oops:
I will link to this topic, don't worry :D

EDIT: Linking done.

_________________
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  
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, 6 ... 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