Issue with Guis and mouse click

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Guest2018

Issue with Guis and mouse click

17 Jan 2018, 15:02

Hi,

I created 1 Gui (upper left corner) which activates another Gui (full screen) when clicking on it.
The full screen gui is split into 80 sections, each section stays for 1 value.
(I just created it in Excel and made a screenshot.)
The full screen gui does not contain any additional buttons or text.
The only function is that it catches the mouse cursor position and when clicking, it executes the specific operation.

When I click on the first gui to activate the second gui, it already executes the operation which belongs to gui 2, which is wrong.
If my mouse cursor is between x=0 and x=128 and y=0 and y=128, it should execute the defined operation (Send 1).
I tried to change the if condition and add a variable, but it doesn't work anymore.

So when the full screen gui is not visible, clicking on gui1 must not execute Send 1.
It must only make gui2 visible (toggle).

That's the code:

Code: Select all

^F2::
Gui, Gui01:-Caption
Gui, Gui01:+AlwaysOnTop
Gui, Gui01:Show, x0 y0 w128 h128 
Gui, Gui01:Add, Picture, x0 y0 w128 h128 gGuiNo1, pics\top01.jpg
return

GuiNo1:
gui1_count := 0
gui1_count++
SoundPlay, Chord.wav
if (gui1_count = 1)
{
  Gui, Gui02:-Caption
  Gui, Gui02:+AlwaysOnTop
  Gui, Gui02:Show, x0 y0 w1280 h1024 
  Gui, Gui02:Add, Picture, x0 y0 w1280 h1024, pics\01_80.png

  OnMessage(0x201, "WM_LBUTTONDOWN")
  return

  WM_LBUTTONDOWN(wParam, lParam)
  {
      X := lParam & 0xFFFF
      Y := lParam >> 16

    if ((x>=0 and x<=128 and y>=0 and y<=128) and (gui1_count = 1))
    {
      HideGuiWriteText()
      Send 1
    }
    if (x>128 and x<=256 and y>=0 and y<=128)
    {
      HideGuiWriteText()
      Send 2     
    }        
  }
}

HideGuiWriteText()
{
  Gui, Gui02:Hide
  Sleep, 2
  WinActivate ahk_class Notepad
  Sleep, 2
}

esc::
GuiClose:
ExitApp
Thanks for any help

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Rohwedder and 242 guests