Better use ifwinactive or #ifwinactive

Get help with using AutoHotkey and its commands and hotkeys
braunbaer
Posts: 11
Joined: 22 Feb 2016, 10:49

Better use ifwinactive or #ifwinactive

21 Jan 2018, 15:43

I use the hotkey #P to enter login info where it is needed. Of course, the login data and the necessary actions depend on the program / internet site that is active, and there are quite a lot of different situations to handle.

Which method is better (in respect to minimizing system load):

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



or

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus



or should I better first use wingettitle to read the title of the active window into a variable and compare the contents of the variable to the different window names that I want to handle?
User avatar
Spawnova
Posts: 339
Joined: 08 Jul 2015, 00:12
Contact:

Re: Better use ifwinactive or #ifwinactive

21 Jan 2018, 16:00

I'd probably use wingettitle

here's an example code that you may find usefull

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

braunbaer
Posts: 11
Joined: 22 Feb 2016, 10:49

Re: Better use ifwinactive or #ifwinactive

21 Jan 2018, 16:52

This would be nice, but it is not possible this way, because depending on the program / site, the actions are somewhat different, so it is not possible to do the task in such a loop.
Sometimes the login button has to be clicked, in other login screens the enter key works, in one case the script has to wait before clicking on the login button until I have solved a captcha (in this case, the script checks the colour of a specific screen pixel that changes its colour when the captcha is correctly solved), in some other programs the script has to do different things after the login. I even have one internet site where the position of the input field is not always the same, so the script first has to find out where the input field is before clicking there.

Currently I have a big script that is loaded when the computer starts and automates many different tasks with a lot of different hotkeys.
For all kinds of login screens, I currently use #ifwinactive ... and #p:: , but I am reorganising the sript and adding several other logins, and I am asking myself if many #ifwinactive directives might degrade the performance of the system.
Last edited by braunbaer on 21 Jan 2018, 17:16, edited 1 time in total.
User avatar
Spawnova
Posts: 339
Joined: 08 Jul 2015, 00:12
Contact:

Re: Better use ifwinactive or #ifwinactive

21 Jan 2018, 17:01

Ah, I see, that is indeed a lot of variables to consider.

In that case, personally I would still use WinGetTitle and just have a lot of if/else statements, possibly making a few functions to wrap common actions.

There may be a more efficient way, but I can't think of anything atm.
User avatar
divanebaba
Posts: 712
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Better use ifwinactive or #ifwinactive

21 Jan 2018, 17:21

Don't you have to close the directive? Or is it not necessary? Like below?

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus


[Starklichtbirne IQ >> 250!!] Dank deutscher Lehrerempfehlung, nur Süperdepp und Hartz4-Bezieher, statt Abitürient und Einkommensbezieher.
[Strong light bulb IQ >> 250!!] Thanks to german teacher's recommendation, willful and welfare recipient, instead of high school graduate and moneymaker.

Entering high school for foreign children is not prohibited in GERMANY, it's only made nearly impossible by government.
Virtually the only way - visiting high school abroad.

ADVERTISING: Patent pending strip accumulator - advanced technology - priceless inexpensive, space-saving, energy efficient - Patent priority for sale.
braunbaer
Posts: 11
Joined: 22 Feb 2016, 10:49

Re: Better use ifwinactive or #ifwinactive

21 Jan 2018, 17:35

No. Any #ifwinactive automatically overrides the previous #ifwinactive directive.

@Spawnova
I am afraid you are right. That is going to be a lot of typing :evil: but it probably is the best solution.

Return to “Ask For Help”

Who is online

Users browsing this forum: Doc16743, Vh_ and 62 guests