Here is the code I have so far.. I have broken it several times trying to figure it out so I know I have some repair work to do... but it is the generally working code I have so far.
I have it reading a DVD.ini file located in %filepath% for the device name, searching for the device in device manager, and moving to the next line in the ini if that drive it is not found. If it is found it will set the DVD region for that drive and then re-read the same line in the ini to search for extra drives of the same name. The problem I am facing is it always finds the location of the first drive of that name, and I do not know how to ignore those results.
Currently I have it set to run on XP, but will be using the systempath variable to make it functional on W2K and XP.
Also, I think I am mis-understanding the GetTreeNode results
"GetTreeNode>WindowTitle,ClassName,Instance,Text,Case,Partial,Result,Handle"
Specifically, "Result: Gets set to the zero based index of the item or -1 if not found."
What is the zero based index? In my code am I using this result properly?
Thanks in advance for any suggestions you may have.
Code: Select all
Let>iniline=0
let>filepath=c:\configfile\
let>systempath=c:\windows\system32
gosub>Sub_StartDM
gosub>Sub_SelectDVD
gosub>Sub_Get_Drive_Location
SRT>Sub_StartDM
ExecuteFile>%systempath%\devmgmt.msc
wait>delay
WaitWindowOpen>Device Manager
wait>1
SetFocus>Device Manager
Press Tab
Wait>1
END>Sub_StartDM
SRT>Sub_SelectDVD
GetTreeNode>Device Manager,SysTreeView32,0,DVD/CD-ROM drives,1,0,DVD_CD,Handle
//MessageModal>%result% and handle %handle%
//set %result% as variable
Let>DVD_Parent=%DVD_CD%
//MessageModal>%DVD_Parent%
if>Result=-1
WriteLn>%filepath%\logfile.txt,,Failure:DVD/CD-Rom drop down box not found
endif
wait>delay
Press Home
Press Down * %DVD_Parent%
Press Right
wait>delay
END>Sub_SelectDVD
SRT>Sub_Get_Drive_Location
Label>Get_Drive_Locations
Let>iniline=iniline+1
ReadLn>%filepath%\DVD.ini,%iniLine%,drivename
If>drivename=##EOF##,Done
//go to label>Done
ENDIF
Let>Drive_Name=%drivename%
GetTreeNode>Device Manager,SysTreeView32,0,%Drive_Name%,1,0,Drive_Location,Drive_Handle
//messagemodal>%Drive_Location% %Drive_Handle%
IF>%Drive_Location%=-1
Goto>Get_Drive_Locations
ELSE
IF>%Drive_Location%<0>Distance_From_Parent=%Drive_Location%-%DVD_Parent%
//MessageModal>%Distance_From_Parent%
EndIF
IF>%Drive_Location%=0
//Drive name not found
ELSE
IF>%Drive_Handle%=%Previous_Handle%
goto>Get_Drive_Locations
//need to ignore this drive
ELSE
wait>delay
Press Down * %Distance_From_Parent%
gosub>Sub_Drive_Selected
ENDIF
ENDIF
ENDIF
goto>Get_Drive_Locations
END>Sub_Get_Drive_Location
SRT>Sub_Drive_Selected
wait>1
Press Enter
wait>1
WaitWindowOpen>%Drive_Name% Properties*
wait>1
SetFocus>%Drive_Name% Properties*
wait>delay
Press CTRL
wait>1
Press Tab
wait>1
Press Tab
wait>1
Release CTRL
wait>delay
Send Character/Text>U
wait>delay
Send Character/Text>n
wait>delay
Send Character/Text>i
wait>delay
Send Character/Text>t
wait>delay
Send Character/Text>e
wait>delay
Send Character/Text>d
wait>delay
Send Character/Text>
wait>delay
Send Character/Text>S
wait>delay
Send Character/Text>t
wait>delay
Press Enter
wait>1
PushButton>DVD Region Change*,OK
wait>1
IfWindowOpen>DVD Region Change Error,RegionFailure,NoFailure
Label>RegionFailure
WriteLn>%filepath%\logfile.txt,,Failure:%Drive_Name% Region not set -- needs DVD media
PushButton>DVD Region Change Error,OK
wait>1
PushButton>Properties*,Cancel
wait>1
Let>Previous_Handle=%Drive_Handle%
Let>iniline=iniline-1
gosub>Sub_Get_Drive_Location
Label>NoFailure
PushButton>Properties*,OK
wait>1
Let>Previous_Handle=%Drive_Handle%
WriteLn>%filepath%\logfile.txt,,Success:%Drive_Name% Region set
Let>iniline=iniline-1
gosub>Sub_Get_Drive_Location
End>Sub_Drive_Selected
Label>Done
CloseWindow>Device Manager