make image press on button with joy1

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
DRLantern
Posts: 45
Joined: 05 May 2023, 20:21

make image press on button with joy1

Post by DRLantern » 02 Jun 2023, 21:25

hello, so i was trying to make a code where the image will move and when it moves onto the button it will press the button with joy1 and then what will happen to the button when i press with joy1 is it will try to make an action where it will do nothing or send a MSGBOX saying it works, how can i do that, I'm new to AHK and I tried to get help on some friend who helps with AHK and he said "make a picture item launch a G label then use A_GuiControl variable in the label to see what picture launched the label, name your picture with v option
G label is used when clicked
" what does that mean and how can I solve this problem I'm having


Code: Select all

JoyNomX := GetKeyState("JoyX") 
JoyNomY := GetKeyState("JoyY") 

Gui, +HwndGuiHwnd
Gui, Color, 5186D2
Gui, add, Button, x200 y200 w200 h200 vLabel2 gLabel1, OK
Gui, Add, Picture, x20 y20 w20 h-1 vMousePic, C:\Users\BIZZARE\Downloads\apps\New folder (2)\new2.png
Gui, Show, w800 h600, testing lol
SetTimer, MoveMouse, 20
return

MoveMouse:
	GuiControlGet, Pic, Pos, MousePic
	GuiControl, Move, MousePic, % "x" (PicX + (GetKeyState("JoyX") - JoyNomX) / 5) " y"	(PicY + (GetKeyState("JoyY") - JoyNomY) / 5)
	Sleep, 20
return

Label1:
Joy1::
Critical
GuiControlGet, MousePic, x200 y200
guicontrol, Label2
KeyWait, Joy1
return



Last edited by DRLantern on 03 Jun 2023, 11:06, edited 1 time in total.

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

Re: make image press on button with joy1

Post by boiler » 02 Jun 2023, 23:05

Why do you have the first two lines of you script when you immediately replace the assignment of those variables with the next so lines? Why would you ever want to subtract 100 from them anyway? Why are you subtracting zero from them?

DRLantern
Posts: 45
Joined: 05 May 2023, 20:21

Re: make image press on button with joy1

Post by DRLantern » 03 Jun 2023, 00:51

well as u can see, what i did in the jonumb's was kinda cool, what i did was somehow placed numbers in joyX and joyy to make it move because without the numbers in the jonum;s it wouldnt work, also the minus does nothing lol

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

Re: make image press on button with joy1

Post by boiler » 03 Jun 2023, 01:21

No, I don’t see how it’s not kinda cool at all. What you said doesn’t make sense. Assigning values to those variables doesn’t move anything when you overwrite them with the next two lines anyway. So how is it kinda cool to have lines of code that have no effect at all on anything?

It’s important to go over this to clear up your misconceptions about how things work, or else you won’t be able to write good code. So explain again how having those first two lines are expected to do anything. And run your script without them so you can see for yourself that they actually do nothing instead of anything that’s kinda cool.

When I wrote the code for the other thread with JoyNomX and JoyNomY, it was meant to define the nominal position of the stick because sometimes it can be off 1 or 2 from what is supposed to be its nominal value of 100. Do you understand? So adding or subtracting anything from them doesn’t make sense to do. When you subtract something from them, it defeats the purpose of why they’re there. So put them back to how I had them or there’s no use for me trying to help you with the script.

What also is not cool is that you asked me to tell how to do the this in your last thread, I explained it, then showed you some code when you asked me to, then instead of following up with what I posted, you ignored it and started this new thread. And then you even PM me to see if I can help with your new thread (even though I told you not to do that the last time you PM’d me but did it again anyway) after you didn’t even bother to try to implement what I already told you to do in the last thread.

DRLantern
Posts: 45
Joined: 05 May 2023, 20:21

Re: make image press on button with joy1

Post by DRLantern » 03 Jun 2023, 11:08

ok i removed them, but like all i want is making the image item launch a g label right, like make image item be pressed on button with joy1 and then a msgbox saying it works, then using guicontrol to find out wich picutre launched the label, how is that possible and how can i do that

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

Re: make image press on button with joy1

Post by boiler » 03 Jun 2023, 11:21

Like I said, I described it to you here, and when you asked that I show you code, I did that here. If you didn't understand it and had questions about it, you didn't ask or reply at all. You instead started a new thread.

DRLantern
Posts: 45
Joined: 05 May 2023, 20:21

Re: make image press on button with joy1

Post by DRLantern » 03 Jun 2023, 11:25

thats because when i tried using it i think it was the wrong variable right because the picture as v mouse pic, tell me if i got this wrong because its hard to use, even with the gosub is had probelms

DRLantern
Posts: 45
Joined: 05 May 2023, 20:21

Re: make image press on button with joy1

Post by DRLantern » 03 Jun 2023, 12:49

ok i posted something on old thread

Post Reply

Return to “Ask for Help (v1)”