What is Wrong With My Simple Test?

Get help with using AutoHotkey and its commands and hotkeys
BillW
Posts: 28
Joined: 01 Aug 2017, 15:24

What is Wrong With My Simple Test?

12 Aug 2017, 15:47

I am brand new at this stuff! My very simple little test routine below works as expected when I press the lowercase 'Q' key.



But this very simple routine does not work when I hold down the Alt key and press the 'y' key!

Code: [Select all] [Download] GeSHi © Codebox Plus

!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
TimeHorizon
Posts: 13
Joined: 02 Aug 2017, 17:59

Re: What is Wrong With My Simple Test?

12 Aug 2017, 16:07

Code: [Select all] [Download] GeSHi © Codebox Plus

!y::
WinGetTitle, Title, a ;a = active window
MsgBox The active window is "%Title%".
User avatar
AlphaBravo
Posts: 314
Joined: 29 Sep 2013, 22:59

Re: What is Wrong With My Simple Test?

12 Aug 2017, 16:08

works fine here, you may need to look through the rest of your code

Code: [Select all] [Download] GeSHi © Codebox Plus

Title = Hello there
return

!y::
MsgBox The active window is "%Title%".
return
TimeHorizon
Posts: 13
Joined: 02 Aug 2017, 17:59

Re: What is Wrong With My Simple Test?

12 Aug 2017, 16:25

AlphaBravo wrote:works fine here, you may need to look through the rest of your code

Code: [Select all] [Download] GeSHi © Codebox Plus

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.
User avatar
AlphaBravo
Posts: 314
Joined: 29 Sep 2013, 22:59

Re: What is Wrong With My Simple Test?

12 Aug 2017, 16:28

BillW wrote:but did not change the MsgBox line.

your statement leads me to think the variable named "title" is empty !!
BillW
Posts: 28
Joined: 01 Aug 2017, 15:24

Re: What is Wrong With My Simple Test?

12 Aug 2017, 17:14

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
BillW
Posts: 28
Joined: 01 Aug 2017, 15:24

Re: What is Wrong With My Simple Test?

12 Aug 2017, 19:10

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] [Download] GeSHi © Codebox Plus

#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
TimeHorizon
Posts: 13
Joined: 02 Aug 2017, 17:59

Re: What is Wrong With My Simple Test?

12 Aug 2017, 19:19

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?
BillW
Posts: 28
Joined: 01 Aug 2017, 15:24

Re: What is Wrong With My Simple Test?

12 Aug 2017, 21:09

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
BillW
Posts: 28
Joined: 01 Aug 2017, 15:24

Re: What is Wrong With My Simple Test?

17 Aug 2017, 09:29

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
BillW
Posts: 28
Joined: 01 Aug 2017, 15:24

Re: What is Wrong With My Simple Test?

23 Aug 2017, 10:29

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

Return to “Ask For Help”

Who is online

Users browsing this forum: Emmori, Phroster, Yahoo [Bot] and 66 guests