Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

GUI Picture and Add Button


  • Please log in to reply
13 replies to this topic
ILL.1
  • Members
  • 84 posts
  • Last active: Apr 28 2005 11:42 AM
  • Joined: 29 Sep 2004
I found a problem with sending mouse clicks in a GUI.
I created a simple gui with the following:

MyPic = PATH TO PICTURE

GUI, Add, Picture, xm ym, %MyPic%
GUI, Add, Button, gOK xm ym, OK
GUI, Add, Button, gCancel xm ym+20, Cancel
GUI, Show, , Background Test
Return

Cancel:
GuiClose:
ExitApp

OK:
GUI, submit
MsgBox, OK Clicked
ExitApp

When the buttons are over top of the picture, mouse clicks do not work. Keyboard input does work. Is there something that I am missing, or is this how the GUI is suppose to work?
===============
----------ILL.1-----------
===============

Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004
The AHK Help file says :

Options for Assigning Actions and Variables

G: Gosub. To launch a subroutine in response to the press of a button, changing of a checkbox/radio, selection of a new choice, or the clicking of a picture or text control: include the letter G followed immediately by the name of the label to execute....

So try :
MyPic = PATH TO PICTURE

GUI, Add, Picture, xm ym gPicProc, %MyPic%
GUI, Add, Button, gOK xm ym, OK
GUI, Add, Button, gCancel xm ym+20, Cancel
GUI, Show, , Background Test
Return

Cancel:
GuiClose:
ExitApp

OK:
GUI, submit
MsgBox, OK Clicked
ExitApp

PicProc:
;here your procedure
return
May be I'm wrong...

ILL.1
  • Members
  • 84 posts
  • Last active: Apr 28 2005 11:42 AM
  • Joined: 29 Sep 2004
My understanding of that command leads me to believe that if I wanted an action to occur if I pressed the picture it would assign a label like you did. So, after adding the code like you suggested I did a little trouble shooting. It seems that the picture is considered to be in front, even though the buttons are on top. Do you know of a way to keep the buttons in front of the picture? Or is there a way to make the button clicks pass throguh the picture but not the GUI?
===============
----------ILL.1-----------
===============

Rajat
  • Members
  • 1904 posts
  • Last active: Jul 17 2015 07:45 AM
  • Joined: 28 Mar 2004
ur script works fine for me... make sure u've the latest download.

MIA

CleanNews.in : Bite sized latest news headlines from India with zero bloat


Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004
Well I must say I don't know why, when you click on one of the buttons, this is the action of the click on the picture wich is fired.
May be as the buttons are in the aera of the picture they are considered as part of the picture ???
Is it a bug or a normal behaviour ?
Please Chris, help !!!
But perhaps is it a good idea to implement, if it's possible, the equivalent of the HTML image maps in the AHK's GUI ?
Please Chris, do you think you can do that ?

Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004
to Rajat :
I have Win 98SE and the last version of AHK and the script works for me like I said.

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
Rajat's right: The issue with pictures "stealing clicks" was recently fixed. It sounds like your version is slightly too old to have that fix.

To take advantage of the fix, your picture mustn't have an associated g-label in its options.

Although already present in the installer, this fix will be announced in the changelog for version 1.0.20, which is due out tomorrow hopefully.

Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004

But perhaps is it a good idea to implement, if it's possible, the equivalent of the HTML image maps in the AHK's GUI ?
Please Chris, do you think you can do that ?

What do you think about that, Chris ?
Do you think it's a good idea ? Is it possible to do ?

Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004
About the subject of this post :
I have the last version of AHK, with the last modifications.
I tried with and without the "G" parameter
With : the 2 buttons and the pict give the G Pict procedure as result.
Without : nothing happens for me clicing on the pict or the buttons.
I have Win 98SE

Chris
  • Administrators
  • 10727 posts
  • Last active:
  • Joined: 02 Mar 2004
I'll make a note of it, but you may already know you could do it using something like the following:
Gui, Add, Pic, gMyPicClick, MyPic.jpg

...

return



MyPicClick:

MouseGetPos, ClickX, ClickY

ControlGetPos, PicX, PicY, PicW, PicH, Static4, A

... now compare the above coordinates and dimensions to figure out where in the picture the user clicked ...

return


ILL.1
  • Members
  • 84 posts
  • Last active: Apr 28 2005 11:42 AM
  • Joined: 29 Sep 2004
I'll download the new version once I get the chance.
===============
----------ILL.1-----------
===============

Nemroth
  • Members
  • 278 posts
  • Last active: Dec 31 2011 10:53 PM
  • Joined: 07 Sep 2004
Thanks Chris for your interesting code.

For me the equivalent of the HTML image maps is just a suggestion as I have personally no use of sutch a feature. But perhaps it ca be usefull for some guys.

ILL.1
  • Members
  • 84 posts
  • Last active: Apr 28 2005 11:42 AM
  • Joined: 29 Sep 2004
Downloaded the latest version and all is fixed. I was going to use the MouseGetPos, but I wanted to see if there was a fix for this first. I did a bit of a search before I posted and didn't see any answers to a fix. From now on I'll make sure that I have the lastest download. Thanks for all your help.
===============
----------ILL.1-----------
===============

  • Guests
  • Last active:
  • Joined: --
Appologies. I tried once again with 1.0.20 version and it's OK under W98 SE
For me too it was a version problem and I was sure th had install the last 1.0.19 one...