Help - Using Selection from TreeView

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Senseikkid90
Posts: 3
Joined: 18 Sep 2019, 13:38

Help - Using Selection from TreeView

24 Sep 2019, 16:08

Hello All,

Let me start by saying I am a novice with coding/scripting. I created a basic app for my team which basically list some network printers, swaps an INI file in the destined folder and launches an internal application for printing, this works fine. I wanted to give the app a new look based on the quantity of printers so i started looking at Treeview. I am having issues getting the child folders to execute an IF function, the code executes but only file append/delete the very last lines of the code. Can anyone advise what I'm missing?

Here is a basic concept of the code I wrote:

Code: Select all

P1 := TV_Add("Western Region - West Badging Hub")
P1C1 := TV_Add("Address", P1)  ; Specify P1 to be this item's parent.

return

F1:: Gui, Show, xCenter yCenter, Actions

Send {Click}
Sleep 100
Send {Click}

Action:
If ((A_GuiEvent = "DoubleClick") || (Trigger_Action))
{
    Gui, Submit
	Sleep 4000
	Process, close, App.exe
	sleep 1000
    Run, "C:\Program Files (x86)\XXXXX\

If (P1C1)
{
FileDelete, C:\Program Files (x86)\XXXXX\
FileAppend,  ;
(

[PrintProperties]

 ), C:\Program Files (x86)\XXXXXX\
}
[Mod edit: [code][/code] tags added]
Senseikkid90
Posts: 3
Joined: 18 Sep 2019, 13:38

Re: Help - Using Selection from TreeView

25 Sep 2019, 13:25

Please help good people of AHK forum.

All I want is to allow a double click to execute based on the operations in the child folder. :?: :?: :?: :?: :?: :?:
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Help - Using Selection from TreeView

25 Sep 2019, 23:05

if you want help from this forum, you should show your complete code or a working "basic concept" of your code at least !
Please look at my comments marked with "<==" in the following running "basic concept":

Code: Select all

Gui, Add, TreeView, gAction	; <== line missing, not even a gui defined !!
P1 := TV_Add("Western Region - West Badging Hub")
P1C1 := TV_Add("Address", P1)  ; Specify P1 to be this item's parent.

return

F1:: Gui, Show, xCenter yCenter, Actions

Send {Click}
Sleep 100
Send {Click}
return	; <== line missing

Action:
If ((A_GuiEvent = "DoubleClick") || (Trigger_Action))	; <== where is Trigger_Action set ?
{
    Gui, Submit
	Sleep 4000
	Process, close, App.exe
	sleep 1000
;   Run, "C:\Program Files (x86)\XXXXX\	; <== missing filename and closing " (see error message)

If (P1C1)
{
FileDelete, C:\Program Files (x86)\XXXXX\	; <== missing filename
FileAppend,  ;
(

[PrintProperties]

 ), C:\Program Files (x86)\XXXXXX\	; <== missing filename
}
}	; <== line missing (see error message)
I even doubt you can use the <C:\Program Files> folders for your file
Hubert
Senseikkid90
Posts: 3
Joined: 18 Sep 2019, 13:38

Re: Help - Using Selection from TreeView

28 Sep 2019, 07:07

Your help is most appreciated.

Please see what I have below. The code only executes the file append at the end and runs the software.

Code:

Code: Select all

#SingleInstance Force
FileInstall, remoteprinter.png, %temp%\remoteprinter.png, 1
FileInstall, credit.png, %temp%\credit.png, 1

if not (A_IsAdmin or RegExMatch(full_command_line, " /restart(?!\S)"))
{
    try
    {
        if A_IsCompiled
            Run *RunAs "%A_ScriptFullPath%" /restart
        else
            Run *RunAs "%A_AhkPath%" /restart "%A_ScriptFullPath%"
    }
    ExitApp
}

Gui, +AlwaysOnTop
Gui Margin, 0, 0
Gui, Add, Picture, w500 h350 BackgroundTrans, %temp%\remoteprinter.png
Gui, -Caption 
Gui, Add, Text, x1 y1 w500 h57 BackgroundTrans Center GuiMove, 
Gui, Add, TreeView, x65 y80 w290 h125

P1 := TV_Add("Western Region - West Badging Hub")
P1C1 := TV_Add("11111 Santa Monica, Los Angeles, CA", P1)  ; Specify P1 to be this item's parent.
P1C2 := TV_Add("1165 E Wilmington Ave, Salt Lake City, UT", P1)
P1C3 := TV_Add("2121 N California Blvd, Walnut Creek, CA",P1)
P1C4 := TV_Add("3145 Brookwood Pkwy(Local Printer), Hillsboro OR",P1)
P1C5 := TV_Add("301 Howard St, San Francisco, CA",P1)
P1C6 := TV_Add("9605 Scranton Rd, San Diego, CA",P1)

P2 := TV_Add("Central Region - Central Badging Hub")
P2C1 := TV_Add("1354 E Boot Road(Local Printer), Westchester PA",P2)
P2C2 := TV_Add("1407 Broadway, New York, NY", P2)
P2C3 := TV_Add("55 W 46th St, New York, NY", P2)
P2C4 := TV_Add("584 Broadway, New York, NY", P2)


P3 := TV_Add("Northeast Region - Northeast Badging Hub")
P3C1 := TV_Add("1000 2nd Ave, Seattle, WA", P3)
P3C2 := TV_Add("33 W Monroe St, Chicago, IL", P3)
P3C3 := TV_Add("4000 Port Union Rd, Hamilton, OH", P3)
P3C4 := TV_Add("6200 Bridge Point Prkwy, Austin, TX", P3)

P4 := TV_Add("International - International Badging Hub")
P4C1 := TV_Add("71-91 Alwych House, London, UK",P4)
Gui, Add, Button, x50 y268 w70 h22, OK
Gui, Add, Button, x129 y268 w130 h22, Cancel
Gui, Add, Picture, vCredit x60 y78 w385 h143 BackgroundTrans, %temp%\credit.png
Gui, Show  ; Show the window and its TreeView.
GuiControl, hide ,credit
return


ESC:: 
GuiControl, show ,credit
Sleep 3000
GuiControl, hide ,credit

Return

F1:: Gui, Show, xCenter yCenter, Actions

Send {Click}
Sleep 100
Send {Click}

Action:
If ((A_GuiEvent = "DoubleClick") || (Trigger_Action))
{
    Gui, Submit
	Sleep 4000
	Process, close, SAFEClient.exe
	sleep 1000
    Run, "C:\Program Files (x86)\Quantum Secure\SAFE Smart Client\SAFEClient.exe"

If (P1C1)
{
FileDelete, C:\Program Files (x86)\Quantum Secure\SAFE Smart Client\QSPRINTERSETTINGS.ini
FileAppend,  ;
(
[PrintProperties]
Printername=11111 Santa Monica Blvd DTC1250e Card Printer
DefaultPrinter=NO
Printside=single
Orientation=Portrait
PRINTERMAP=Corporate Employee|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Corporate Security|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Corporate Field Identification|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Comcast Corporate Contractor|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012, Corporate Temp Intern|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Corporate 1717 Cleaning|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Corporate 1717 Security|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Corporate Temp Access|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Corporate 1800 Market Staff|11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Corporate Property Removal |11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012,Comcast Visitor Escort |11111 Santa Monica Blvd DTC1250e Card Printer|Portrait|640|1012 
LandscapeDefaultSize=988,635
LandscapePictureBox=341,219
PortraitDefaultSize=657,1074
PortraitPictureBox=219,358
ReadIClass=false
Debug=false
PictureCropSize=200,250,50,0
FargoMoveInterfaceLocation=C:\Program Files\Quantum Secure\SAFE\Client\Fargo Interface\
SelectedReader=OMNIKEY CardMan 5x21-CL 0
FargoStation=4
WaitParameters=1,1,1,1,1
ReadAttemp=2,15
WriteLog=true
Duplex=4
ShowPrintDialog=false
WebBadgePrint=false
PrintFromIE=false
MoveFargo=false
SmartChipReadTest=false	
HIDCardType=HIDCorp1000
SearchOmnikeyReader=false
ReadIClassEnableBadges=12723
ReadIClassDisabledBadges=12725,12729
 ), C:\Program Files (x86)\Quantum Secure\SAFE Smart Client\QSPRINTERSETTINGS.ini
}

If (P1C2)
{
FileDelete, C:\Program Files (x86)\Quantum Secure\SAFE Smart Client\QSPRINTERSETTINGS.ini
FileAppend,  ;
(
[PrintProperties]
Printername=1165 East Wilmington Ave DTC1250e Card Printer
DefaultPrinter=NO
Printside=single
Orientation=Portrait
PRINTERMAP=Corporate Employee|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Corporate Security|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Corporate Field Identification|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Comcast Corporate Contractor|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012, Corporate Temp Intern|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Corporate 1717 Cleaning|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Corporate 1717 Security|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Corporate Temp Access|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Corporate 1800 Market Staff|1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Corporate Property Removal |1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012,Comcast Visitor Escort |1165 East Wilmington Ave DTC1250e Card Printer|Portrait|640|1012 
LandscapeDefaultSize=988,635
LandscapePictureBox=341,219
PortraitDefaultSize=657,1074
PortraitPictureBox=219,358
ReadIClass=false
Debug=false
PictureCropSize=200,250,50,0
FargoMoveInterfaceLocation=C:\Program Files\Quantum Secure\SAFE\Client\Fargo Interface\
SelectedReader=OMNIKEY CardMan 5x21-CL 0
FargoStation=4
WaitParameters=1,1,1,1,1
ReadAttemp=2,15
WriteLog=true
Duplex=4
ShowPrintDialog=false
WebBadgePrint=false
PrintFromIE=false
MoveFargo=false
SmartChipReadTest=false	
HIDCardType=HIDCorp1000
SearchOmnikeyReader=false
ReadIClassEnableBadges=12723
ReadIClassDisabledBadges=12725,12729
 ), C:\Program Files (x86)\Quantum Secure\SAFE Smart Client\QSPRINTERSETTINGS.ini
} 
}

return

#If WinActive("Actions ahk_class AutoHotkeyGUI")

    Enter::
        Trigger_Action := true
        GoSub, Action
        Trigger_Action := false
    return
ButtonOk:
Trigger_Action := true
        GoSub, Action
        Trigger_Action := false
	 return
	 
ButtonCancel:
Gui, Hide

uiMove:
PostMessage, 0xA1, 2,,, A 
Return

#If

GuiClose:
ExitApp

Sleep 100
[Mod edit: Please use [code][/code] tags around your code, next time. Thank you!]
hd0202
Posts: 183
Joined: 04 Oct 2013, 03:07
Location: Germany near Cologne

Re: Help - Using Selection from TreeView

19 Oct 2019, 05:36

you missed (at least) one comment in my version:

Code: Select all

F1:: Gui, Show, xCenter yCenter, Actions

Send {Click}
Sleep 100
Send {Click}
return	; <== line missing
Hubert

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot] and 107 guests