Autohotkey own window Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
virooz
Posts: 4
Joined: 31 Aug 2018, 05:49

Autohotkey own window

31 Aug 2018, 06:14

Hi,

The simple script:

Code: Select all

if WinExist("ahk_exe mintty.exe")
    WinActivate, ahk_class mintty
else
    Run, C:\Distrib\git\git-bash.exe
I've made a hotkey in shortcut using Windows Start menu, now every time this script is running Autohotkey own window is activated for a moment and sometimes focus goes to Autohotkey Window AFTER mintty window was activated.
I don't know why, maybe it's OS GUI lag or messages queue lag, or maybe lag references to the hotkey i'm using (Ctrl+Shit+Alt+P), but i think if autohotkey own window will not show itself while executing scipt - the problem will go away.

Is it possible not to show Autohotkey own window?
YMP2
Posts: 47
Joined: 20 Apr 2014, 06:55

Re: Autohotkey own window

31 Aug 2018, 06:38

That's very odd. But what do you call "AutoHotkey own window"? Maybe it's the black window of Windows command line console?
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Autohotkey own window

31 Aug 2018, 09:57

If you are trying to perform operations on the GUI of the AHK script itself, then use:

Code: Select all

Gui, +HwndScriptGui ; Creates a variable "ScriptGUI" and places the ID (HWND) of the script's GUI in it

[...]

WinActivate, ahk_id %MyGui%
virooz
Posts: 4
Joined: 31 Aug 2018, 05:49

Re: Autohotkey own window

03 Sep 2018, 05:39

evilC wrote:If you are trying to perform operations on the GUI of the AHK script itself, then use:

Code: Select all

Gui, +HwndScriptGui ; Creates a variable "ScriptGUI" and places the ID (HWND) of the script's GUI in it

[...]

WinActivate, ahk_id %MyGui%
Yes you right. Partially. I want GUI of the AHK script itself not to appear at all!
I'm sure it should be the default behaviour, but GUI blinking every time i call the script (window shows itself for a moment and closes immediately).

Do i need to search AHK script GUI inside my script and hide it, before activating windows of another apps? Or maybe some command line key exists to NOT TO SHOW ahk script GUI while executing?
virooz
Posts: 4
Joined: 31 Aug 2018, 05:49

Re: Autohotkey own window

04 Sep 2018, 05:03

evilC wrote:AHK scripts never show a Gui unless you tell it to show using Gui, Show
OK, I'll show you to understand what i mean: https://youtu.be/hCKlo_jbhhU
Please, turn on the subtitles
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Autohotkey own window

04 Sep 2018, 05:56

You execute

Code: Select all

If WinExist("ahk_exe mintty.exe")
   WinActivate, ahk_class Mintty
The AHK script matches the IfWinExist
So it executes the WinActivate.
Image

So it's doing exactly what you asked it to?

It just seems wrong to say "IF window A exists, Activate Window B", without checking if Window B actually exists
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Autohotkey own window  Topic is solved

04 Sep 2018, 06:14

Also, the mind truly boggles as to why you are compiling the script and using a shortcut hotkey to launch an AHK script?
Why not just run the script uncompiled and put the hotkey in the script?

ie

Code: Select all

^!+p::	; Run this code when I hit CTRL+ALT+SHIFT+P
If WinExist("ahk_exe mintty.exe")
   WinActivate, ahk_class Mintty
 ; ...
virooz
Posts: 4
Joined: 31 Aug 2018, 05:49

Re: Autohotkey own window

04 Sep 2018, 09:20

> So it's doing exactly what you asked it to?
No. I confused you with naming compiled scripts as mintty.exe in my example video on youtube, actually i'am searching another application, named mintty.exe too

> Why not just run the script uncompiled and put the hotkey in the script?
Yes i'll try thank you this way...
User avatar
evilC
Posts: 4730
Joined: 27 Feb 2014, 12:30

Re: Autohotkey own window

04 Sep 2018, 09:36

Are the WinExist and WinActivate commands referring to the same window? If so, why did you change from ahk_exe to ahk_class ?
If you are trying to say "If this window exists, activate it", then use identical titles, or on the WinActivate, omit the title entirely to use the "Last Found" window (The one that just matched in the WinExist)

Return to “Ask For Help”

Who is online

Users browsing this forum: anaxio, Bad husband, Bing [Bot], eL Tux, ostius and 247 guests