Right-click to add a few color pixels...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Right-click to add a few color pixels...

Post by AHKJeff » 27 Jan 2023, 18:48

I have an application where I'd like to have a special script.

I'd like to be able to right-click at different places on the screen and have those places add a few pixels
of a certain color (let's say green or blue), and then I'd like to be able to remove these colored
pixels by right-clicking and holding down another key (perhaps Esc).

These pixels will basically be acting as temporary reminders.

Can AHK do this?

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Right-click to add a few color pixels...

Post by mikeyww » 27 Jan 2023, 20:31

Code: Select all

; This script creates & destroys small GUIs at the mouse position
#Requires AutoHotkey v2.0
w := 20                                  ; GUI width

RButton:: {                              ; RBUTTON = Create GUI
 CoordMode('Mouse'), MouseGetPos(&x, &y) ; Get mouse position
 makeGUI(x - w / 2, y - w / 2, 'Red')    ; Add GUI at mouse position
 SoundBeep 1500
}

RButton & Esc:: {                        ; RBUTTON & ESC = Destroy GUI
 MouseGetPos ,, &hWnd
 (WinGetClass(hWnd) = "AutoHotkeyGUI") && (WinClose(hWnd), SoundBeep(1000))
}

makeGUI(x, y, color) {                   ; Add GUI at specified position
 gui1 := Gui('+AlwaysOnTop -Caption -DPIScale'), gui1.BackColor := color
 gui1.Show('x' x ' y' y ' w' w ' h' w)
}

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Right-click to add a few color pixels...

Post by AHKJeff » 27 Jan 2023, 21:26

mikeyww wrote:
27 Jan 2023, 20:31

Code: Select all

; This script creates & destroys small GUIs at the mouse position
#Requires AutoHotkey v2.0
w := 20                                  ; GUI width

...
[Mod edit: Fixed tags.]

Beautiful!
Thanks very much mikey.

The only thing I need to do now is figure out what to do with my other .ahk scripts.

I had to download and install AHK v.2 to get your script to work.

Then when I tried to load my other scripts they wouldn't work with v.2, it said it needed v.1.

Is there an easy solution to this?
I would have thought that older scripts would be be backward compatible with newer AHK versions?

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Right-click to add a few color pixels...

Post by AHKJeff » 27 Jan 2023, 21:53

Wow, I re-started the computer and I still can't run my old scripts.

Somehow v2 has taken over.

I installed v2 in its own directory.
It says my scripts require v1.

I go to v1 folder and try to run from there but they still won't run.

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Right-click to add a few color pixels...

Post by mikeyww » 27 Jan 2023, 21:57

Best approach:

1. Uninstall all AutoHotkey.
2. Run the regular v1 installer. You can use the default options.
3. Run the regular v2 installer.

You can now use both versions concurrently, without converting anything. Syntax differs between the versions.

https://www.autohotkey.com/docs/v2/howto/Install.htm

https://www.autohotkey.com/docs/v2/Program.htm#launcher

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Right-click to add a few color pixels...

Post by AHKJeff » 27 Jan 2023, 22:51

Thanks I'm not out of the woods just yet.
My system is still a bit messed up.

Everything was predicated on my system starting up and running a couple of AHK scripts first (v.1.1.33.02).

I don't think I ever installed AHK properly. I say this because when I uninstalled v.2 I couldn't see v.1 in the app list.

I installed AHK 1.1.33.02 in its own folder.
Then I installed AHK 2.0 in its own folder.

Now when I boot up and still have my main ahk1.ahk script file (v1.1) in the startup folder,
I get this message:
" It looks like the script you are trying to run requires AutoHotkey v1, which is not installed.

Script: AHK1.ahk
Rule: v1-hk cmd v1-char v1-pct

We can try to download and install AHK v1.1.36.02 for you while retaining the ability to use the versions
already installed.

Download and Install AHK v1.1.36.02?
Yes /No "

Please advise on how to proceed.

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Right-click to add a few color pixels...

Post by mikeyww » 27 Jan 2023, 23:01

I'm not sure why you are saying, "in its own folder". You can just use the default folders that the installers use, for both versions. That is the easiest and fastest way to get up and running. Follow all three steps, in order. Download the two current installers from the AutoHotkey Web site.

Below is an example of my command line for running a script from a shortcut file or batch file. The script itself can be a v1 or v2 script. The rest of the command line can stay the same.

"C:\Program Files\AutoHotkey\v2\AutoHotkey.exe" "c:\Program Files\AutoHotkey\UX\launcher.ahk" d:\utils\coreStartup2.ahk

There are some possible variations of this, all explained: https://www.autohotkey.com/docs/v2/Program.htm#launcher-cmd

You may also benefit from creating new startup shortcuts: https://www.autohotkey.com/docs/v2/FAQ.htm#Startup

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Right-click to add a few color pixels...

Post by AHKJeff » 27 Jan 2023, 23:28

mikeyww wrote:
27 Jan 2023, 23:01
I'm not sure why you are saying, "in its own folder". You can just use the default folders that the installers use, for both versions. That is the easiest and fastest way to get up and running. Follow all three steps, in order. Download the two current installers from the AutoHotkey Web site.

Below is an example of my command line for running a script from a shortcut file or batch file. The script itself can be a v1 or v2 script. The rest of the command line can stay the same.

"C:\Program Files\AutoHotkey\v2\AutoHotkey.exe" "c:\Program Files\AutoHotkey\UX\launcher.ahk" d:\utils\coreStartup2.ahk

There are some possible variations of this, all explained: https://www.autohotkey.com/docs/v2/Program.htm#launcher-cmd

You may also benefit from creating new startup shortcuts: https://www.autohotkey.com/docs/v2/FAQ.htm#Startup
Thanks mikey I will continue working on this and am sure I will eventually get it working.
Of course there are many ways we can work with our systems.

The way I have operated for most of my apps is to place them in folders that I like/create.
For example I consider AHK a utility and so I place its folder inside my Utils folder along with many other apps.

I created an AHK v.1 folder and an AHK v.2 folder inside the Utils folder.
When going through setup of each of the apps I was asked where I'd like to install the app and
I told them where.
I don't think this is a problem, or it wouldn't have asked where to install.

Perhaps the problem is my AHK1.ahk file that is located in my startup folder?
Perhaps it is causing the startup error?

Perhaps it has vestiges from the old AHK folder it was running from?

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Right-click to add a few color pixels...

Post by mikeyww » 27 Jan 2023, 23:31

I provided the instructions that I recommend, and there are only three of them! You are free to deviate!
Please advise on how to proceed.
I've never understood why people ask this question and then do it a different way! Oh, well. It's not like I've offered unsolicited advice. I hope your installation works anyway.

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Right-click to add a few color pixels...

Post by AHKJeff » 27 Jan 2023, 23:53

mikeyww wrote:
27 Jan 2023, 23:31
I provided the instructions that I recommend, and there are only three of them! You are free to deviate!
Please advise on how to proceed.
I've never understood why people ask this question and then do it a different way! Oh, well. It's not like I've offered unsolicited advice. I hope your installation works anyway.
I did follow your instructions, in terms of deleting existing versions and then installing them in the order you recommended:
V1, then V2.

But my problem still persists. I don't think it has anything to do with the fact that I have installed the apps in the folders
I choose.

After re-installing both apps, I ran my new script (for right-click for color pixels) and it worked.
BUT, when I tried to run my old main script, I got the same error message I mentioned just above.

Somehow it seems the script wants v.1.1.33 and I have installed v.1.1.36.02
I placed the old main script right in the v.1.1.36.02 folder and clicked on it there.
I got the error message right after.

User avatar
mikeyww
Posts: 26934
Joined: 09 Sep 2014, 18:38

Re: Right-click to add a few color pixels...

Post by mikeyww » 28 Jan 2023, 00:04

I don't think it has anything to do with the fact that I have installed the apps in the folders I choose.
Testing your hypothesis is fast & simple: install as noted. You will then know whether the issue is related to the folder locations.

User avatar
boiler
Posts: 16951
Joined: 21 Dec 2014, 02:44

Re: Right-click to add a few color pixels...

Post by boiler » 28 Jan 2023, 02:39

“Thanks for the advice (that I asked for), but I did something different and it didn’t work. Please tell me how to fix the way I decided should work.”

I’m dumbfounded.

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Right-click to add a few color pixels...

Post by AHKJeff » 28 Jan 2023, 13:10

boiler wrote:
28 Jan 2023, 02:39
“Thanks for the advice (that I asked for), but I did something different and it didn’t work. Please tell me how to fix the way I decided should work.”

I’m dumbfounded.
Who are you quoting? I certainly never said that.


This is what mikey said.

"I'm not sure why you are saying, "in its own folder". You can just use the default folders that the installers use, for both versions. That is the easiest and fastest way to get up and running. Follow all three steps, in order. Download the two current installers from the AutoHotkey Web site"

He said "can", not "must".
And he said "easiest and fastest", not "the only way".

AHKJeff
Posts: 91
Joined: 07 Apr 2016, 11:54

Re: Right-click to add a few color pixels...

Post by AHKJeff » 28 Jan 2023, 14:46

mikeyww wrote:
28 Jan 2023, 00:04

I've never understood why people ask this question and then do it a different way! Oh, well. It's not like I've offered unsolicited advice. I hope your installation works anyway....

I don't think it has anything to do with the fact that I have installed the apps in the folders I choose.
Testing your hypothesis is fast & simple: install as noted. You will then know whether the issue is related to the folder locations.
As I suspected, the problem I had did not have anything to do with the folder where the program was installed.

I left the versions (1 & 2) in the customs folders I created and was able to get both versions to work together by loading my main AHK1.ahk script
via the command line.

I hope I can still get some more help to fix a few things (below).
Previously I was loading my main script by placing a link in the Windows startup folder.

My scripts are currently situated in the base folder where each version resides:
c:\Program Files\Utils\AHK_1.1.36\AHK1.ahk
c:\Program Files\Utils\AHK_2.0.2\Right-click-color.ahk

When I click on AHK1.ahk (v.1) it will not run. I get the error message mentioned above.
But when I click on Right-click-color.ahk (v.2) it runs.

1. I would like to run my AHK1.ahk the same way I always did, from the startup folder.
2. I would like to change the hotkey to run the right click color from 'Right click' to 'Control-Right click' and to disable
it 'Control-Right click' + 'Esc'.
3. Since I installed and started running AHK 2.0, I've been getting all kinds of errors with Total Commander (file manager).
It asks for admin permissions to run (Total Commander), copy, save, delete AHK scripts etc.
Something fundamental has changed.

Post Reply

Return to “Ask for Help (v1)”