Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Controlsend to Excel?



  • Please log in to reply
5 replies to this topic
Aquinax
  • Members
  • 9 posts
  • Last active: Jun 18 2016 01:13 PM
  • Joined: 19 Oct 2012

I've a script which uses "Ctrl+I", so I have to controlsend the command to Word and Excel to italize some text. I've found by luck the ClassNN of MS Word and can now italize via ControlSend, _WwG1, ^i, ahk_class OpusApp in Word and would need to know the same information - the ClassNN - of Excel in order to use the said feature with the regular shortcut. If you know this, please share your knowledge. Thank you.

 

 

The script that works in case of MS Word 2013 is:

#IfWinActive, ahk_class OpusApp
<^i::
    ControlSend, _WwG1, ^i, ahk_class OpusApp
#IfWinActive
return


Exaskryz
  • Members
  • 3249 posts
  • Last active: Nov 20 2015 05:30 AM
  • Joined: 23 Aug 2012

You shouldn't need luck to identifying ClassNN's. Use the Window Spy that should have come with your AHK download. Put your mouse over the text field or cells, whichever you'd normally have focus in, and you should see a ClassNN value.



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012

two COM examples

 

Excel:

f3::
ComObjActive("Excel.Application").Selection.Font.Italic := True
return

 

Word:

f3::
wdToggle = 9999998
ComObjActive("Word.Application").Selection.Font.Italic := wdToggle ; or true
return

Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

Aquinax
  • Members
  • 9 posts
  • Last active: Jun 18 2016 01:13 PM
  • Joined: 19 Oct 2012
✓  Best Answer

You shouldn't need luck to identifying ClassNN's. Use the Window Spy that should have come with your AHK download. Put your mouse over the text field or cells, whichever you'd normally have focus in, and you should see a ClassNN value.

Stupid of me, I've used the Autoit spy tool until now which doesn't report the ClassNN. The Autohotkey's tool does disclose this information.

 

The finall script does accomplish the task:

#IfWinActive, ahk_class XLMAIN
<^i::
	ControlSend, EXCEL71, ^i, ahk_class XLMAIN
#IfWinActive
return

Thanks of reminding me of the Autohotkey's own spy tool.



Aquinax
  • Members
  • 9 posts
  • Last active: Jun 18 2016 01:13 PM
  • Joined: 19 Oct 2012

 

two COM examples

 

Jackie, I've no idea what COM is and do not want to learn it now to be honest - just try to make use of small Autohotkey scripts where I can. Thanks for replying though.



Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
That's fine :) np

Just wanted to let you know there was more ways to do it :)
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About