Page 1 of 1

What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 15:47
by BillW
I am brand new at this stuff! My very simple little test routine below works as expected when I press the lowercase 'Q' key.

Code: Select all

q::
Msgbox "It is working!"
return
But this very simple routine does not work when I hold down the Alt key and press the 'y' key!

Code: Select all

!y::
MsgBox The active window is "%Title%".
What do I have wrong in this one? Note that this routine was longer and it did not work so I simplified it but did not change the MsgBox line.

Thanks,
Bill

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 16:07
by TimeHorizon

Code: Select all

!y::
WinGetTitle, Title, a ;a = active window
MsgBox The active window is "%Title%".

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 16:08
by AlphaBravo
works fine here, you may need to look through the rest of your code

Code: Select all

Title = Hello there
return

!y::
MsgBox The active window is "%Title%".
return

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 16:25
by TimeHorizon
AlphaBravo wrote:works fine here, you may need to look through the rest of your code

Code: Select all

Title = Hello there
return

!y::
MsgBox The active window is "%Title%".
return

Also worked for me. I think it's his laptop that doesn't respond to it. I wonder if his alt requires a combo press of a fn key, like some do to use F keys.

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 16:28
by AlphaBravo
BillW wrote:but did not change the MsgBox line.
your statement leads me to think the variable named "title" is empty !!

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 17:14
by BillW
Yes, the Title variable is empty. I thought it would still display the text part of that statement. However, I started out with the code that was added by TimeHorizon and it didn't work for me either. I go back and try again now that I know the original code should have worked and I'll look for what was wrong with it.

Thanks to all of you.
BillW

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 19:10
by BillW
OK, here is the bigger file that I trimmed down some for my latest test. This version does not work on my laptop. Any obvious errors or ideas as to what is wrong?

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
^k::
   ;Send, My First Script
msgbox "Ctrl K"
Return

The original 'Send' did not seem to do anything so I commented it out and added the msgbox. Should the Send do anything visible the way it was being used?

Thanks,
Bill

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 19:19
by TimeHorizon
to clarify, do any scripts work on the laptop? Maybe try running as administrator? umm... hmm..

Edit: maybe try F keys instead of the modifier keys?

Re: What is Wrong With My Simple Test?

Posted: 12 Aug 2017, 21:09
by BillW
Yes, several simple scripts do execute as expected. I'll try the F keys tomorrow.

Again: What does the send command do, i.e, where does it send the text?

Thanks,
Bill

Re: What is Wrong With My Simple Test?

Posted: 17 Aug 2017, 09:29
by BillW
TimeHorizon wrote:to clarify, do any scripts work on the laptop? Maybe try running as administrator? umm... hmm..

Edit: maybe try F keys instead of the modifier keys?
Well, I'm back to working on this subject and I have read a lot of the manual and watched a few YouTube videos in the meantime. I never did find a statement as to how to designate a function key in a hotkey label but I tried it with the letter f and that worked. Actually, now all of my little experimental scripts work as expected! I don't really know what I was doing wrong originally except that I was sometimes expecting a routine with a hotkey to run when I double-clicked the file and I've noticed that it doesn't work that way. But, it will run when I click the hotkey for it.

Thanks for the help.
Bill

Re: What is Wrong With My Simple Test?

Posted: 23 Aug 2017, 10:29
by BillW
I think I'm missing an important concept! Do I have to do something before a script will respond to its hotkey? I just tried to run a couple of my test scripts that worked fine a few days ago and neither one responded. I opened one and tried initiating it from the Run command button in the script editor and of course that didn't work but after closing the editor I tried the hotkey again and it worked! What am I missing?

Thanks,
Bill