1

For my project I need a program that exports text or spreadsheet data to other programs like word, excel, notepad, etc.. The user will set his cursor in the application he wants to export to, then he clicks in my program on "export", which will start the autohotkey .exe. I already figured out how to get the window of the other application, but not how to send the data.

Here is the current code:

WinGet, id, list

window_id := id3 ;id2 = current program, id3 = program behind (we want to send the data here)
ControlSendRaw, , MyExportDataHere, ahk_id %window_id% ;<-------- DOESNT WORK

;~ ///////////// Works, but ugly because of popup:
;~ window_id := id3
;~ WinActivate, ahk_id %window_id%
;~ SendRaw MyExportDataHere
;~ window_id := id2
;~ WinActivate, ahk_id %window_id%
ellow7
  • 61
  • 1
  • 7
  • `controlsendraw` should actually work equally well as your commented out code.. I cannot find any mistakes – phil294 Jul 27 '15 at 13:15
  • After some tests, I found out that it works with notepad and excel, but not with firefox, chrome, notepad++, word and internet explorer. – ellow7 Jul 27 '15 at 13:52
  • Tell us a little bit more about the work flow. I am interested to know why e.g. you seem to want to avoid activating the destination application. An alternative could be to first collect all the data from the source application (in an array) and only at the end switch to the destination application, where you empty the array step by step into the destination application. – Robert Ilbrink Jul 28 '15 at 15:48
  • It should work as a "data snapshot". The user wants to concentrate mostly on the main program. Your suggested workaround makes sense, but I would need the "data collector" program running at all time, polling the current active window and pasting when it changed. Can I somehow debug the ControlSend method? Or is there a way to get the cursor focus (control class) of the inactive window? – ellow7 Jul 29 '15 at 12:27

1 Answers1

0

Use the first parameter of ControlSendRaw to specify the Control like this: http://lexikos.github.io/v2/docs/commands/ControlSend.htm#Function_Syntax

noXi
  • 175
  • 1
  • 1
  • 7
  • Then I would need an endless list of control names for word, excel, open office, notepad, etc. I would like to keep it universal for every program. – ellow7 Jul 27 '15 at 13:04