1 |
/* wptCurrWnd.cpp - Current window code |
/* wptCurrWnd.cpp - Current window code |
2 |
* Copyright (C) 2001-2004, 2006, 2007 Timo Schulz |
* Copyright (C) 2001-2004, 2006, 2007, 2011 Timo Schulz |
3 |
* |
* |
4 |
* This file is part of WinPT. |
* This file is part of WinPT. |
5 |
* |
* |
29 |
|
|
30 |
|
|
31 |
/* PTD prototypes from the DLL. */ |
/* PTD prototypes from the DLL. */ |
32 |
extern "C" HWND PTD_get_curr_hwnd (void); |
extern "C" HWND PTD_get_current_window (void); |
33 |
extern "C" BOOL PTD_keyb_send (UINT *keys, UINT n_keys); |
extern "C" BOOL PTD_keyboard_send_keys (UINT *keys, UINT n_keys); |
34 |
extern "C" int PTD_is_used (void); |
extern "C" int PTD_is_hook_used (void); |
35 |
|
|
36 |
|
|
37 |
/* Clear the clipboard contents. */ |
/* Clear the clipboard contents. */ |
73 |
{ |
{ |
74 |
unsigned int keys[4]; |
unsigned int keys[4]; |
75 |
|
|
76 |
if (PTD_is_used ()) { |
if (PTD_is_hook_used ()) { |
77 |
keys[0] = VK_CONTROL | 0x8000; |
keys[0] = VK_CONTROL | 0x8000; |
78 |
keys[1] = 'A' | 0x8000; |
keys[1] = 'A' | 0x8000; |
79 |
keys[2] = 'A'; |
keys[2] = 'A'; |
80 |
keys[3] = VK_CONTROL; |
keys[3] = VK_CONTROL; |
81 |
PTD_keyb_send (keys, 4); |
PTD_keyboard_send_keys (keys, 4); |
82 |
|
|
83 |
} |
} |
84 |
else { |
else { |
96 |
{ |
{ |
97 |
unsigned int keys[4]; |
unsigned int keys[4]; |
98 |
|
|
99 |
if (PTD_is_used ()) { |
if (PTD_is_hook_used ()) { |
100 |
keys[0] = VK_CONTROL | 0x8000; |
keys[0] = VK_CONTROL | 0x8000; |
101 |
keys[1] = 'V' | 0x8000; |
keys[1] = 'V' | 0x8000; |
102 |
keys[2] = 'V'; |
keys[2] = 'V'; |
103 |
keys[3] = VK_CONTROL; |
keys[3] = VK_CONTROL; |
104 |
PTD_keyb_send (keys, 4); |
PTD_keyboard_send_keys (keys, 4); |
105 |
} |
} |
106 |
else { |
else { |
107 |
KEYDOWN (VK_CONTROL, 0x1d); |
KEYDOWN (VK_CONTROL, 0x1d); |
118 |
{ |
{ |
119 |
unsigned int keys[4]; |
unsigned int keys[4]; |
120 |
|
|
121 |
if (PTD_is_used ()) { |
if (PTD_is_hook_used ()) { |
122 |
keys[0] = VK_CONTROL | 0x8000; |
keys[0] = VK_CONTROL | 0x8000; |
123 |
keys[1] = 'C' | 0x8000; |
keys[1] = 'C' | 0x8000; |
124 |
keys[2] = 'C'; |
keys[2] = 'C'; |
125 |
keys[3] = VK_CONTROL; |
keys[3] = VK_CONTROL; |
126 |
PTD_keyb_send (keys, 4); |
PTD_keyboard_send_keys (keys, 4); |
127 |
} |
} |
128 |
else { |
else { |
129 |
KEYDOWN (VK_CONTROL, 0x1d); |
KEYDOWN (VK_CONTROL, 0x1d); |
153 |
prev = GetForegroundWindow (); |
prev = GetForegroundWindow (); |
154 |
else { |
else { |
155 |
*r_main = GetNextWindow (main, GW_HWNDNEXT); |
*r_main = GetNextWindow (main, GW_HWNDNEXT); |
156 |
return PTD_get_curr_hwnd (); |
return PTD_get_current_window (); |
157 |
} |
} |
158 |
|
|
159 |
SetForegroundWindow (prev); |
SetForegroundWindow (prev); |
161 |
GetWindowThreadProcessId (prev, NULL), |
GetWindowThreadProcessId (prev, NULL), |
162 |
TRUE); |
TRUE); |
163 |
fg = GetFocus (); |
fg = GetFocus (); |
164 |
|
|
165 |
AttachThreadInput (GetCurrentThreadId (), |
AttachThreadInput (GetCurrentThreadId (), |
166 |
GetWindowThreadProcessId (prev, NULL), |
GetWindowThreadProcessId (prev, NULL), |
167 |
FALSE); |
FALSE); |
176 |
in @ctx. |
in @ctx. |
177 |
A return value of 0 indicates a problem. */ |
A return value of 0 indicates a problem. */ |
178 |
int |
int |
179 |
copy_window_content (HWND old_hwnd, HWND *r_main, HWND *r_focus, |
copy_window_content (HWND old_hwnd, HWND *r_main, HWND *r_focus, int use_hotkey) |
|
int use_hotkey) |
|
180 |
{ |
{ |
181 |
HWND hwnd; |
HWND hwnd; |
182 |
int rc; |
int rc; |
196 |
if the clipboard contains some text. */ |
if the clipboard contains some text. */ |
197 |
SendMessage (hwnd, WM_COPY, 0, 0); |
SendMessage (hwnd, WM_COPY, 0, 0); |
198 |
if (!clip_check ()) { |
if (!clip_check ()) { |
199 |
rc = 0; |
rc = WPTERR_SUCESS; |
200 |
goto leave; |
goto leave; |
201 |
} |
} |
202 |
/* Then the check if the window is an edit control */ |
/* Then the check if the window is an edit control */ |
203 |
window_msg_em_set_pos (hwnd, 0); |
window_msg_em_set_pos (hwnd, 0); |
204 |
SendMessage (hwnd, WM_COPY, 0, 0); |
SendMessage (hwnd, WM_COPY, 0, 0); |
205 |
if (!clip_check ()) { |
if (!clip_check ()) { |
206 |
rc = 0; |
rc = WPTERR_SUCESS; |
207 |
goto leave; |
goto leave; |
208 |
} |
} |
209 |
|
|
211 |
window_msg_selectall (); |
window_msg_selectall (); |
212 |
window_msg_copy (); |
window_msg_copy (); |
213 |
if (!clip_check ()) |
if (!clip_check ()) |
214 |
rc = 0; |
rc = WPTERR_SUCESS; |
215 |
|
|
216 |
leave: |
leave: |
217 |
AttachThreadInput (GetCurrentThreadId (), |
AttachThreadInput (GetCurrentThreadId (), |