AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

A 'if 2 things match then do something' code

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Wex
Guest





PostPosted: Sun Apr 17, 2005 8:35 am    Post subject: A 'if 2 things match then do something' code Reply with quote

Hello

I am trying to make a script that looks for a colour under the mouse pointer, that when found will show a tooltip.

I've worked out the finding bit, but cannot work out how to do the 'if both find the colour then show the tooltip' bit


#InstallMouseHook

SetKeyDelay,,20

Suspend
^p::Suspend
^o::Pause
^r::Reload

k::
loop
{
MouseGetPos, MouseX, MouseY
PixelSearch,,, MouseX - 100, MouseY + 100, MouseX, MouseY -100, 0xFFE671, 10,
if ErrorLevel = 1
ToolTip, move right

MouseGetPos, MouseX, MouseY
PixelSearch,,, MouseX, MouseY - 100, MouseX + 100, MouseY + 100, 0xFFE671, 10,
if ErrorLevel = 1
ToolTip, move left

Sleep, 100
}

;insert 'if both errorlevels = 1 then show tooltip, found' code



Tia

Wex
Back to top
niwi



Joined: 27 Feb 2005
Posts: 128
Location: Heidelberg, Germany

PostPosted: Sun Apr 17, 2005 9:21 am    Post subject: Reply with quote

Hi,

try this (not tested):
Code:
#InstallMouseHook

SetKeyDelay,,20

Suspend
^p::Suspend
^o::Pause
^r::Reload

k::
loop
{
MouseGetPos, MouseX, MouseY
PixelSearch,,, MouseX - 100, MouseY + 100, MouseX, MouseY -100, 0xFFE671, 10,
if ErrorLevel = 1
{
  errlev1 = 1
  ToolTip, move right
}
else
 errlev1 = 0


MouseGetPos, MouseX, MouseY
PixelSearch,,, MouseX, MouseY - 100, MouseX + 100, MouseY + 100, 0xFFE671, 10,
if ErrorLevel = 1
{
  ToolTip, move left
  errlev2 = 1
}
else
  errlev2 = 0

Sleep, 100
}

if (errlev1 + errlev2 = 2)
{
;insert 'if both errorlevels = 1 then show tooltip, found' code

}
Back to top
View user's profile Send private message
Wex
Guest





PostPosted: Sun Apr 17, 2005 10:45 am    Post subject: Reply with quote

Thx niwi for helping me understand what to do, I ended up with this which works a treat!!:


Code:
#InstallMouseHook

SetKeyDelay,,20

Suspend
^p::Suspend
^o::Pause
^r::Reload

k::
loop
{
MouseGetPos, MouseX, MouseY
PixelSearch,,, MouseX - 100, MouseY + 100, MouseX, MouseY -100, 0xFFE671, 10,
if ErrorLevel = 1
{
  errlev1 = 1
  ToolTip, move right
}
else
 errlev1 = 0


MouseGetPos, MouseX, MouseY
PixelSearch,,, MouseX, MouseY - 100, MouseX + 100, MouseY + 100, 0xFFE671, 10,
if ErrorLevel = 1
{
  ToolTip, move left
  errlev2 = 1
}
else
  errlev2 = 0

Sleep, 100

if (errlev1 + errlev2 = 0)
{
ToolTip, found
}
}
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group