Unable to use #Ifwinactive and ControlSend for Copy Link to Paragraph in OneNote Desktop Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
arrondark
Posts: 29
Joined: 01 May 2024, 05:27

Unable to use #Ifwinactive and ControlSend for Copy Link to Paragraph in OneNote Desktop

06 May 2024, 07:51

Problem: I have created a small ahk script for which do copy, cut and copy link to paragraph in OneNote. Since I use copy and cut functions with other application also I haven't use #Ifwinactive in very start instead I placed #Ifwinactive in the section of 'copy link to paragraph code' and I used ControlSend with it to send Appskey(right menu)p ie. right menu + p(letter) but it also didn't work. I can use simple code like removing #Ifwinactive and ControlSend and just using SendInput instead but I only want to use this function(copy link to paragraph part) of script in OneNote, not in any other application.
Also with ControlSend I unable to give shortcut key(ie. {Appskey}P) to onenote

Code: Select all

;Copy and Cut
NumpadSub::
If (KeyPressCount > 0)
	{
		KeyPressCount +=1
	}
else
	{
		KeyPressCount :=1
	}
if (KeyPressCount <4)
	{
		Tooltip, % KeyPressCount
	}
SetTimer, vKeyPressMonitor, 550
return
vKeyPressMonitor:
If (KeyPressCount = 1)
	{
		SendInput, ^c
		ToolTip, Copy
		Sleep 400
	}
else if (KeyPressCount = 2)
	{
		SendInput, ^x
		ToolTip, Cut
		Sleep 400
	}
else if (KeyPressCount > 2) ;copy link to paragraph part
	{
		#IfWinActive ahk_class Framework::CFrame ahk_exe ONENOTE.EXE
			ControlSend,, {AppsKey}{p}, ahk_exe ONENOTE.EXE
			ToolTip, Copy Link to Paragraph(OneNote)
			Sleep 400	
		#IfWinActive
	}
KeyPressCount := 0
SetTimer, vKeyPressMonitor, Off
Tooltip,
return
The above is a whole script.
Where is below is the portion of script where I am having problem:

Code: Select all

else if (KeyPressCount > 2) ;copy link to paragraph part
	{
		#IfWinActive ahk_class Framework::CFrame ahk_exe ONENOTE.EXE
			ControlSend,, {AppsKey}{p}, ahk_exe ONENOTE.EXE
			ToolTip, Copy Link to Paragraph(OneNote)
			Sleep 400	
		#IfWinActive
	}
tabr3
Posts: 22
Joined: 25 Feb 2024, 04:06

Re: Unable to use #Ifwinactive and ControlSend for Copy Link to Paragraph in OneNote Desktop  Topic is solved

07 May 2024, 01:17

Code: Select all

else if (KeyPressCount > 2) ;copy link to paragraph part
if winexist("ahk_exe ONENOTE.EXE")
{
  WinActivate
    send {AppsKey}p
    ToolTip, Copy Link to Paragraph(OneNote)
    Sleep 400
}		
#if doesn't work within the thread , it only affect the hotkey below it

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], ShatterCoder, sofista and 140 guests