Is it possible to set a loop on each script on GUI? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 19 Jan 2022, 05:12

Hello guys,


Still noob here,
Need help for setting any amount of loop times on each script then add a button to run it on sequence. Here is my code:

Code: Select all

Gui, +AlwaysOnTop +Resize -MaximizeBox -MinimizeBox
Gui, Font, cRed
Gui, Add, Text, w130 h20 , ESC to STOP
Gui, Add, Text, w130 h20 , End to EXIT
Gui, Font, cBlue
Gui, Add, Text, w130 h20 , S+F1 for Mouse Coor.
Scripts := "DESCRIPTION, VALUE, EXPCOM, QTY"
ScriptsArray  := StrSplit(Scripts, ", ")
Loop, % 1*ScriptsArray.Count()
	Gui, Add, Button, xm y+1 w130 h35 gTestUniversal , % "Run " . ScriptsArray[Round(A_Index/1)] . ".AHK"
Gui, Add, Edit, w30 h20 vf1x,
Gui, Add, Edit, w30 h20 vf1y,
Gui, Font, s5
Gui, Show,, MULTIPLE ITEMS BREXIT
Return

+F1::
CoordMode, Mouse, Screen
MouseGetPos, xpos, ypos
GuiControl,, f1x, % f1x := xpos
GuiControl,, f1y, % f1y := ypos
Return

TestUniversal:
Run % "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS\" . StrReplace(A_GuiControl, "Run ") 
Return

#d::Run, C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS\DESCRIPTION.AHK
#v::Run, C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS\VALUE.AHK
#e::Run, C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS\EXPCOM.AHK
#q::Run, C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS\QTY.AHK

GuiClose:
End::
ExitApp
For example:
I want to loop the description for 6x(editable) then,
8x(editable) for value then,
5x(editable) for EXPCOM then
3x(editable) for QTY
Then add a button to run it on sequence.
Last edited by RESTRIVERA1 on 19 Jan 2022, 05:18, edited 1 time in total.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is it possible to set a loop on each script on GUI?

Post by BoBo » 19 Jan 2022, 05:18

Just out of curiosity, what kind of Brexit-hassle you've to deal with? :shh: :shifty: :wtf: :mrgreen:

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 19 Jan 2022, 05:21

BoBo wrote:
19 Jan 2022, 05:18
Just out of curiosity, what kind of Brexit-hassle you've to deal with? :shh: :shifty: :wtf: :mrgreen:
Well, I 'm assigned at customs, we're checking the validity of the item such as goods description, weight, commodity codes, and etc. including proper amount of taxes on each parcels.

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is it possible to set a loop on each script on GUI?

Post by BoBo » 19 Jan 2022, 08:53

Do you wanna export the editable part (the number of iterations for the loops) into an INI-file or want to select it using the GUI with a default setting in place?

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is it possible to set a loop on each script on GUI?  Topic is solved

Post by BoBo » 19 Jan 2022, 14:18

Code: Select all

#SingleInstance, Force
scriptPath := "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS"

/*					; INI content embedded within the script for testing
[DESCRIPTION]
	max=	6
	default=6
[VALUE]
	max=	10
	default=8
[EXPCOM]
	max=	5
	default=3
[QUANTITY]
	max=	7
	default=5
*/

Gui, -Caption +Border														; styling
Gui, Add, Text, x10  y18	,Description
Gui, Add, DDL, xp+68 yp	w42 vDescription, 0|								; added '0' just in case a specific item shouldn't been processed
Gui, Add, Text,xp-68 yp+22	,Value
Gui, Add, DDL, xp+68 yp	w42	vValue		, 0|
Gui, Add, Text,xp-68 yp+22	,ExpCom
Gui, Add, DDL, xp+68 yp	w42	vExpCom		, 0| 
Gui, Add, Text,xp-68 yp+22	,Quantity
Gui, Add, DDL, xp+68 yp w42	vQuantity	, 0|

IniRead, SectionNames, % A_ScriptName										; extract section names from "script INI" above (instead of external INI file)
section := StrSplit(SectionNames,"`n")										; transfer section names into an array
Loop % section.count()														; create DDLs based on INI section settings
	{	INIRead, d,% A_ScriptName,% section[A_Index], default				; get default item position within that specific DDL
		INIRead, i,% A_ScriptName,% section[A_Index], max					; get maximum number of items within that specific DDL
		DDL := section[A_Index]
		Loop % i															
			items .= A_Index "|"
		GuiControl,,% DDL,% (d = i) ? StrReplace(items, d, d "|") : RTrim(StrReplace(items, d, d "|"),"|")	; set created DDL content
		items := ""
	}

Gui, Add, Button, w42 gRun, Run
Gui, Show, w136 h148
Return

Run:
	Gui, Submit, NoHide
	Loop % Description
		MsgBox % scriptPath . "\description.ahk"
	Loop % Value
		MsgBox % scriptPath . "\value.ahk" ; replace 'MsgBox' with 'Run(Wait)'
	Loop % ExpCom
		MsgBox % scriptPath . "\expcom.ahk"
	Loop % Quantity
		MsgBox % scriptPath . "\quantity.ahk"
	Return

Esc::ExitApp ; as there's no button to close the GUI press ESC to kill it

Code is licensed under "BREXIT SUCKS"-license. Kindly scripted in the EU (that evil place across the channel) :mrgreen:

PS. you won't have to run AHK-scripts separately, simply use AHK's #Include to embed external modulized scripts ;)

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 20 Jan 2022, 10:03

BoBo wrote:
19 Jan 2022, 14:18

Code: Select all

#SingleInstance, Force
scriptPath := "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS"

/*					; INI content embedded within the script for testing
[DESCRIPTION]
	max=	6
	default=6
[VALUE]
	max=	10
	default=8
[EXPCOM]
	max=	5
	default=3
[QUANTITY]
	max=	7
	default=5
*/

Gui, -Caption +Border														; styling
Gui, Add, Text, x10  y18	,Description
Gui, Add, DDL, xp+68 yp	w42 vDescription, 0|								; added '0' just in case a specific item shouldn't been processed
Gui, Add, Text,xp-68 yp+22	,Value
Gui, Add, DDL, xp+68 yp	w42	vValue		, 0|
Gui, Add, Text,xp-68 yp+22	,ExpCom
Gui, Add, DDL, xp+68 yp	w42	vExpCom		, 0| 
Gui, Add, Text,xp-68 yp+22	,Quantity
Gui, Add, DDL, xp+68 yp w42	vQuantity	, 0|

IniRead, SectionNames, % A_ScriptName										; extract section names from "script INI" above (instead of external INI file)
section := StrSplit(SectionNames,"`n")										; transfer section names into an array
Loop % section.count()														; create DDLs based on INI section settings
	{	INIRead, d,% A_ScriptName,% section[A_Index], default				; get default item position within that specific DDL
		INIRead, i,% A_ScriptName,% section[A_Index], max					; get maximum number of items within that specific DDL
		DDL := section[A_Index]
		Loop % i															
			items .= A_Index "|"
		GuiControl,,% DDL,% (d = i) ? StrReplace(items, d, d "|") : RTrim(StrReplace(items, d, d "|"),"|")	; set created DDL content
		items := ""
	}

Gui, Add, Button, w42 gRun, Run
Gui, Show, w136 h148
Return

Run:
	Gui, Submit, NoHide
	Loop % Description
		MsgBox % scriptPath . "\description.ahk"
	Loop % Value
		MsgBox % scriptPath . "\value.ahk" ; replace 'MsgBox' with 'Run(Wait)'
	Loop % ExpCom
		MsgBox % scriptPath . "\expcom.ahk"
	Loop % Quantity
		MsgBox % scriptPath . "\quantity.ahk"
	Return

Esc::ExitApp ; as there's no button to close the GUI press ESC to kill it

Code is licensed under "BREXIT SUCKS"-license. Kindly scripted in the EU (that evil place across the channel) :mrgreen:

PS. you won't have to run AHK-scripts separately, simply use AHK's #Include to embed external modulized scripts ;)
Woah, This is just what I wanted! :superhappy: but I have few things to request, if you don't mind.... Actually I really don't get what you said earlier even the "INI" (yeah, I know I'm that kind of a dumb. haha).. When I open your script the only option I get from each script is "Zero".. Is there anything I need to change inside the script?

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 20 Jan 2022, 10:07

I forgot to tell you something, as you can see on my script, the way I repeat my script is by using a hotkey or by a GUI button only, that's why I'm trying to improve it by putting a number of loops on each scripts....

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 20 Jan 2022, 10:22

BoBo wrote:
19 Jan 2022, 14:18

Code: Select all

#SingleInstance, Force
scriptPath := "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS"

/*					; INI content embedded within the script for testing
[DESCRIPTION]
	max=	6
	default=6
[VALUE]
	max=	10
	default=8
[EXPCOM]
	max=	5
	default=3
[QUANTITY]
	max=	7
	default=5
*/

Gui, -Caption +Border														; styling
Gui, Add, Text, x10  y18	,Description
Gui, Add, DDL, xp+68 yp	w42 vDescription, 0|								; added '0' just in case a specific item shouldn't been processed
Gui, Add, Text,xp-68 yp+22	,Value
Gui, Add, DDL, xp+68 yp	w42	vValue		, 0|
Gui, Add, Text,xp-68 yp+22	,ExpCom
Gui, Add, DDL, xp+68 yp	w42	vExpCom		, 0| 
Gui, Add, Text,xp-68 yp+22	,Quantity
Gui, Add, DDL, xp+68 yp w42	vQuantity	, 0|

IniRead, SectionNames, % A_ScriptName										; extract section names from "script INI" above (instead of external INI file)
section := StrSplit(SectionNames,"`n")										; transfer section names into an array
Loop % section.count()														; create DDLs based on INI section settings
	{	INIRead, d,% A_ScriptName,% section[A_Index], default				; get default item position within that specific DDL
		INIRead, i,% A_ScriptName,% section[A_Index], max					; get maximum number of items within that specific DDL
		DDL := section[A_Index]
		Loop % i															
			items .= A_Index "|"
		GuiControl,,% DDL,% (d = i) ? StrReplace(items, d, d "|") : RTrim(StrReplace(items, d, d "|"),"|")	; set created DDL content
		items := ""
	}

Gui, Add, Button, w42 gRun, Run
Gui, Show, w136 h148
Return

Run:
	Gui, Submit, NoHide
	Loop % Description
		MsgBox % scriptPath . "\description.ahk"
	Loop % Value
		MsgBox % scriptPath . "\value.ahk" ; replace 'MsgBox' with 'Run(Wait)'
	Loop % ExpCom
		MsgBox % scriptPath . "\expcom.ahk"
	Loop % Quantity
		MsgBox % scriptPath . "\quantity.ahk"
	Return

Esc::ExitApp ; as there's no button to close the GUI press ESC to kill it

Code is licensed under "BREXIT SUCKS"-license. Kindly scripted in the EU (that evil place across the channel) :mrgreen:

PS. you won't have to run AHK-scripts separately, simply use AHK's #Include to embed external modulized scripts ;)
Woot Woot! This is just what I wanted! Thank you so much! Thanks for the effort!!! I really appreciate it! :superhappy: :bravo: :o :clap: :dance:

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 20 Jan 2022, 10:39

BoBo wrote:
19 Jan 2022, 14:18

Code: Select all

#SingleInstance, Force
scriptPath := "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS"

/*					; INI content embedded within the script for testing
[DESCRIPTION]
	max=	6
	default=6
[VALUE]
	max=	10
	default=8
[EXPCOM]
	max=	5
	default=3
[QUANTITY]
	max=	7
	default=5
*/

Gui, -Caption +Border														; styling
Gui, Add, Text, x10  y18	,Description
Gui, Add, DDL, xp+68 yp	w42 vDescription, 0|								; added '0' just in case a specific item shouldn't been processed
Gui, Add, Text,xp-68 yp+22	,Value
Gui, Add, DDL, xp+68 yp	w42	vValue		, 0|
Gui, Add, Text,xp-68 yp+22	,ExpCom
Gui, Add, DDL, xp+68 yp	w42	vExpCom		, 0| 
Gui, Add, Text,xp-68 yp+22	,Quantity
Gui, Add, DDL, xp+68 yp w42	vQuantity	, 0|

IniRead, SectionNames, % A_ScriptName										; extract section names from "script INI" above (instead of external INI file)
section := StrSplit(SectionNames,"`n")										; transfer section names into an array
Loop % section.count()														; create DDLs based on INI section settings
	{	INIRead, d,% A_ScriptName,% section[A_Index], default				; get default item position within that specific DDL
		INIRead, i,% A_ScriptName,% section[A_Index], max					; get maximum number of items within that specific DDL
		DDL := section[A_Index]
		Loop % i															
			items .= A_Index "|"
		GuiControl,,% DDL,% (d = i) ? StrReplace(items, d, d "|") : RTrim(StrReplace(items, d, d "|"),"|")	; set created DDL content
		items := ""
	}

Gui, Add, Button, w42 gRun, Run
Gui, Show, w136 h148
Return

Run:
	Gui, Submit, NoHide
	Loop % Description
		MsgBox % scriptPath . "\description.ahk"
	Loop % Value
		MsgBox % scriptPath . "\value.ahk" ; replace 'MsgBox' with 'Run(Wait)'
	Loop % ExpCom
		MsgBox % scriptPath . "\expcom.ahk"
	Loop % Quantity
		MsgBox % scriptPath . "\quantity.ahk"
	Return

Esc::ExitApp ; as there's no button to close the GUI press ESC to kill it

Code is licensed under "BREXIT SUCKS"-license. Kindly scripted in the EU (that evil place across the channel) :mrgreen:

PS. you won't have to run AHK-scripts separately, simply use AHK's #Include to embed external modulized scripts ;)
if ever I add some few items(scripts), how can I put it here without appearing on a GUI? more likely a passive one, that has a default loop of 1, positioning between on existing script. (Description > NEW SCRIPT(PASSIVE) > VALUE > (NEW SCRIPT(PASSIVE) and so on..

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 20 Jan 2022, 10:40

RESTRIVERA1 wrote:
20 Jan 2022, 10:03
BoBo wrote:
19 Jan 2022, 14:18

Code: Select all

#SingleInstance, Force
scriptPath := "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS"

/*					; INI content embedded within the script for testing
[DESCRIPTION]
	max=	6
	default=6
[VALUE]
	max=	10
	default=8
[EXPCOM]
	max=	5
	default=3
[QUANTITY]
	max=	7
	default=5
*/

Gui, -Caption +Border														; styling
Gui, Add, Text, x10  y18	,Description
Gui, Add, DDL, xp+68 yp	w42 vDescription, 0|								; added '0' just in case a specific item shouldn't been processed
Gui, Add, Text,xp-68 yp+22	,Value
Gui, Add, DDL, xp+68 yp	w42	vValue		, 0|
Gui, Add, Text,xp-68 yp+22	,ExpCom
Gui, Add, DDL, xp+68 yp	w42	vExpCom		, 0| 
Gui, Add, Text,xp-68 yp+22	,Quantity
Gui, Add, DDL, xp+68 yp w42	vQuantity	, 0|

IniRead, SectionNames, % A_ScriptName										; extract section names from "script INI" above (instead of external INI file)
section := StrSplit(SectionNames,"`n")										; transfer section names into an array
Loop % section.count()														; create DDLs based on INI section settings
	{	INIRead, d,% A_ScriptName,% section[A_Index], default				; get default item position within that specific DDL
		INIRead, i,% A_ScriptName,% section[A_Index], max					; get maximum number of items within that specific DDL
		DDL := section[A_Index]
		Loop % i															
			items .= A_Index "|"
		GuiControl,,% DDL,% (d = i) ? StrReplace(items, d, d "|") : RTrim(StrReplace(items, d, d "|"),"|")	; set created DDL content
		items := ""
	}

Gui, Add, Button, w42 gRun, Run
Gui, Show, w136 h148
Return

Run:
	Gui, Submit, NoHide
	Loop % Description
		MsgBox % scriptPath . "\description.ahk"
	Loop % Value
		MsgBox % scriptPath . "\value.ahk" ; replace 'MsgBox' with 'Run(Wait)'
	Loop % ExpCom
		MsgBox % scriptPath . "\expcom.ahk"
	Loop % Quantity
		MsgBox % scriptPath . "\quantity.ahk"
	Return

Esc::ExitApp ; as there's no button to close the GUI press ESC to kill it

Code is licensed under "BREXIT SUCKS"-license. Kindly scripted in the EU (that evil place across the channel) :mrgreen:

PS. you won't have to run AHK-scripts separately, simply use AHK's #Include to embed external modulized scripts ;)
Woah, This is just what I wanted! :superhappy: but I have few things to request, if you don't mind.... Actually I really don't get what you said earlier even the "INI" (yeah, I know I'm that kind of a dumb. haha).. When I open your script the only option I get from each script is "Zero".. Is there anything I need to change inside the script?
Please disregard this.. hehe

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is it possible to set a loop on each script on GUI?

Post by BoBo » 20 Jan 2022, 12:48

if ever I add some few items(scripts), how can I put it here without appearing on a GUI? more likely a passive one, that has a default loop of 1, positioning between on existing script. (Description > NEW SCRIPT(PASSIVE) > VALUE > (NEW SCRIPT(PASSIVE) and so on.
Simply add such a 'Loop' with its static value to the "Run" section, without any assigned GUI setting ...

Code: Select all

Run:
	Gui, Submit, NoHide
	Loop % Description
		RunWait % scriptPath . "\description.ahk"
;	Loop 1 ; not necessarry bc you can run it directly
	RunWait % scriptPath . "passive1.ahk"	
	Loop % Value
		RunWait % scriptPath . "\value.ahk"
	Loop 2 ; two fixed/static iterations
		RunWait % scriptpath . "\passive2.ahk"
	Loop % ExpCom
		RunWait % scriptPath . "\expcom.ahk"
	Loop % Quantity
		MsgBox % scriptPath . "\quantity.ahk"
	Return

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 21 Jan 2022, 01:46

BoBo wrote:
20 Jan 2022, 12:48
if ever I add some few items(scripts), how can I put it here without appearing on a GUI? more likely a passive one, that has a default loop of 1, positioning between on existing script. (Description > NEW SCRIPT(PASSIVE) > VALUE > (NEW SCRIPT(PASSIVE) and so on.
Simply add such a 'Loop' with its static value to the "Run" section, without any assigned GUI setting ...

Code: Select all

Run:
	Gui, Submit, NoHide
	Loop % Description
		RunWait % scriptPath . "\description.ahk"
;	Loop 1 ; not necessarry bc you can run it directly
	RunWait % scriptPath . "passive1.ahk"	
	Loop % Value
		RunWait % scriptPath . "\value.ahk"
	Loop 2 ; two fixed/static iterations
		RunWait % scriptpath . "\passive2.ahk"
	Loop % ExpCom
		RunWait % scriptPath . "\expcom.ahk"
	Loop % Quantity
		MsgBox % scriptPath . "\quantity.ahk"
	Return
ow... I see.. :facepalm: Just a common sense... hahaha anyway. Thanks a lot!!

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is it possible to set a loop on each script on GUI?

Post by BoBo » 21 Jan 2022, 02:44

@RESTRIVERA1

Code: Select all

#SingleInstance, Force
scriptPath := "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS"

If !FileExist(scriptPath . "\Brexit.ini")
FileAppend,			; create 'Brexit.ini' if missing with all sections (even for "passive" entries)
(

[PASSIVES]
	p1NoLoops=		1
	p1FileName=	passive1.ahk
	p2NoLoops=		1
	p2FileName=	passive2.ahk

[DESCRIPTION]
	max=	6
	default=6

[VALUE]
	max=	10
	default=8

[EXPCOM]
	max=	5
	default=3

[QUANTITY]
	max=	7
	default=5

),% scriptPath . "\Brexit.ini"

Gui, -Caption +Border														; styling
Gui, Add, Text, x10  y18	,Description
Gui, Add, DDL, xp+68 yp	w42 vDescription, 0|								; added '0' just in case a specific item shouldn't been processed
Gui, Add, Text,xp-68 yp+22	,Value
Gui, Add, DDL, xp+68 yp	w42	vValue		, 0|
Gui, Add, Text,xp-68 yp+22	,ExpCom
Gui, Add, DDL, xp+68 yp	w42	vExpCom		, 0| 
Gui, Add, Text,xp-68 yp+22	,Quantity
Gui, Add, DDL, xp+68 yp w42	vQuantity	, 0|

IniRead, SectionNames,% scriptPath . "\Brexit.ini"							; extract section names
section := StrSplit(SectionNames,"`n")										; transfer section names into an array
Loop % section.count()														; create DDL content based on its INI section settings
	{	INIRead, d,% scriptPath . "\Brexit.ini",% section[A_Index], default	; set default item within DDL content
		INIRead, i,% scriptPath . "\Brexit.ini",% section[A_Index], max		; maximum number of items in DDL content
		DDL := section[A_Index]
		Loop % i															
			items .= A_Index "|"
		GuiControl,,% DDL,% (d = i) ? StrReplace(items, d, d "|") : RTrim(StrReplace(items, d, d "|"),"|")	; set created DDL using GuiControl
		items := ""
	}

Gui, Add, Button, w42 vOK gRun, Run
Gui, Show, w136 h148
Return


Run:
	Gui, Submit, NoHide
	INIRead, p1No,% scriptPath . "\Brexit.ini", PASSIVES, p1NoLoops
	INIRead, p2No,% scriptPath . "\Brexit.ini", PASSIVES, p2NoLoops
	INIRead, p1Fn,% scriptPath . "\Brexit.ini", PASSIVES, p1FileName
	INIRead, p2Fn,% scriptPath . "\Brexit.ini", PASSIVES, p2FileName
	
	Loop % Description
		RunWait % scriptPath . "\description.ahk"
	Loop % p1No
		RunWait % scriptPath . "\" . p1Fn	
	Loop % Value
		RunWait % scriptPath . "\value.ahk"
	Loop % p2No
		RunWait % scriptpath . "\" . p2Fn
	Loop % ExpCom
		RunWait % scriptPath . "\expcom.ahk"
	Loop % Quantity
		RunWait % scriptPath . "\quantity.ahk"
	Return

Esc::ExitApp
This should do the trick for executing passively handled processings while making its configuration editable (now using/creating an external INI-file). HTH

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 28 Jan 2022, 00:39

BoBo wrote:
21 Jan 2022, 02:44
@RESTRIVERA1

Code: Select all

#SingleInstance, Force
scriptPath := "C:\Users\DepEd\OneDrive\Desktop\BREXIT SCRIPTS"

If !FileExist(scriptPath . "\Brexit.ini")
FileAppend,			; create 'Brexit.ini' if missing with all sections (even for "passive" entries)
(

[PASSIVES]
	p1NoLoops=		1
	p1FileName=	passive1.ahk
	p2NoLoops=		1
	p2FileName=	passive2.ahk

[DESCRIPTION]
	max=	6
	default=6

[VALUE]
	max=	10
	default=8

[EXPCOM]
	max=	5
	default=3

[QUANTITY]
	max=	7
	default=5

),% scriptPath . "\Brexit.ini"

Gui, -Caption +Border														; styling
Gui, Add, Text, x10  y18	,Description
Gui, Add, DDL, xp+68 yp	w42 vDescription, 0|								; added '0' just in case a specific item shouldn't been processed
Gui, Add, Text,xp-68 yp+22	,Value
Gui, Add, DDL, xp+68 yp	w42	vValue		, 0|
Gui, Add, Text,xp-68 yp+22	,ExpCom
Gui, Add, DDL, xp+68 yp	w42	vExpCom		, 0| 
Gui, Add, Text,xp-68 yp+22	,Quantity
Gui, Add, DDL, xp+68 yp w42	vQuantity	, 0|

IniRead, SectionNames,% scriptPath . "\Brexit.ini"							; extract section names
section := StrSplit(SectionNames,"`n")										; transfer section names into an array
Loop % section.count()														; create DDL content based on its INI section settings
	{	INIRead, d,% scriptPath . "\Brexit.ini",% section[A_Index], default	; set default item within DDL content
		INIRead, i,% scriptPath . "\Brexit.ini",% section[A_Index], max		; maximum number of items in DDL content
		DDL := section[A_Index]
		Loop % i															
			items .= A_Index "|"
		GuiControl,,% DDL,% (d = i) ? StrReplace(items, d, d "|") : RTrim(StrReplace(items, d, d "|"),"|")	; set created DDL using GuiControl
		items := ""
	}

Gui, Add, Button, w42 vOK gRun, Run
Gui, Show, w136 h148
Return


Run:
	Gui, Submit, NoHide
	INIRead, p1No,% scriptPath . "\Brexit.ini", PASSIVES, p1NoLoops
	INIRead, p2No,% scriptPath . "\Brexit.ini", PASSIVES, p2NoLoops
	INIRead, p1Fn,% scriptPath . "\Brexit.ini", PASSIVES, p1FileName
	INIRead, p2Fn,% scriptPath . "\Brexit.ini", PASSIVES, p2FileName
	
	Loop % Description
		RunWait % scriptPath . "\description.ahk"
	Loop % p1No
		RunWait % scriptPath . "\" . p1Fn	
	Loop % Value
		RunWait % scriptPath . "\value.ahk"
	Loop % p2No
		RunWait % scriptpath . "\" . p2Fn
	Loop % ExpCom
		RunWait % scriptPath . "\expcom.ahk"
	Loop % Quantity
		RunWait % scriptPath . "\quantity.ahk"
	Return

Esc::ExitApp
This should do the trick for executing passively handled processings while making its configuration editable (now using/creating an external INI-file). HTH
Hey, sorry for late reply, this is really awesome, you really help me a lot!.. Thank you very much! :bravo:

User avatar
Xeo786
Posts: 759
Joined: 09 Nov 2015, 02:43
Location: Karachi, Pakistan

Re: Is it possible to set a loop on each script on GUI?

Post by Xeo786 » 28 Jan 2022, 01:25

RESTRIVERA1 wrote:
19 Jan 2022, 05:21
Well, I 'm assigned at customs, we're checking the validity of the item such as goods description, weight, commodity codes, and etc. including proper amount of taxes on each parcels.
I got few questions too :D

is GSP form A regularized? or are you still receiving Form A draft Copy signed by export (not by origin authorities)?
is REX Statement of Origin still valid?

Thank you,
"When there is no gravity, there is absolute vacuum and light travel with no time" -Game changer theory

BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Is it possible to set a loop on each script on GUI?

Post by BoBo » 28 Jan 2022, 01:35

@RESTRIVERA1 - if you‘re interested we could review the scripts that you're executing that way as well. Your main focus should be on easy maintenance, and the prevention of redundant code. JFTR :shifty:

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 07 Feb 2022, 10:45

Xeo786 wrote:
28 Jan 2022, 01:25
RESTRIVERA1 wrote:
19 Jan 2022, 05:21
Well, I 'm assigned at customs, we're checking the validity of the item such as goods description, weight, commodity codes, and etc. including proper amount of taxes on each parcels.
I got few questions too :D

is GSP form A regularized? or are you still receiving Form A draft Copy signed by export (not by origin authorities)?
is REX Statement of Origin still valid?

Thank you,
Hey Xeo, I'm sorry, I can't answer your questions, I'm just a guy who are validating the data from our client which is the DPD group.. To be precise, we're checking the data from our client tool vs. on google search and some given source.. even the background of consignee/or..

RESTRIVERA1
Posts: 23
Joined: 06 Jan 2022, 04:52

Re: Is it possible to set a loop on each script on GUI?

Post by RESTRIVERA1 » 07 Feb 2022, 11:05

BoBo wrote:
28 Jan 2022, 01:35
@RESTRIVERA1 - if you‘re interested we could review the scripts that you're executing that way as well. Your main focus should be on easy maintenance, and the prevention of redundant code. JFTR :shifty:
Uhmm. I think I still need your help on one of my other task... I hope you could me to this one as well. viewtopic.php?f=76&t=98538&p=437436#p437436

I still couldn't make it work, it's more like if there is a specific text (two or more words) on my screen it will run the corresponding script.

Post Reply

Return to “Ask for Help (v1)”