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

without having that window act can this be done ?


THANK YOU

ps set text wont work for what im trying to do
#2
Code:
Copy      Help
_s.getclip
_s.setsel(0 id(15 "Notepad"))

here _s is a str variable.

Or

Code:
Copy      Help
SendMessage id(15 "Notepad") WM_PASTE 0 0
#3
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
Code:
Copy      Help
SendMessage id(15 "Notepad") VK_BACK 0 0
that did not work
#4
Function SendKey
Code:
Copy      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.


;EXAMPLE
;int hwnd=id(15 "Notepad")
;SendKey hwnd 'A'
;1
;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
#5
Of course you now my next question....

Can you do this with strings?

Code:
Copy      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.


thanks.
An old blog on QM coding and automation.

The Macro Hook
#6
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]
#7
How do you do this with strings?
#8
I'll add a function for this in some new QM version.
#9
Quote:in some new QM version

rats...i could actually use this now. Smile
An old blog on QM coding and automation.

The Macro Hook
#10
Is this available on 2.2.0.11?
#11
No, possibly in 2.2.1.
#12
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?
thanks
An old blog on QM coding and automation.

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

Function SendCharactersToWindow
Code:
Copy      Help
;/
function hwnd $_string

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

;hwnd - child window handle.

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


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



See also: SendKeysToWindow
#14
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.

thanks!
An old blog on QM coding and automation.

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

Macro
Code:
Copy      Help
ExcelSheet es.Init
es.SetCell("ä" 1 1)

I also updated SendCharactersToWindow. In QM 2.3.0 now it supports Unicode.
#17
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.
#18
Don't know how to send Alt+numpad to an inactive window.
#19
Sorry, not inactive windows, but in background. is it posible??
#20
If key cannot be used, I don't know another way to send Alt+numpad to an inactive or background window.
#21
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.
#22
In most cases Alt will not work with this function.
Macro Macro2471
Code:
Copy      Help
int w=win("Notepad")
SendKeysToWindow w key(Af)
#23
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!
#24
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")
#25
If there are no controls, send keys to the window.

int hwnd=win("Notepad")


Forum Jump:


Users browsing this thread: 1 Guest(s)