request for script review

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Philog69
Posts: 3
Joined: 13 Feb 2023, 11:58

request for script review

Post by Philog69 » 13 Feb 2023, 12:17

Dear,

Would you please be so kind as to offer me some help?

I wrote the hereunder script first line in a notepad file named "Transparent AT-loop.ahk" (see attached printscreen). In the same folder, I placed the executable file (see same printscreen). To run the ahk file, I launch the exe file.
My problem is that when I change the letter in this first line (i.e. "s") and double-click anew on the exe file so that it takes my change into account, it doesn't.

(script:)
!s::

Best regards,
Philippe
Attachments
image.png
image.png (101.99 KiB) Viewed 997 times

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: request for script review

Post by RussF » 13 Feb 2023, 12:36

Changing the source code (.AHK) file does not automatically change the executable. If you double click the .AHK file, you will see your change take effect immediately, however, if you want to use the executable (.EXE), you must re-compile every time you make a change to your source.

Russ

User avatar
kunkel321
Posts: 1049
Joined: 30 Nov 2015, 21:19

Re: request for script review

Post by kunkel321 » 13 Feb 2023, 13:29

Do you mean that you're changing the hotkey that is in your script? It should still work... Are you sure that you are saving the .ahk file, before re-running the .exe that is in the same folder?

Also, you don't have any #SingleInstance at the top... It is possible that the previous version is still in RAM? (right-click the icon in the system tray and choose Exit to kill it.)

EDIT: Also, like RussF said... If your exe file is merely a renamed version of "AutoHotkey.exe" then it will read from the same-name ahk file if there is one in the same folder. My above comment assumes that this is what you are doing.

However, if you've compiled your ahk into the exe that we see in the picture, then you'll need to recompile every time you edit the script.
ste(phen|ve) kunkel

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: request for script review

Post by RussF » 13 Feb 2023, 13:37

kunkel321 wrote: Are you sure that you are saving the .ahk file, before re-running the .exe that is in the same folder?
Yes, you must save the .AKH file, but you must also re-compile for the changes to be reflected in the .EXE. Just saving WON'T do it.

Russ

User avatar
kunkel321
Posts: 1049
Joined: 30 Nov 2015, 21:19

Re: request for script review

Post by kunkel321 » 13 Feb 2023, 13:58

RussF wrote:
13 Feb 2023, 13:37
kunkel321 wrote: Are you sure that you are saving the .ahk file, before re-running the .exe that is in the same folder?
Yes, you must save the .AKH file, but you must also re-compile for the changes to be reflected in the .EXE. Just saving WON'T do it.
I believe this is only the case if/when the ahk has been compiled into an exe. If you just take a copy of AutoHotkey.exe and rename it to match one of the ahks in the same folder, the exe will read from the ahk at runtime. This is true for v1 and v2. This is how I run all of my own scripts. I haven't compiled any for years.

I suspect this is what Philippe is doing, given the file dates in his screenshot.

EDIT: See also:
https://www.autohotkey.com/docs/v2/Program.htm#portability
ste(phen|ve) kunkel

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: request for script review

Post by RussF » 13 Feb 2023, 14:47

Thank you @kunkel321, I did not know that. Before I responded the last time, I checked the docs in both V1 and V2 under https://www.autohotkey.com/docs/v1/Program.htm#run - just to make sure I wasn't off base. I could not find anything there about the technique you mentioned. I just didn't scroll down far enough to the portability section.

Sooooooo, never mind what I said before, I have no idea why the changes in the script are not being reflected over and above what you have already mentioned.

Humbly, Russ

User avatar
kunkel321
Posts: 1049
Joined: 30 Nov 2015, 21:19

Re: request for script review

Post by kunkel321 » 13 Feb 2023, 15:47

Actually... As I look more closely at the script he posted, It shouldn't work at all.... (I think) it needs to be like:

Code: Select all

!s::
(
Best regards, ; NOPE!
Philippe
)
Return
Parentheses since it's a multi-line one... Also note that this is v1 code. (The Return might be redundant, not sure)

EDIT: No that's not right... Maybe this:

Code: Select all

!s::
Send, Best regards,`nPhilippe
EDIT2: Or this:

Code: Select all

!s::
send,
(
Best regards,
Philipp
)
Both are for v1
ste(phen|ve) kunkel

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: request for script review

Post by RussF » 13 Feb 2023, 15:56

No, that doesn't work, but this does:

Code: Select all

!s::Send, `nBest regards,`nPhilippe`n
Russ

User avatar
kunkel321
Posts: 1049
Joined: 30 Nov 2015, 21:19

Re: request for script review

Post by kunkel321 » 13 Feb 2023, 16:05

I was assuming that Philippe uses this little script to add his signature to emails (hence using "s"). It occurs to me now though, that he might have just been signing his name at the bottom of his forum post, and that it's not even part of his script... LOL

I guess that's a good reason to use the code boxes.

EDIT:
Anyway, I'm betting that he changed the ahk file but forgot to save the file to disc before re-running the exe. I've done that a million times.
ste(phen|ve) kunkel

Philog69
Posts: 3
Joined: 13 Feb 2023, 11:58

Re: request for script review

Post by Philog69 » 05 Jun 2023, 09:28

Hi friends :-)
I'm reaching out to you because I still have a problem with my script, i.e. the loop I coded doesn't work
here is the script:

Code: Select all

^!s::
wait := True
Loop {
Send ^a
Sleep 1000
Send ^x
Sleep 1000 }
Esc::ExitApp
[Mod edit: [code][/code] tags added. Please use them yourself going forward.]

Can you help, please?
Kind regards,

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: request for script review

Post by RussF » 05 Jun 2023, 09:40

Sorry, but what you appear to be trying to do makes no sense.

What is the variable wait used for?

Why are you putting the rest of your code inside a loop? You can only select all (^a) and cut to clipboard (^x) once - and then there is nothing left to select or cut. Why are you putting it inside an endless loop?

Tell us what, exactly, it is that you want to accomplish.

Russ

Philog69
Posts: 3
Joined: 13 Feb 2023, 11:58

Re: request for script review

Post by Philog69 » 05 Jun 2023, 10:04

thanks very much for replying!
Explaining everything would be long and unnecessary.
What I want to know is if the coding of the loop is correct whatever stands inside the loop.

User avatar
kunkel321
Posts: 1049
Joined: 30 Nov 2015, 21:19

Re: request for script review

Post by kunkel321 » 05 Jun 2023, 11:26

Russ has a good point, that once you select-all, then cut, the text will be gone. But anyway... Make sure the closing } is on its own line. And be careful, because you have an endless loop.
ste(phen|ve) kunkel

RussF
Posts: 1264
Joined: 05 Aug 2021, 06:36

Re: request for script review

Post by RussF » 05 Jun 2023, 11:35

Philog69 wrote:Explaining everything would be long and unnecessary.
Well, then I guess a detailed answer would be long and unnecessary as well. See Loop.

Russ

Post Reply

Return to “Ask for Help (v1)”