JamesHustle Posted November 1, 2018 Posted November 1, 2018 I have a hotkey script and it runs on ifwinactive and it will do XYZ but I cant figure out how to have it lookout for 2 separate programs If WinActive('[CLASS:AE_CApplication_15.1]','Chrome - Chromium') doenst work. but they work on their own i.e. If WinActive('Chrome - Chromium') - works If WinActive('[CLASS:AE_CApplication_15.1]') - works how can I have it look out for both?
Nine Posted November 1, 2018 Posted November 1, 2018 If WinActive('Chrome - Chromium') and WinActive('[CLASS:AE_CApplication_15.1]') then XYZ “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JamesHustle Posted November 1, 2018 Author Posted November 1, 2018 17 minutes ago, Nine said: If WinActive('Chrome - Chromium') and WinActive('[CLASS:AE_CApplication_15.1]') then XYZ That didnt work for me but the OR did 5 minutes ago, mikell said: ... or 'or' lol I thought of that in my head but I didnt think it would be a code type of thing lol, thanks it worked and easy enough.
Nine Posted November 1, 2018 Posted November 1, 2018 OR ya “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
JamesHustle Posted November 2, 2018 Author Posted November 2, 2018 8 hours ago, mikell said: ... or 'or' I initially thought this worked cause well it performed the action when I tested it but what I failed to test was if it DOES NOT perform the action if those windows arent active and well this or seems to nullify the 'IF winactive" statement and just triggers the action no matter what when called from hotkey this is my exact script Im working with. #include <AutoItConstants.au3> HotKeySet("{NUMPADADD}", "ENABLE") While 1 Sleep(100) WEnd Func ENABLE() If WinActive('Chrome - Chromium') Or ('[CLASS:AE_CApplication_15.1]') Then Switch @HotKeyPressed Case "{NUMPADADD}" $iPID = Run("rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,1", @ScriptDir, @SW_HIDE) AutoItSetOption("MouseCoordMode",2) WinWaitActive("[CLASS:#32770]", "", 10) MouseClick($MOUSE_CLICK_RIGHT, 83, 106,1, 0) send('E') Sleep(100) ProcessClose($iPID) Case "{NUMPADADD}" Exit EndSwitch Else HotKeySet(@HotKeyPressed) Send(@HotKeyPressed) HotKeySet(@HotKeyPressed, "ENABLE") EndIf EndFunc
mikell Posted November 2, 2018 Posted November 2, 2018 I don't understand the reason for all this hotkey management. Isn't this enough ? #include <AutoItConstants.au3> HotKeySet("{NUMPADADD}", "ENABLE") While 1 Sleep(10) WEnd Func ENABLE() If WinActive('Chrome - Chromium') Or ('[CLASS:AE_CApplication_15.1]') Then $iPID = Run("rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,1", @ScriptDir, @SW_HIDE) AutoItSetOption("MouseCoordMode",2) WinWaitActive("[CLASS:#32770]", "", 10) MouseClick($MOUSE_CLICK_RIGHT, 83, 106,1, 0) send('E') Sleep(100) ProcessClose($iPID) EndIf EndFunc
FrancescoDiMuro Posted November 2, 2018 Posted November 2, 2018 @JamesHustle If WinActive('Chrome - Chromium') Or ('[CLASS:AE_CApplication_15.1]') Then should be If WinActive('Chrome - Chromium') Or WinActive('[CLASS:AE_CApplication_15.1]') Then ; Are you sure that's an OR and not an AND? ; The condition to continue with the script is that ; OR a Window is active, OR another one it is? And, I agree with @mikell Click here to see my signature: Spoiler ALWAYS GOOD TO READ: Forum Rules Forum Etiquette
JamesHustle Posted November 2, 2018 Author Posted November 2, 2018 1 hour ago, mikell said: I don't understand the reason for all this hotkey management. Isn't this enough ? #include <AutoItConstants.au3> HotKeySet("{NUMPADADD}", "ENABLE") While 1 Sleep(10) WEnd Func ENABLE() If WinActive('Chrome - Chromium') Or ('[CLASS:AE_CApplication_15.1]') Then $iPID = Run("rundll32.exe shell32.dll,Control_RunDLL mmsys.cpl,,1", @ScriptDir, @SW_HIDE) AutoItSetOption("MouseCoordMode",2) WinWaitActive("[CLASS:#32770]", "", 10) MouseClick($MOUSE_CLICK_RIGHT, 83, 106,1, 0) send('E') Sleep(100) ProcessClose($iPID) EndIf EndFunc I've been using this setup for a long while now, Never had any issues, I remember running it your version and a few others way but I used to run into issues like the script eating up alot of resources such as memory, or hijacking the key so its not usuable anymore etc, and with this way I never ran into those issues again. 1 hour ago, FrancescoDiMuro said: @JamesHustle If WinActive('Chrome - Chromium') Or ('[CLASS:AE_CApplication_15.1]') Then should be If WinActive('Chrome - Chromium') Or WinActive('[CLASS:AE_CApplication_15.1]') Then ; Are you sure that's an OR and not an AND? ; The condition to continue with the script is that ; OR a Window is active, OR another one it is? And, I agree with @mikell thanks lol another simple error I overlooked, and yes its OR, yeah the condition to continue is on that winactive. What this script does is simple enable my microphone with a single hotkey when Im in 2 certain programs cause thats all i need the mic for, and I also have a disable script which is basically the same thing just to disable. and i answered why I use all the hotkey management above. Basically its what worked for me when I first started without issue so I stuck with it.
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