Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
pasting to notepad (when notepad is in background)
im wanting to paste what is in my clipboard to
Select All      Help
id(15 "Untitled - Notepad")

without having that window act can this be done ?


ps set text wont work for what im trying to do
Select All      Help
_s.setsel(0 id(15 "Notepad"))

here _s is a str variable.


Select All      Help
SendMessage id(15 "Notepad") WM_PASTE 0 0
im not sure how u go about doing this but here is what i im trying to do im trying to hit the back key in id(15 "Notepad") without that window being act, i tried
Select All      Help
SendMessage id(15 "Notepad") VK_BACK 0 0
that did not work
Function SendKey
Select All      Help
function hwnd vk [flags] ;;flags: 0 down-up, 1 down, 2 up

;Posts keyboard messages directly to a control. The window can be inactive.
;You can find virtual-key codes in QM help. For alphanumeric keys, use uppercase characters in '', eg 'A'.

;hwnd - control handle.
;vk - virtual-key code.

;int hwnd=id(15 "Notepad")
;SendKey hwnd 'A'
;SendKey hwnd VK_BACK

int m1 m2 lp=MapVirtualKey(vk 0)<<16|1
sel(vk) case [3,33,34,35,36,37,38,39,40,44,45,46,91,92,93,111,144,VK_RCONTROL,VK_RMENU] lp|0x1000000 ;;ek
if(flags&3!2) PostMessage hwnd WM_KEYDOWN vk lp
if(flags&3!1) PostMessage hwnd WM_KEYUP vk lp|0xC0000000
Of course you now my next question....

Can you do this with strings?

Select All      Help
str a="This is a test."

SendKey hwnd a

At this time this is just a theoretical question, as I don't need to do it at this time. But, it is interesting.

A new blog on QM coding and automation.

The Macro Hook
Can be programmed using QmKeyCodeToVK, but easier for me would be to add a function that would use already existing internal code for key.

key2 keycodes [flags] [hwnd]
How do you do this with strings?
I'll add a function for this in some new QM version.
Quote:in some new QM version

rats...i could actually use this now. Smile
A new blog on QM coding and automation.

The Macro Hook
Is this available on
No, possibly in 2.2.1.
i came across this today cuz i need to make sure that the info im trying to type into an 'OpenVMS' telnet session doesn't get stolen by something going on top if it and stealing focus.

did you create the 'sendkey' with the capacity to use strings?
A new blog on QM coding and automation.

The Macro Hook
Try to send characters instead. This should work with most controls.

Function SendCharactersToWindow
Select All      Help
function hwnd $_string

;Sends the string to a child window using WM_CHAR messages.
;The window can be inactive.

;hwnd - child window handle.

;int hwnd=id(15 "Notepad")
;SendCharactersToWindow hwnd "Line1[]Line2"

str s=_string
s.findreplace("[]" "[13]")
word* w=s
for(_i 0 s.len/2) PostMessageW hwnd WM_CHAR w[_i] 0

See also: SendKeysToWindow
well. that first one works just dandy. my text editor (PSPad) doesn't receive the newline character ([10] or [13]) but it works in a lot of other places.

A new blog on QM coding and automation.

The Macro Hook
Sir, can you show me how to parsing Sendkey Alt+Numpad (ex.Alt+132 result->ä) to excel without activated the workbook.?
Download QM 2.3.0. It supports Unicode.

Select All      Help
ExcelSheet es.Init
es.SetCell("ä" 1 1)

I also updated SendCharactersToWindow. In QM 2.3.0 now it supports Unicode.
int a(131) b(132) c(133)
I mean using macro to send "key Alt + a or b or c" to excel then in excel show the â, ä or à in cell.
figured using FormatKeyString and GetMod but don't know how to use that function.
Don't know how to send Alt+numpad to an inactive window.
Sorry, not inactive windows, but in background. is it posible??
If key cannot be used, I don't know another way to send Alt+numpad to an inactive or background window.
Dear Gintaras,

Supposed that I want to send to Notepad background window, what I usually send when it is foreground window :
Quote:key AS 1

My question is how should I compose the SendKeysToWindow statement, in particular in what it concerns the Alt (A) character code.

Many thanks.
In most cases Alt will not work with this function.
Macro Macro2471
Select All      Help
int w=win("Notepad")
SendKeysToWindow w key(Af)
Thank you so much! It is true, I envisaged a lot of problems with Alt, particularly in Internet Exolorer Windows. No problem with VK_CONTROL and VK_SHIFT.

Best regards!
I'm using the send keys code to another window. However, the window doesn't have have id. Any idea how to get around this?

int hwnd=id(15 "Notepad")
If there are no controls, send keys to the window.

int hwnd=win("Notepad")

Forum Jump:

Users browsing this thread: 1 Guest(s)