gui that allows cmdline executions

Get help with using AutoHotkey and its commands and hotkeys
User avatar
BGM
Posts: 495
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

gui that allows cmdline executions

22 Oct 2020, 13:31

My app is a commandline application with a GUI for its settings.

If you run the program without parameters it opens the GUI.
But if you run it with parameters, it runs the script without any GUI.

I have the script set to look for commandline parameters and if there are none, it will launch the GUI, if not, it will run it's sequence and then exit.

Well, that's what is supposed to happen.

What happens is, if the GUI is open, the second instance kills the first one.
If I turn #SingleInstance to off, then it lets the user open multiple options GUIs which I don't want.

Here's what I want:
1. Be able to run the GUI instance and commandline instances at the same time.
2. Not be able to open two GUIs.
3. Have the commandline instances to not kill the GUI instance.

Maybe if there was a way to detect a previously running instance of the application?
User avatar
BGM
Posts: 495
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: gui that allows cmdline executions

22 Oct 2020, 13:51

Hmmm, I think I might have figured it out (always happens after I post).

I only need to kill the second instance of the gui.
If I do this, then it leaves any first instance alone, but if I call it with parameters, it allows the hidden instance to run.

Code: Select all

#singeinstance, off
if not %0%
{
	winget, windowcount,Count,%appname%
	if(windowcount > 1){
		exitapp
	}
	gosub, MAINWINDOW

}else{
	loop %0%
	givenpath := %a_index%
	{
		loop %givenpath%, 1
		{
			msgbox, %a_loopfilelongpath%
		}
	}
	exitapp	;end the program now
}
User avatar
mikeyww
Posts: 2052
Joined: 09 Sep 2014, 18:38

Re: gui that allows cmdline executions

22 Oct 2020, 16:58

I think that's the idea. I have some GUI setups where I give the GUI a particular name (window title) so that I can easily have a separate script identify it. That approach can be a helpful adjunct.
User avatar
BGM
Posts: 495
Joined: 20 Nov 2013, 20:56
GitHub: bgmCoder
Contact:

Re: gui that allows cmdline executions

29 Oct 2020, 09:53

Funny, this code works on my own computer, but doesn't work on others. I tried it on another computer and it keeps the gui from launching the first time, not the second.
User avatar
mikeyww
Posts: 2052
Joined: 09 Sep 2014, 18:38

Re: gui that allows cmdline executions

29 Oct 2020, 10:00

You can debug it by breaking it down into steps. Eliminate the initial directive. Have the script display the command line, so that you can verify it. Display the window count, so that you can verify that. Etc.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], FrancoisM, Google [Bot], hasantr, JoeWinograd, sadasada, stcy00, teeedubb and 67 guests