AlvinHu1991 Posted November 3, 2014 Share Posted November 3, 2014 (edited) Hello, I currently have a script that shows alerts on a tooltip for me. But I want to be able to toggle certain scripts on and off by using HotKeySet. Or if there's a way to rewrite into the running script without closing the script. Here's my basic example scripts: Script #1 If PixelGetColor(43, 834) = 0x4D3924 Then ToolTip("Someone just messaged you.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(43, 834) = 0xE6CD94 Else EndIf Script #2 If Not PixelGetColor(883, 834) = 0x0A0503 Then ToolTip("An attachment has arrived.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(883, 834) = 0x0A0503 Else EndIf Edit: Basically I want to maintain several functions active.(With an option to toggle them on or off) But with HotKeySet it will only allow one function active at a time. If anyone can direct me to the direction or if its not possible, thank you! Edited November 3, 2014 by AlvinHu1991 Link to comment Share on other sites More sharing options...
MikahS Posted November 3, 2014 Share Posted November 3, 2014 (edited) Using HotKeySet you can do something like this: HotKeySet("{F1}", "firstFunc") HotKeySet("{F2}", "secondFunc") While 1 ; run indefinitely WEnd Func firstFunc() If PixelGetColor(43, 834) = 0x4D3924 Then ToolTip("Someone just messaged you.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(43, 834) = 0xE6CD94 EndIf EndFunc ;==>firstFunc Func secondFunc() If Not PixelGetColor(883, 834) = 0x0A0503 Then ToolTip("An attachment has arrived.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(883, 834) = 0x0A0503 EndIf EndFunc ;==>secondFunc EDIT: Hopefully this is what you mean, I think I'm a little confused on what you completely wanted. EDIT: If you wanted these running in one loop, then when hitting the hotkey take out one, then you would just have 3 functions, 1 full with both script 1 & 2 (so you can toggle back to regular functionality), 1 with just script 1, and another with just script 2. Edited November 3, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
AlvinHu1991 Posted November 3, 2014 Author Share Posted November 3, 2014 (edited) Using HotKeySet you can do something like this: HotKeySet("{F1}", "firstFunc") HotKeySet("{F2}", "secondFunc") While 1 ; run indefinitely WEnd Func firstFunc() If PixelGetColor(43, 834) = 0x4D3924 Then ToolTip("Someone just messaged you.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(43, 834) = 0xE6CD94 EndIf EndFunc ;==>firstFunc Func secondFunc() If Not PixelGetColor(883, 834) = 0x0A0503 Then ToolTip("An attachment has arrived.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(883, 834) = 0x0A0503 EndIf EndFunc ;==>secondFunc EDIT: Hopefully this is what you mean, I think I'm a little confused on what you completely wanted. EDIT: If you wanted these running in one loop, then when hitting the hotkey take out one, then you would just have 3 functions, 1 full with both script 1 & 2 (so you can toggle back to regular functionality), 1 with just script 1, and another with just script 2. The problem with HotKeySet is it only allows one function to be activate at a time So lets say when I press F1 then Press F2, F1 will be canceled out and F2 will be the only script running. But I want them both to be on or off when I toggle them. If toggling with HotKeySet is possible or not? Or if there's a similar way of writing it and if you can show me any example or lead me to the function im looking for. Thanks Edited November 3, 2014 by AlvinHu1991 Link to comment Share on other sites More sharing options...
water Posted November 3, 2014 Share Posted November 3, 2014 Which program do you try to automate? If the program offers a COM interface then you could try to automate this events. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
MikahS Posted November 3, 2014 Share Posted November 3, 2014 (edited) The problem with HotKeySet is it only allows one function to be activate at a time So lets say when I press F1 then Press F2, F1 will be canceled out and F2 will be the only script running. But I want them both to be on or off when I toggle them. If toggling with HotKeySet is possible or not? Or if there's a similar way of writing it and if you can show me any example or lead me to the function im looking for. Thanks HotKeySet("{F1}", "firstFunc") HotKeySet("{F2}", "secondFunc") Local $hDLL = DllOpen('User32.dll') While 1 ; run indefinitely WEnd Func firstFunc() Do If PixelGetColor(43, 834) = 0x4D3924 Then ToolTip("Someone just messaged you.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(43, 834) = 0xE6CD94 ElseIf Not PixelGetColor(883, 834) = 0x0A0503 Then ToolTip("An attachment has arrived.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(883, 834) = 0x0A0503 EndIf Until _IsPressed("71", $hDLL) EndFunc ;==>firstFunc Func secondFunc() Do Until _IsPressed("70", $hDLL) EndFunc ;==>secondFunc Maybe like this? Edited November 3, 2014 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Solution Danp2 Posted November 3, 2014 Solution Share Posted November 3, 2014 Add two variables that are toggled whenever you press the designated hotkeys. Then check the variable in your main loop to determine if you should perform each specific section of code. Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
AlvinHu1991 Posted November 3, 2014 Author Share Posted November 3, 2014 Add two variables that are toggled whenever you press the designated hotkeys. Then check the variable in your main loop to determine if you should perform each specific section of code. Thanks, It actually worked better than I thought! HotKeySet("{F1}", "firstFunc") HotKeySet("{F2}", "secondFunc") Local $hDLL = DllOpen('User32.dll') While 1 ; run indefinitely WEnd Func firstFunc() Do If PixelGetColor(43, 834) = 0x4D3924 Then ToolTip("Someone just messaged you.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(43, 834) = 0xE6CD94 ElseIf Not PixelGetColor(883, 834) = 0x0A0503 Then ToolTip("An attachment has arrived.", @DesktopWidth / 2, 10, "", 1, 2) Do Sleep(100) Until PixelGetColor(883, 834) = 0x0A0503 EndIf Until _IsPressed("71", $hDLL) EndFunc ;==>firstFunc Func secondFunc() Do Until _IsPressed("70", $hDLL) EndFunc ;==>secondFunc Maybe like this? Thanks for all your help! MikahS 1 Link to comment Share on other sites More sharing options...
MikahS Posted November 3, 2014 Share Posted November 3, 2014 My pleasure Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now