topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Friday March 29, 2024, 7:02 am
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Author Topic: 🤔 PixelNotifier alert when color is different, not same as it operates now?  (Read 5475 times)

mydo

  • Participant
  • Joined in 2019
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
"Would it be possible to change PixelNotifier such that an alert is triggered when the monitored pixel changes FROM it's current color value as opposed to when it changes TO a user defined, (anticipated), color value?"

script is by: skrommel, PixelNotifier,  www.dcmembers.com/skrommel/download/pixelnotifier/


Code: Text [Select]
  1. #SingleInstance,Force
  2.  
  3. SysGet,workarea,MonitorWorkArea
  4.  
  5. applicationname=PixelNotifier
  6.  
  7. Gosub,READINI
  8. Gosub,ACTIVATEALL
  9.  
  10. LOOP:
  11. Loop,%alarmscount%
  12. {
  13.   Sleep,500
  14.   If active_%A_Index%=0
  15.     Continue
  16.   If triggered_%A_Index%=1
  17.     Continue
  18.   x:=alarms_%A_Index%_1
  19.   y:=alarms_%A_Index%_2
  20.   pixelcolor:=alarms_%A_Index%_3
  21.   relative:=alarms_%A_Index%_4
  22.   If relative=1
  23.     CoordMode,Pixel,Screen
  24.   Else
  25.     CoordMode,Pixel,Relative
  26.   PixelGetColor,readpixelcolor,x,y,RGB
  27.   StringTrimLeft,readpixelcolor,readpixelcolor,2
  28.   If readpixelcolor<>%pixelcolor%
  29.     Continue
  30.   triggered_%A_Index%=1
  31.   message:=alarms_%A_Index%_5
  32.   fullscreencolor:=alarms_%A_Index%_6
  33.   Gui,%A_Index%:+Owner -Resize -SysMenu -MinimizeBox -MaximizeBox -Disabled +Caption +Border -ToolWindow
  34.   Gui,%A_Index%:Color,%fullscreencolor%
  35.   Gui,%A_Index%:Add,Button,X320 Y240 Default GOK_%A_Index%,%message%
  36.   Gui,%A_Index%:Show,X-4 Y-4 W%workareaRight% H%workareaBottom%,%applicationname% %A_Index%
  37.   SetTimer,TRIGGERED_%A_Index%,5000
  38.   Gosub,TRIGGERED_%A_Index%    
  39. }
  40. Goto,LOOP
  41.  
  42.  
  43. TRIGGERED_9:
  44. triggered=9
  45. Goto,TRIGGERED
  46. TRIGGERED_8:
  47. triggered=8
  48. Goto,TRIGGERED
  49. TRIGGERED_7:
  50. triggered=7
  51. Goto,TRIGGERED
  52. TRIGGERED_6:
  53. triggered=6
  54. Goto,TRIGGERED
  55. TRIGGERED_5:
  56. triggered=5
  57. Goto,TRIGGERED
  58. TRIGGERED_4:
  59. triggered=4
  60. Goto,TRIGGERED
  61. TRIGGERED_3:
  62. triggered=3
  63. Goto,TRIGGERED
  64. TRIGGERED_2:
  65. triggered=2
  66. Goto,TRIGGERED
  67. TRIGGERED_1:
  68. triggered=1
  69. Goto,TRIGGERED
  70. TRIGGERED:
  71. sound:=alarms_%triggered%_7
  72. SoundPlay,%sound%
  73. ;WinSet,Top,,%applicationname% %triggered%
  74. WinActivate,%applicationname% %triggered%
  75. Return
  76.  
  77.  
  78. OK_9:
  79. ok=9
  80. Goto,BUTTON
  81. OK_8:
  82. ok=8
  83. Goto,BUTTON
  84. OK_7:
  85. ok=7
  86. Goto,BUTTON
  87. OK_6:
  88. ok=6
  89. Goto,BUTTON
  90. OK_5:
  91. ok=5
  92. Goto,BUTTON
  93. OK_4:
  94. ok=4
  95. Goto,BUTTON
  96. OK_3:
  97. ok=3
  98. Goto,BUTTON
  99. OK_2:
  100. ok=2
  101. Goto,BUTTON
  102. OK_1:
  103. ok=1
  104. Goto,BUTTON
  105. BUTTON:
  106. SetTimer,TRIGGERED_%ok%,Off
  107. Gui,%ok%:Destroy
  108. active_%ok%=0
  109. Gosub,TRAYMENU
  110. Return
  111.  
  112.  
  113. TOGGLE_9:
  114. TOGGLE_8:
  115. TOGGLE_7:
  116. TOGGLE_6:
  117. TOGGLE_5:
  118. TOGGLE_4:
  119. TOGGLE_3:
  120. TOGGLE_2:
  121. TOGGLE_1:
  122. menu:=A_ThisMenuItemPos-2
  123. If active_%menu%=0
  124. {
  125.   active_%menu%=1
  126.   triggered_%menu%=0
  127.   Gosub,TRAYMENU
  128. }
  129. Else
  130. {
  131.   Gosub,OK_%menu%
  132. }
  133. Return
  134.  
  135.  
  136. ADD:
  137. Gosub,DEACTIVATEALL
  138. Loop
  139. {
  140.   CoordMode,Pixel,Screen
  141.   CoordMode,Mouse,Screen
  142.   MouseGetPos,sx,sy
  143.   PixelGetColor,readpixelcolor,sx,sy,RGB
  144.   StringTrimLeft,readpixelcolor,readpixelcolor,2
  145.   CoordMode,Mouse,Relative
  146.   MouseGetPos,x,y
  147.   ToolTip,Color:`t%readpixelcolor%`nScreenCoord:`t%sx% %sy%`nWindowCoord:`t%x% %y%`n`nPress`tto add`n1=`tScreenCoord`n2=`tWindowCoord`nEsc=Cancel
  148.   GetKeyState,screen,1,P
  149.   If screen=D
  150.   {
  151.     FileAppend,`n%sx%`,%sy%`,%readpixelcolor%`,1`,Message`,FFFFFF`,C:\Windows\Ding.wav,%applicationname%.ini
  152.     ToolTip,
  153.     Gosub,SETTINGS
  154.     Break  
  155.   }
  156.   GetKeyState,window,2,P
  157.   If window=D
  158.   {
  159.     FileAppend,`n%x%`,%y%`,%readpixelcolor%`,2`,Message`,FFFFFF`,C:\Windows\Ding.wav,%applicationname%.ini
  160.     ToolTip,
  161.     Gosub,SETTINGS
  162.     Break  
  163.   }
  164.   GetKeyState,esc,Esc,P
  165.   If esc=D
  166.   {
  167.     ToolTip,
  168.     Break
  169.   }
  170. }
  171. Return
  172.  
  173.  
  174. SETTINGS:
  175. Gosub,DEACTIVATEALL
  176. Gosub,READINI
  177. Run,%applicationname%.ini
  178. Return
  179.  
  180.  
  181. READINI:
  182. IfNotExist,%applicationname%.ini
  183. {
  184. ini=`;%applicationname%.ini
  185. ini=%ini%`n`;
  186. ini=%ini%`n`;Syntax:
  187. ini=%ini%`n`;
  188. ini=%ini%`n`;x,y,pixelcolor,relative,message,fullscreencolor,sound
  189. ini=%ini%`n`;
  190. ini=%ini%`n`; x                               Horizontal positon of the pixel to watch
  191. ini=%ini%`n`; y                               vertical positon of the pixel to watch
  192. ini=%ini%`n`; pixelcolor=000000-FFFFFF        RGB-color of the pixel to watch
  193. ini=%ini%`n`; relative=1,2                    Find pixel relative to 1=the screen or 2=the active window
  194. ini=%ini%`n`; message                         The message to display
  195. ini=%ini%`n`; fullscreencolor=000000-FFFFFF   Color of the fullscreen notification
  196. ini=%ini%`n`; sound                           Path to the WAV-file
  197. ini=%ini%`n`;
  198. ini=%ini%`n`;Example:
  199. ini=%ini%`n`;
  200. ini=%ini%`n`;0,0,FFFFFF,White color detected!,0,0000FF,C:\Windows\Media\Ding.wav
  201. ini=%ini%`n`;  Watches the screenposition 0,0 for the color white and plays a sound and
  202. ini=%ini%`n`;  displays a blue message window with the text White color detected!
  203. ini=%ini%`n
  204. ini=%ini%`n200,200,FFFFFF,1,White color detected!,0000FF,C:\Windows\Media\Ding.wav
  205. ini=%ini%`n400,400,FFFFFF,1,White color detected!,FF0000,C:\Windows\Media\Ding.wav
  206. FileAppend,%ini%,%applicationname%.ini
  207. ini=
  208. }
  209. alarmscount=0
  210. Loop,Read,%applicationname%.ini
  211. {
  212.   IfInString,A_LoopReadLine,`;
  213.     Continue
  214.   IfNotInString,A_LoopReadLine,`,
  215.     Continue
  216.   alarmscount+=1
  217.   StringSplit,alarms_%alarmscount%_,A_LoopReadLine,`,
  218. }
  219. Return
  220. ...
  221. ...
  222. ...
  223. ...
« Last Edit: February 28, 2019, 01:15 AM by mydo »

Ath

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 3,612
    • View Profile
    • Donate to Member
I've modified the original download from the Skrommel site to support your request, and also updated the documentation in the ini file (source and sample ini in the attached zip file)
No compiled exe is provided, so you'll have to have AutoHotKey installed on your computer.

Modification: The pixelcolor can now optionally be prefixed with an exclamation mark, like !FFFFFF, so the pixel is watched for being not-equal to that color. The message should probably be adjusted accordingly.

NB: There is no support for setting this option from using the Add alarm... option from the context menu, but it can easily be set as the ini file is opened after adding an alarm.

Code: Autohotkey [Select]
  1. ;PixelNotifier.ahk
  2. ; Watches a screen pixel for a specific color, and notifies the user when it occurs.
  3. ;Skrommel @2005
  4. ; 2019-03-02 Ath: Added inverted check by prefixing the pixelcolor with !
  5.  
  6.  
  7. SysGet,workarea,MonitorWorkArea
  8.  
  9. applicationname=PixelNotifier
  10.  
  11. Gosub,READINI
  12. Gosub,ACTIVATEALL
  13.  
  14. Loop,%alarmscount%
  15. {
  16.   Sleep,500
  17.   If active_%A_Index%=0
  18.     Continue
  19.   If triggered_%A_Index%=1
  20.     Continue
  21.   x:=alarms_%A_Index%_1
  22.   y:=alarms_%A_Index%_2
  23.   pixelcolor:=alarms_%A_Index%_3
  24.   StringLeft,invert,pixelcolor,1
  25.   If invert = !
  26.   {
  27.         checkInvert=1
  28.         StringTrimLeft,pixelcolor,pixelcolor,1
  29.   }
  30.   relative:=alarms_%A_Index%_4
  31.   If relative=1
  32.     CoordMode,Pixel,Screen
  33.   Else
  34.     CoordMode,Pixel,Relative
  35.   PixelGetColor,readpixelcolor,x,y,RGB
  36.   StringTrimLeft,readpixelcolor,readpixelcolor,2
  37.   If checkInvert = 1
  38.   {
  39.         If readpixelcolor=%pixelcolor%
  40.           Continue
  41.   }
  42.   else
  43.   {
  44.         If readpixelcolor<>%pixelcolor%
  45.           Continue
  46.   }
  47.   triggered_%A_Index%=1
  48.   message:=alarms_%A_Index%_5
  49.   fullscreencolor:=alarms_%A_Index%_6
  50.   Gui,%A_Index%:+Owner -Resize -SysMenu -MinimizeBox -MaximizeBox -Disabled +Caption +Border -ToolWindow
  51.   Gui,%A_Index%:Color,%fullscreencolor%
  52.   Gui,%A_Index%:Add,Button,X320 Y240 Default GOK_%A_Index%,%message%
  53.   Gui,%A_Index%:Show,X-4 Y-4 W%workareaRight% H%workareaBottom%,%applicationname% %A_Index%
  54.   SetTimer,TRIGGERED_%A_Index%,5000
  55.   Gosub,TRIGGERED_%A_Index%    
  56. }
  57.  
  58.  
  59. TRIGGERED_9:
  60. triggered=9
  61. Goto,TRIGGERED
  62. TRIGGERED_8:
  63. triggered=8
  64. Goto,TRIGGERED
  65. TRIGGERED_7:
  66. triggered=7
  67. Goto,TRIGGERED
  68. TRIGGERED_6:
  69. triggered=6
  70. Goto,TRIGGERED
  71. TRIGGERED_5:
  72. triggered=5
  73. Goto,TRIGGERED
  74. TRIGGERED_4:
  75. triggered=4
  76. Goto,TRIGGERED
  77. TRIGGERED_3:
  78. triggered=3
  79. Goto,TRIGGERED
  80. TRIGGERED_2:
  81. triggered=2
  82. Goto,TRIGGERED
  83. TRIGGERED_1:
  84. triggered=1
  85. Goto,TRIGGERED
  86. TRIGGERED:
  87. sound:=alarms_%triggered%_7
  88. SoundPlay,%sound%
  89. ;WinSet,Top,,%applicationname% %triggered%
  90. WinActivate,%applicationname% %triggered%
  91. Return
  92.  
  93.  
  94. OK_9:
  95. ok=9
  96. OK_8:
  97. ok=8
  98. OK_7:
  99. ok=7
  100. OK_6:
  101. ok=6
  102. OK_5:
  103. ok=5
  104. OK_4:
  105. ok=4
  106. OK_3:
  107. ok=3
  108. OK_2:
  109. ok=2
  110. OK_1:
  111. ok=1
  112. SetTimer,TRIGGERED_%ok%,Off
  113. active_%ok%=0
  114. Gosub,TRAYMENU
  115. Return
  116.  
  117.  
  118. TOGGLE_9:
  119. TOGGLE_8:
  120. TOGGLE_7:
  121. TOGGLE_6:
  122. TOGGLE_5:
  123. TOGGLE_4:
  124. TOGGLE_3:
  125. TOGGLE_2:
  126. TOGGLE_1:
  127. menu:=A_ThisMenuItemPos-2
  128. If active_%menu%=0
  129. {
  130.   active_%menu%=1
  131.   triggered_%menu%=0
  132.   Gosub,TRAYMENU
  133. }
  134. Else
  135. {
  136.   Gosub,OK_%menu%
  137. }
  138. Return
  139.  
  140.  
  141. Gosub,DEACTIVATEALL
  142. {
  143.   CoordMode,Pixel,Screen
  144.   CoordMode,Mouse,Screen
  145.   MouseGetPos,sx,sy
  146.   PixelGetColor,readpixelcolor,sx,sy,RGB
  147.   StringTrimLeft,readpixelcolor,readpixelcolor,2
  148.   CoordMode,Mouse,Relative
  149.   ToolTip,Color:`t%readpixelcolor%`nScreenCoord:`t%sx% %sy%`nWindowCoord:`t%x% %y%`n`nPress`tto add`n1=`tScreenCoord`n2=`tWindowCoord`nEsc=Cancel
  150.   GetKeyState,screen,1,P
  151.   If screen=D
  152.   {
  153.     FileAppend,`n%sx%`,%sy%`,%readpixelcolor%`,1`,Message`,FFFFFF`,C:\Windows\Ding.wav,%applicationname%.ini
  154.     ToolTip,
  155.     Gosub,SETTINGS
  156.     Break  
  157.   }
  158.   GetKeyState,window,2,P
  159.   If window=D
  160.   {
  161.     FileAppend,`n%x%`,%y%`,%readpixelcolor%`,2`,Message`,FFFFFF`,C:\Windows\Ding.wav,%applicationname%.ini
  162.     ToolTip,
  163.     Gosub,SETTINGS
  164.     Break  
  165.   }
  166.   GetKeyState,esc,Esc,P
  167.   If esc=D
  168.   {
  169.     ToolTip,
  170.     Break
  171.   }
  172. }
  173. Return
  174.  
  175.  
  176. SETTINGS:
  177. Gosub,DEACTIVATEALL
  178. Gosub,READINI
  179. Run,%applicationname%.ini
  180. Return
  181.  
  182.  
  183. READINI:
  184. IfNotExist,%applicationname%.ini
  185. {
  186. ini=`;%applicationname%.ini
  187. ini=%ini%`n`;
  188. ini=%ini%`n`;Syntax:
  189. ini=%ini%`n`;
  190. ini=%ini%`n`;x,y,pixelcolor,relative,message,fullscreencolor,sound
  191. ini=%ini%`n`;
  192. ini=%ini%`n`; x                               Horizontal positon of the pixel to watch
  193. ini=%ini%`n`; y                               vertical positon of the pixel to watch
  194. ini=%ini%`n`; pixelcolor=[!]000000-FFFFFF     RGB-color of the pixel to watch
  195. ini=%ini%`n`;                                 If the RGB color is optionally prefixed with an exclamation mark,
  196. ini=%ini%`n`;                                 like !FFFFFF, the pixel is watched for being not-equal to that color
  197. ini=%ini%`n`; relative=1,2                    Find pixel relative to 1=the screen or 2=the active window
  198. ini=%ini%`n`; message                         The message to display
  199. ini=%ini%`n`; fullscreencolor=000000-FFFFFF   Color of the fullscreen notification
  200. ini=%ini%`n`; sound                           Path to the WAV-file
  201. ini=%ini%`n`;
  202. ini=%ini%`n`;Example:
  203. ini=%ini%`n`;
  204. ini=%ini%`n`;0,0,FFFFFF,White color detected!,0,0000FF,C:\Windows\Media\Ding.wav
  205. ini=%ini%`n`;  Watches the screenposition 0,0 for the color white and plays a sound and
  206. ini=%ini%`n`;  displays a blue message window with the text White color detected!
  207. ini=%ini%`n
  208. ini=%ini%`n200,200,FFFFFF,1,White color detected!,0000FF,C:\Windows\Media\Ding.wav
  209. ini=%ini%`n400,400,FFFFFF,1,White color detected!,FF0000,C:\Windows\Media\Ding.wav
  210. FileAppend,%ini%,%applicationname%.ini
  211. ini=
  212. }
  213. alarmscount=0
  214. Loop,Read,%applicationname%.ini
  215. {
  216.     Continue
  217.     Continue
  218.   alarmscount+=1
  219.   StringSplit,alarms_%alarmscount%_,A_LoopReadLine,`,
  220. }
  221. Return
  222.  
  223.  
  224. TRAYMENU:
  225. Menu,Tray,NoStandard
  226. Menu,Tray,DeleteAll
  227. Menu,Tray,Add,%applicationname%,TOGGLE
  228. Menu,Tray,Add,
  229. Loop,%alarmscount%
  230. {
  231.   message:=alarms_%A_Index%_5
  232.   Menu,Tray,Add,&%A_Index%:%message%,TOGGLE_%A_Index%
  233.   If active_%A_Index%=1
  234.     Menu,Tray,Check,&%A_Index%:%message%
  235. }
  236. Menu,Tray,Add,
  237. Menu,Tray,Add,&Enable All,ACTIVATEALL
  238. Menu,Tray,Add,&Disable All,DEACTIVATEALL
  239. Menu,Tray,Add,
  240. Menu,Tray,Add,&Add alarm...,Add
  241. Menu,Tray,Add,&Edit alarms...,SETTINGS
  242. Menu,Tray,Add,
  243. Menu,Tray,Add,&About...,ABOUT
  244. Menu,Tray,Add,E&xit,EXIT
  245. Menu,Tray,Default,%applicationname%
  246. Menu,Tray,Tip,%applicationname%
  247. Return
  248.  
  249.  
  250. TOGGLE:
  251. Pause,Toggle
  252. Return
  253.  
  254.  
  255. ACTIVATEALL:
  256. Loop,%alarmscount%
  257. {
  258.   active_%A_Index%=1
  259.   triggered_%A_Index%=0
  260.   Gosub,TRAYMENU
  261. }
  262. Return
  263.  
  264.  
  265. DEACTIVATEALL:
  266. Loop,%alarmscount%
  267. {
  268.   SetTimer,TRIGGERED_%A_Index%,Off
  269.   Gui,%A_Index%:Destroy
  270.   active_%A_Index%=0
  271.   triggered_%A_Index%=0
  272.   Gosub,TRAYMENU
  273. }
  274. Return
  275.  
  276.  
  277. ABOUT:
  278. Gui,99:Margin,20,20
  279. Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
  280. Gui,99:Font,Bold
  281. Gui,99:Add,Text,x+10 yp+10,%applicationname% v1.0
  282. Gui,99:Add,Text,y+10,Watches a screen pixel for a specific color, and notifies the user when it occurs.
  283. Gui,99:Add,Text,y+5,- Change settings using Settings in the tray menu
  284. Gui,99:Add,Text,y+5,- Shows a message, plays a sound and fills the whole screen with color
  285.  
  286. Gui,99:Add,Picture,xm y+20 Icon5,%applicationname%.exe
  287. Gui,99:Font,Bold
  288. Gui,99:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
  289. Gui,99:Add,Text,y+10,For more tools, information and donations, please visit
  290. Gui,99:Font,CBlue Underline
  291. Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
  292.  
  293. Gui,99:Add,Picture,xm y+20 Icon7,%applicationname%.exe
  294. Gui,99:Font,Bold
  295. Gui,99:Add,Text,x+10 yp+10,DonationCoder
  296. Gui,99:Add,Text,y+10,Please support the contributors at
  297. Gui,99:Font,CBlue Underline
  298. Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
  299.  
  300. Gui,99:Add,Picture,xm y+20 Icon6,%applicationname%.exe
  301. Gui,99:Font,Bold
  302. Gui,99:Add,Text,x+10 yp+10,AutoHotkey
  303. Gui,99:Add,Text,y+10,This tool was made using the powerful
  304. Gui,99:Font,CBlue Underline
  305. Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
  306.  
  307. Gui,99:Show,,%applicationname% About
  308. hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
  309. OnMessage(0x200,"WM_MOUSEMOVE")
  310. Return
  311.  
  312. 1HOURSOFTWARE:
  313.  Run,http://www.1hoursoftware.com,,UseErrorLevel
  314. Return
  315.  
  316. DONATIONCODER:
  317.  Run,http://www.donationcoder.com,,UseErrorLevel
  318. Return
  319.  
  320. AUTOHOTKEY:
  321.  Run,http://www.autohotkey.com,,UseErrorLevel
  322. Return
  323.  
  324. 99GuiClose:
  325.  Gui,99:Destroy
  326.   OnMessage(0x200,"")
  327.   DllCall("DestroyCursor","Uint",hCur)
  328. Return
  329.  
  330. WM_MOUSEMOVE(wParam,lParam)
  331. {
  332.   Global hCurs
  333.   MouseGetPos,,,,ctrl
  334.   If ctrl in Static9,Static13,Static17
  335.     DllCall("SetCursor","UInt",hCurs)
  336.   Return
  337. }
  338. Return
  339.  
  340.  

mydo

  • Participant
  • Joined in 2019
  • *
  • default avatar
  • Posts: 3
    • View Profile
    • Donate to Member
This is awesome, thanks so much. 

I feel like this script will be a lot more useful now to a lot of people.  I personally use it for detecting changes in a software which does not have support for notifications.  I have it set up to send me an email anything the color is NOT detected in a pixel 😊
« Last Edit: March 05, 2019, 02:08 PM by mydo »