Jump to content


Photo

Send keystrokes on windows 7


  • Please log in to reply
28 replies to this topic

#1 Onoclea

Onoclea
  • Members
  • 3 posts

Posted 03 July 2012 - 08:18 AM

I was using an ahk script on windows XP what worked well. Now i'l run this on Windows 7 but the Send command isn't working. I tried different Send commands and keystrokes, none of them will work. Can anybody help me, make this work?

This is the original script:
-----
IfWinExist Analook
{
    WinActivate
}
else
{
    Run C:\Vleermuisbatch\AnalookW\AnalookW.exe
    WinWait Analook
    WinActivate
}
Send ^n
-----

#2 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 03 July 2012 - 08:22 AM

This is probably because the privileges of the script do not allow it to send strokes to the window in question. Try this code instead:
if not A_IsAdmin

{

 	run *runAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+

	ExitApp

}



IfWinExist Analook

	WinActivate

else

{

	Run C:\Vleermuisbatch\AnalookW\AnalookW.exe

	WinWait Analook

	WinActivate

}

Send ^n

ExitApp


#3 Onoclea

Onoclea
  • Members
  • 3 posts

Posted 03 July 2012 - 08:58 AM

I've tried your code, but it gives a bug warning: it can't find the .ahk file. Your mentioning ahk version v1.0.92.01+?
I downloaded the latest version of ahk yesterday but this is version 1.0.48.05?? Is there somenthing I miss here.

#4 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 03 July 2012 - 09:03 AM

Try using AHK_L: <!-- m -->http://l.autohotkey.net/<!-- m -->

#5 Onoclea

Onoclea
  • Members
  • 3 posts

Posted 03 July 2012 - 10:20 AM

That works!!

Many thanks

#6 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 03 July 2012 - 11:13 AM

Graag gedaan.

#7 sanjay

sanjay
  • Members
  • 25 posts

Posted 03 July 2012 - 01:12 PM

Hi,

I am also facing the same issue after moving to windows 7.
It is not that send command is not working in all the scripts. In some of the scripts, it is working perfectly fine but in some of them, it is not working.
Eg, in the script below, Send is not working:

!z::
Send #l
return
Another big issue that I am facing is that my scripts containing Winmove command have stopped working. I have raised it yesterday in the support forum with the title "Winmove command not working in AHK with Window 7".

I tried both 1.0.48.05 and 1.1.07.03 but none helped. I even tried running scripts "Run as administrator" but that didn't help either.

Pl. help.

Thanks and Best Regards,
Sanjay

#8 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 03 July 2012 - 02:48 PM

try adding a msgbox line like:
!z::

Send #l

[color=#FF0000]msgbox %A_ThisHotkey% pressed[/color]

return
To determine if the hotkey is firing at all or maybe it's something else.

#9 sanjay

sanjay
  • Members
  • 25 posts

Posted 04 July 2012 - 03:49 AM

Hi,

Thanks for the quick response.
I added the line "msgbox %A_ThisHotkey% pressed" and it flashed the message box with the message "!z pressed".

However, it still didn't send #l. :-(

What could be the possible reason for this?

Thanks and Best Regards,
Sanjay

#10 Guests

  • Guests

Posted 04 July 2012 - 04:33 AM

I have also found that you cannot put % in text for a send statement

eg

#z::send 20% Markup
It keeps saying there is a % misssing :x

#11 dylan904

dylan904
  • Members
  • 706 posts

Posted 04 July 2012 - 04:37 AM

Guest, you would use this as a work-around...
#z::send % "20% Markup"


#12 Maestr0

Maestr0
  • Members
  • 649 posts

Posted 04 July 2012 - 06:55 AM

Sanjay, that shows that the hotkey is working. Is the script running elevated (as admin)? If not, try adding the following to the beginning of your script:
if not A_IsAdmin

{

 	run *runAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+

	ExitApp

}
And try it again.

#13 sanjay

sanjay
  • Members
  • 25 posts

Posted 04 July 2012 - 07:20 AM

Hello Maestr0,

Thanks for the prompt response. I tried as per your suggestion but it didn't work. I also tried it running as admin but this didn't help either. Am I doing it correctly? Is it mandatory to use v1.0.92.01+. I am currently using AutoHotkey_L (version 1.1.07.03)

Here's the code:

#SingleInstance,Force
#NoEnv
if not A_IsAdmin
{
   run *runAs "%A_ScriptFullPath%"  ; Requires v1.0.92.01+
   ExitApp
}
; To lock the computer
;#IfWinActive A
!z::
Send #l
;msgbox %A_ThisHotkey% pressed
Sleep 500
return

Thanks and Best Regards,
Sanjay

#14 dylan904

dylan904
  • Members
  • 706 posts

Posted 04 July 2012 - 07:31 AM

Try this out SanJay...
Send % "#l"


#15 sanjay

sanjay
  • Members
  • 25 posts

Posted 04 July 2012 - 08:27 AM

Sorry, this didn't work. :(