PLEASE HELP! Spawn new process/gui from same button

Get help with using AutoHotkey and its commands and hotkeys
User avatar
coder_chick
Posts: 225
Joined: 05 Nov 2015, 10:43

PLEASE HELP! Spawn new process/gui from same button

10 Sep 2019, 13:47

I have the following code. I need help with the following. Can you help fix my code to make this work?

1) When you get to the second gui, the user can select which partition letter they want to perform a directory listing of. When they push the button, it generates a directory listing log for that partition and of only the files containing the extensions. I want the user to be able to select one partition, push the button to create the listing, and then select another partition, and click the button again to generate a listing of that partition (spawning another gui with the progress). For this to happen, I don't think I can have gui3 and need it to be dynamic in some way where it spawns a new gui. How do I do that and how to I replace the various gui3 references in the current code to make those other features of the script work. It seems to work if I go from one selected drop down partition letter to the next, but if I go from one to the next and then retry another one that was previous run, it doesn't work.

Also, the FileAppend,[Directory Listing Exited Before Finishing!!]`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt doesn't work on additional spawned guis.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

AppName = ABCD_Script v1.0
;output directory for all logs will always be in a folder within the script's directory

;;;;;;;;;;;;;;;;;;MUST RUN AS ADMIN
if not A_IsAdmin = 1
{
   Msgbox You must run with admin rights
   ExitApp
}
else
{
;;;;;;;;;;;;;;;;;;;;;;Pull info from INI file
IfExist, extensions_config.ini
{
FileRead,config_extensions, extensions_config.ini
;msgbox,%config_extensions%
;;;;;;;;;;;;;;;;;;;;;;
}
}
;;;;;;;;;;;;;;;;;;END-------MUST RUN AS ADMIN

SECTION1:
Start_Time_Local = %A_Now%
Start_Time_UTC = %A_NowUTC%
pull_make_model_SN() ;pulls the info and stores it in the variables
checkavailabledriveletters() ; pull list of partition letters
Gui, 1:Add, Text, x12 y29 w170 h30 , ABCD_Tech (Last_First):
Gui, 1:Add, Edit, x192 y29 w320 h20 vtech,TECH_BOB
Gui, 1:Add, Text, x12 y79 w170 h30 , Custodian Name (Last_First):
Gui, 1:Add, Edit, x192 y79 w320 h20 vcustodian,Doe_John
Gui, 1:Add, Text, x12 y119 w170 h30 , Make:
Gui, 1:Add, Text, x12 y159 w170 h30 , Model:
Gui, 1:Add, Text, x12 y199 w170 h30 , Serial Number:
Gui, 1:Add, Edit, x192 y119 w320 h20 vMake, %Make%
Gui, 1:Add, Edit, x192 y159 w320 h20 vModel, %Model%
Gui, 1:Add, Edit, x192 y199 w320 h20 vSN, %SN%
Gui, 1:Add, Button, x412 y229 w100 h30 gGo, Next
; Generated using SmartGUI Creator 4.0
Gui, 1:Show, x127 y72 h280 w533,%AppName%
Return

1GuiClose:
ExitApp

Go:
Gui, 1: Submit,nohide  ; Save the input from the user to each control's associated variable.

emptyfields := [custodian,make,model,sn,tech]
for i,a in emptyfields
{
    If !a
    {
		MsgBox, 48, Warning, All fields are required! ;show error message
        return
    }
}

Gui,1:Destroy

;=========================OUTPUTS AND FILES===================================
OutputFolder = %Custodian%-%Make%(%SN%)-%Start_Time_Local%
ProcessLog = %Custodian%-%Make%(%SN%)-%Start_Time_Local%_ProcessLog
FileListing = %Custodian%-%Make%(%SN%)-%Start_Time_Local%_FileListing
FileCreateDir,%OutputFolder%
FileCreateDir,%OutputFolder%\Screenshots
ScreenshotFolder = %OutputFolder%\Screenshots
gui_number = 3
;=============================================================================



FileAppend,%AppName%`n`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Time (Local): %Start_Time_Local%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Time (UTC): %Start_Time_UTC%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,=====================================================`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,ABCD_Tech: %tech%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Custodian: %custodian%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,=====================================================`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,WORKSTATION_INFO:`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Make: %Make%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Model: %Model%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,SN: %SN%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Computer Name: %A_ComputerName%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Current Logged In User: %A_UserName%`n,%OutputFolder%\%ProcessLog%.txt
RegRead, OSName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName
RegRead, BuildNum, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, CurrentBuild
FileAppend,OSName (Registry): %OSName%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,BuildNum: %BuildNum%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,Operating System Build (AHK): %A_OSVersion%`n,%OutputFolder%\%ProcessLog%.txt
FileAppend,=====================================================`n,%OutputFolder%\%ProcessLog%.txt

Gui, 2:Add, Text, x12 y9 w90 h20 , Source Partition:
Gui, 2:Add, DropDownList, x102 y9 w80 h500 vPartitionLetter, %list%
Gui, 2:Add, Button, x192 y9 w190 h20 gDiskManagement, Open Disk Management
Gui, 2:Add, Text, x12 y49 w190 h20 ,File Extensions To Log (one per line)
Gui, 2:Add, Edit, x12 y79 w380 h140 vextensions,%config_extensions%
Gui, 2:Add, Button, x12 y229 w120 h30 gListFiles, Create File Listing
Gui, 2:Add, Text, x422 y9 w110 h20 gIndexStatus, Check Indexing Status
Gui, 2:Add, Button, x532 y-1 w110 h30 gIndexStatus, Open
Gui, 2:Add, Text, x422 y39 w110 h20 , Screenshot (F11)
Gui, 2:Add, Button, x532 y29 w110 h30 gScreenshot , Screenshot
Gui, 2:Add, Text, x422 y69 w190 h20 , Log Comments:
Gui, 2:Add, Edit, x422 y89 w360 h130 vcomment ,nope
Gui, 2:Add, Button, x662 y219 w120 h30 gLogComment, Add Comment
; Generated using SmartGUI Creator 4.0
Gui, 2:Show, x477 y581 h289 w807,%AppName%
Return

2GuiClose:
ExitApp

DiskManagement:
Run, DiskMgmt.msc
return

Screenshot:
screenshot_timestamp = %A_Now%
Run,"nircmd.exe" savescreenshot "%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
sleep,1000
run,"%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
return

F11::
IfExist,%ScreenshotFolder%
{
	screenshot_timestamp = %A_Now%
Run,"nircmd.exe" savescreenshot "%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
sleep,1000
run,"%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
}
return

LogComment:
Gui,2:Submit,nohide
FileAppend,COMMENT:%comment%`n,%OutputFolder%\%ProcessLog%.txt
Msgbox,Comment added to process log. You can add more.
GuiControl,2:,comment,
return


IndexStatus:
Run, control.exe srchadmin.dll
;Run, rundll32.exe shell32.dll,Control_RunDLL srchadmin.dll
;Run, control /name Microsoft.IndexingOptions
return

ListFiles:
Gui,2:Submit,nohide
DirectoryListingTime = %A_Now%

run,%OutputFolder%
emptyfields := [PartitionLetter]
for i,a in emptyfields
{
    If !a
    {
		MsgBox, 48,Warning,You must select a partition letter!  ;show error message
        return
    }
}

;;;;;;;;;;;;The following will parse the edit box of extensions and concatenate the extensions on each row with a comma
;msgbox,%extensions%
loop, parse,extensions, "`n"
{
	
	new_extensions .=  A_loopfield . ","
}
StringTrimRight, new_extensions, new_extensions, 1
;msgbox,%new_extensions%
;;;;;;;;;;;;;;;;;


FormatTime,TimeString,,yyyy-MM-dd hh:mm:ss tt
FileAppend,Filename|Extension|Size|Modified|Accessed|Created|FullPath`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt

Gui,3:Add, Text, x12 y9 w690 h30 +Center, Generating a listing of the provided extensions on the following partition: %PartitionLetter%:
Gui,3:Add, Text, x12 y79 w690 h130 vVar, %Var%
Gui,3:Add, Text, x12 y49 w690 h20 , Current Location Scanned:
Gui,3:Show, x127 y87 h229 w728,%AppName%

Loop, %PartitionLetter%:\*.* ,0,1 ;0 means only files are retrieved and 1 means subfolders are recursed.
{
GuiControl,3:,Var,%A_LoopFileFullPath%
if A_LoopFileExt in %new_extensions%
{
FileAppend,%A_LoopFileName%|%A_LoopFileExt%|%A_LoopFileSize%|%A_LoopFileTimeModified%|%A_LoopFileTimeAccessed%|%A_LoopFileTimeAccessed%|%A_LoopFileFullPath%`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt
}
}
FileAppend,[DIRECTORY LISTING FINISHED]`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt
Gui,3:Destroy
MsgBox, 262208, %AppName% - Directory Listing, Directory listing of the following partition is complete!`n`nPartition: %PartitionLetter%:
Return

3GuiClose:
FileAppend,[Directory Listing Exited Before Finishing!!]`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt
Gui,3: destroy
return

;========================METHODS================================================
checkavailabledriveletters()
{
global

List := ""
Alphabet = A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z  ; check all the possible drive letters
Loop, Parse, Alphabet, .
{

IfExist, %A_LoopField%:\
{
;msgbox, drive letter exists %A_LoopField%:\
List .= A_LoopField "|"
}
IfNotExist, %A_LoopField%:\
{
;msgbox, drive letter DOES NOT EXIST: %A_LoopField%:\
}
continue
}
}

pull_make_model_SN()
{
global

strComputer := "."
objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum

while colSettings[strCSItem]
{
		
	;WMI get info
            strComputer := "."
            objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
            colSettings := objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct")._NewEnum

            vList := "Vendor,Name,IdentifyingNumber"
			
		Loop, Parse, vList, % ","
			{
            source_flag = 0 ; set flag to 0 to start with before the check

            while colSettings[strCSItem]
            {
                Make := strCSItem.Vendor  ; create variable with one of the items from the list
				Model := strCSItem.Name  ; create variable with one of the items from the list
				SN := strCSItem.IdentifyingNumber  ; create variable with one of the items from the list
				
                ;~ msgbox, %Make%
                ;~ msgbox, %Model%
				;~ msgbox, %SN%
               
            }
			}
}	
objWMIService := colSettings := strCSItem := ""

}


♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
coder_chick
Posts: 225
Joined: 05 Nov 2015, 10:43

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 00:37

Please - can someone help me with this? Where are the AKH gods?!
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 00:51

You can use

Code: Select all

Gui, New
and reference the gui using the hwnd.
Please excuse my spelling I am dyslexic.
User avatar
coder_chick
Posts: 225
Joined: 05 Nov 2015, 10:43

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 00:53

I looked into this, but honestly, I'm at a loss as to how to implement it in my code. Can you modify my code and show me as an example? I'm a little out of my league. I assume basically all references to GUI 3 need to modified in some way. Thank you.
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 01:02

Are you just using gui 3 as a MsgBox ?

It looks like the only functionality of GUI 3 is that it has an on close label.

I can take a short look at getting it to work in an hour or so, I need to get out of bed first.
Please excuse my spelling I am dyslexic.
User avatar
coder_chick
Posts: 225
Joined: 05 Nov 2015, 10:43

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 01:11

Gui 3 is essentially a pop up that displays which partition it is generating a file listing of and it is updating to show the current file within the directory listing as it goes through. Example below.
2019-09-11_2-09-47.jpg
2019-09-11_2-09-47.jpg (12.46 KiB) Viewed 1692 times
So by selecting a partition drive letter, and pushing the button, it should spawn a new popup and listing each time.

Thanks for taking a look at it. I appreciate you getting out of bed! :-)
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 01:25

Ok then the only complicated thing you need is a guiclose function
https://www.autohotkey.com/docs/commands/Gui.htm#GuiClose
Please excuse my spelling I am dyslexic.
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 02:05

Well it is not perfect, I don't really know how you want it but this is what I had time to do today.

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

AppName = ABCD_Script v1.0
;output directory for all logs will always be in a folder within the script's directory

;;;;;;;;;;;;;;;;;;MUST RUN AS ADMIN
if(not A_IsAdmin = 1) {
   Msgbox You must run with admin rights
   ExitApp
} else {
	;;;;;;;;;;;;;;;;;;;;;;Pull info from INI file
	IfExist, extensions_config.ini
	{
		FileRead,config_extensions, extensions_config.ini
		;msgbox,%config_extensions%
		;;;;;;;;;;;;;;;;;;;;;;
	}
}
;;;;;;;;;;;;;;;;;;END-------MUST RUN AS ADMIN

SECTION1:
	Start_Time_Local = %A_Now%
	Start_Time_UTC = %A_NowUTC%
	pull_make_model_SN() ;pulls the info and stores it in the variables
	checkavailabledriveletters() ; pull list of partition letters
	Gui, 1:Add, Text, x12 y29 w170 h30 , ABCD_Tech (Last_First):
	Gui, 1:Add, Edit, x192 y29 w320 h20 vtech,TECH_BOB
	Gui, 1:Add, Text, x12 y79 w170 h30 , Custodian Name (Last_First):
	Gui, 1:Add, Edit, x192 y79 w320 h20 vcustodian,Doe_John
	Gui, 1:Add, Text, x12 y119 w170 h30 , Make:
	Gui, 1:Add, Text, x12 y159 w170 h30 , Model:
	Gui, 1:Add, Text, x12 y199 w170 h30 , Serial Number:
	Gui, 1:Add, Edit, x192 y119 w320 h20 vMake, %Make%
	Gui, 1:Add, Edit, x192 y159 w320 h20 vModel, %Model%
	Gui, 1:Add, Edit, x192 y199 w320 h20 vSN, %SN%
	Gui, 1:Add, Button, x412 y229 w100 h30 gGo, Next
	; Generated using SmartGUI Creator 4.0
	Gui, 1:Show, x127 y72 h280 w533,%AppName%
Return

1GuiClose:
	ExitApp

Go:
	Gui, 1: Submit,nohide  ; Save the input from the user to each control's associated variable.

	emptyfields := [custodian,make,model,sn,tech]
	for i,a in emptyfields {
		If(!a) {
			MsgBox, 48, Warning, All fields are required! ;show error message
			return
		}
	}

	Gui,1:Destroy

	;=========================OUTPUTS AND FILES===================================
	OutputFolder = %Custodian%-%Make%(%SN%)-%Start_Time_Local%
	ProcessLog = %Custodian%-%Make%(%SN%)-%Start_Time_Local%_ProcessLog
	FileListing = %Custodian%-%Make%(%SN%)-%Start_Time_Local%_FileListing
	FileCreateDir,%OutputFolder%
	FileCreateDir,%OutputFolder%\Screenshots
	ScreenshotFolder = %OutputFolder%\Screenshots
	gui_number = 3
	;=============================================================================



	FileAppend,%AppName%`n`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Time (Local): %Start_Time_Local%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Time (UTC): %Start_Time_UTC%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,=====================================================`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,ABCD_Tech: %tech%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Custodian: %custodian%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,=====================================================`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,WORKSTATION_INFO:`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Make: %Make%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Model: %Model%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,SN: %SN%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Computer Name: %A_ComputerName%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Current Logged In User: %A_UserName%`n,%OutputFolder%\%ProcessLog%.txt
	RegRead, OSName, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, ProductName
	RegRead, BuildNum, HKEY_LOCAL_MACHINE, SOFTWARE\Microsoft\Windows NT\CurrentVersion, CurrentBuild
	FileAppend,OSName (Registry): %OSName%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,BuildNum: %BuildNum%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,Operating System Build (AHK): %A_OSVersion%`n,%OutputFolder%\%ProcessLog%.txt
	FileAppend,=====================================================`n,%OutputFolder%\%ProcessLog%.txt

	Gui, 2:Add, Text, x12 y9 w90 h20 , Source Partition:
	Gui, 2:Add, DropDownList, x102 y9 w80 h500 vPartitionLetter, %list%
	Gui, 2:Add, Button, x192 y9 w190 h20 gDiskManagement, Open Disk Management
	Gui, 2:Add, Text, x12 y49 w190 h20 ,File Extensions To Log (one per line)
	Gui, 2:Add, Edit, x12 y79 w380 h140 vextensions,%config_extensions%
	Gui, 2:Add, Button, x12 y229 w120 h30 gListFiles, Create File Listing
	Gui, 2:Add, Text, x422 y9 w110 h20 gIndexStatus, Check Indexing Status
	Gui, 2:Add, Button, x532 y-1 w110 h30 gIndexStatus, Open
	Gui, 2:Add, Text, x422 y39 w110 h20 , Screenshot (F11)
	Gui, 2:Add, Button, x532 y29 w110 h30 gScreenshot , Screenshot
	Gui, 2:Add, Text, x422 y69 w190 h20 , Log Comments:
	Gui, 2:Add, Edit, x422 y89 w360 h130 vcomment ,nope
	Gui, 2:Add, Button, x662 y219 w120 h30 gLogComment, Add Comment
	; Generated using SmartGUI Creator 4.0
	Gui, 2:Show, x477 y581 h289 w807,%AppName%
Return

2GuiClose:
	ExitApp

DiskManagement:
	Run, DiskMgmt.msc
return

Screenshot:
	screenshot_timestamp = %A_Now%
	Run,"nircmd.exe" savescreenshot "%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
	sleep,1000
	run,"%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
return

F11::
	IfExist,%ScreenshotFolder%
	{
		screenshot_timestamp = %A_Now%
		Run,"nircmd.exe" savescreenshot "%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
		sleep,1000
		run,"%ScreenshotFolder%\screenshot(%screenshot_timestamp%).png"
	}
return

LogComment:
	Gui,2:Submit,nohide
	FileAppend,COMMENT:%comment%`n,%OutputFolder%\%ProcessLog%.txt
	Msgbox,Comment added to process log. You can add more.
	GuiControl,2:,comment,
return


IndexStatus:
	Run, control.exe srchadmin.dll
	;Run, rundll32.exe shell32.dll,Control_RunDLL srchadmin.dll
	;Run, control /name Microsoft.IndexingOptions
return

ListFiles:
	Gui,2:Submit,nohide
	DirectoryListingTime = %A_Now%

	run,%OutputFolder%
	emptyfields := [PartitionLetter]
	for i,a in emptyfields {
		If(!a) {
			MsgBox, 48,Warning,You must select a partition letter!  ;show error message
			return
		}
	}

	;;;;;;;;;;;;The following will parse the edit box of extensions and concatenate the extensions on each row with a comma
	;msgbox,%extensions%
	loop, parse,extensions, "`n"
	{
		new_extensions .=  A_loopfield . ","
	}
	StringTrimRight, new_extensions, new_extensions, 1
	;msgbox,%new_extensions%
	;;;;;;;;;;;;;;;;;


	FormatTime,TimeString,,yyyy-MM-dd hh:mm:ss tt
	FileAppend,Filename|Extension|Size|Modified|Accessed|Created|FullPath`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt
	
	Gui, New, +HwndMsgBoxGui
	Gui, % MsgBoxGui ":Add", Text, x12 y9 w690 h30 +Center, Generating a listing of the provided extensions on the following partition: %PartitionLetter%:
	Gui, % MsgBoxGui ":Add", Text, x12 y79 w690 h130 vVar, %Var%
	Gui, % MsgBoxGui ":Add", Text, x12 y49 w690 h20, Current Location Scanned:
	Gui, % MsgBoxGui ":Show", x127 y87 h229 w728, %AppName%

	Loop, %PartitionLetter%:\*.* ,0,1 ;0 means only files are retrieved and 1 means subfolders are recursed.
	{
		GuiControl, % MsgBoxGui ":", Var, %A_LoopFileFullPath%
		if A_LoopFileExt in %new_extensions%
		{
			FileAppend,%A_LoopFileName%|%A_LoopFileExt%|%A_LoopFileSize%|%A_LoopFileTimeModified%|%A_LoopFileTimeAccessed%|%A_LoopFileTimeAccessed%|%A_LoopFileFullPath%`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt
		}
	}
	FileAppend,[DIRECTORY LISTING FINISHED]`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt
	Gui, % MsgBoxGui ":Destroy"
	MsgBox, 262208, %AppName% - Directory Listing, Directory listing of the following partition is complete!`n`nPartition: %PartitionLetter%:
Return

GuiClose(GuiHwnd) {  ; Declaring this parameter is optional.
	global
	FileAppend,[Directory Listing Exited Before Finishing!!]`n,%OutputFolder%\%FileListing%(%PartitionLetter%_Partition)-%DirectoryListingTime%.txt
	Gui, % GuiHwnd ":Destroy"
}

;========================METHODS================================================
checkavailabledriveletters() {
	global

	List := ""
	Alphabet = A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.Y.Z  ; check all the possible drive letters
	Loop, Parse, Alphabet, .
	{

		IfExist, %A_LoopField%:\
		{
			;msgbox, drive letter exists %A_LoopField%:\
			List .= A_LoopField "|"
		}
		IfNotExist, %A_LoopField%:\
		{
			;msgbox, drive letter DOES NOT EXIST: %A_LoopField%:\
		}
		continue
	}
}

pull_make_model_SN() {
	global

	strComputer := "."
	objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
	colSettings := objWMIService.ExecQuery("Select * from Win32_DiskDrive")._NewEnum

	while colSettings[strCSItem] {

		;WMI get info
		strComputer := "."
		objWMIService := ComObjGet("winmgmts:{impersonationLevel=impersonate}!\\" strComputer "\root\cimv2")
		colSettings := objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct")._NewEnum

		vList := "Vendor,Name,IdentifyingNumber"

		Loop, Parse, vList, % ","
		{
		source_flag = 0 ; set flag to 0 to start with before the check

		while colSettings[strCSItem] {
			Make := strCSItem.Vendor  ; create variable with one of the items from the list
			Model := strCSItem.Name  ; create variable with one of the items from the list
			SN := strCSItem.IdentifyingNumber  ; create variable with one of the items from the list

			;~ msgbox, %Make%
			;~ msgbox, %Model%
			;~ msgbox, %SN%

			}
		}
	}
	objWMIService := colSettings := strCSItem := ""

}
Edit: I am not sure if you want to have them run in parallel, but regardless of that you have a problem with using global variables in the GuiClose function and possibly in the scan if you did want them to run at the same time.
Please excuse my spelling I am dyslexic.
User avatar
coder_chick
Posts: 225
Joined: 05 Nov 2015, 10:43

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 07:41

I want them to run in parallel - which doesn't work with my code or yours. We suck. Someone must know how to fix this?!

I appreciate you looking at it.
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 09:41

No it is a limitation of ahk, you could use timers but it would seem to me that you probably want to use ahk_h as it has threads.
Please excuse my spelling I am dyslexic.
User avatar
coder_chick
Posts: 225
Joined: 05 Nov 2015, 10:43

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 13:30

Is there a way for it to generate a temp ahk script for each instance of the directory listing and have a pop up asking the user to initiate the directory listing process?
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 15:25

Sure you can use the Run command to run a script
Please excuse my spelling I am dyslexic.
User avatar
coder_chick
Posts: 225
Joined: 05 Nov 2015, 10:43

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 17:03

But would the run command from within an ahk script work for an external ahk file if ahk is not installed?
♥ ❤ ❥ coder_chick ♥ ❤ ❥
User avatar
Capn Odin
Posts: 1308
Joined: 23 Feb 2016, 19:45
Location: Denmark

Re: PLEASE HELP! Spawn new process/gui from same button

11 Sep 2019, 17:30

It could be "compiled" as well.
Please excuse my spelling I am dyslexic.

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], braunbaer, TAC109 and 35 guests