robinsiebler Posted October 24, 2006 Share Posted October 24, 2006 I'm trying to automate a plugin for Total Commander that mounts ISO's. However when I try to search for a string in a ListBox, it returns 0. The control has no text, so I'm using the classname. I don't know if I am doing something wrong, or it is something weird with Total Commander. expandcollapse popup#Include <GuiList.au3> Dim $sInputBoxAnswer = GetImageName() ValidateInputBox($sInputBoxAnswer) WinActivate("Total Commander") Send("^t") ;Duplicate tab Send("!{UP}");Select directory path Send("\\\Virtual Disks\{ENTER}");Activate plugin ;Check for image name Dim $sLB1 = "TMyListBox1" Dim $sLB2 = "TMyListBox2" Dim $sActivePane Dim $iListIndex = _GUICtrlListFindString($sLB1, $sInputBoxAnswer) MsgBox(262144,'Debug line ~14','Selection:' & @lf & '$iListIndex' & @lf & @lf & 'Return:' & @lf & $iListIndex & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX If $iListIndex == $LB_ERR Then $iListIndex = _GUICtrlListFindString($sLB2, $sInputBoxAnswer) Else $sActivePane = $sLB1 EndIf If $iListIndex <> $LB_ERR Then $sActivePane = $sLB2 _GUICtrlListSetCaretIndex($iListIndex, $sActivePane) Else ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical MsgBox(16,"Fatal Error!","Unable to find the specified Image name!") EndIf Func GetImageName() ;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Width=300, Height=150 Dim $sInputBoxAnswer = InputBox("Image to Mount","Enter the name of the Image to Mount:",""," ","300","150","-1","-1") Return $sInputBoxAnswer EndFunc Func ValidateInputBox($sInputBoxAnswer) Select Case @Error = 0;OK - The string returned is valid If StringLen($sInputBoxAnswer) < 1 Then ;MsgBox features: Title=No, Text=Yes, Buttons=OK, Icon=Warning MsgBox(48,"Input not provided!","Please enter an Image Name!") GetImageName() ValidateInputBox($sInputBoxAnswer) EndIf Case @Error = 1;The Cancel button was pushed Exit Case @Error = 3;The InputBox failed to open ;MsgBox features: Title=No, Text=Yes, Buttons=OK, Icon=Critical MsgBox(16,"Fatal Error!","An error occured! Aborting script!") Exit EndSelect EndFunc Link to comment Share on other sites More sharing options...
GaryFrost Posted October 25, 2006 Share Posted October 25, 2006 TMyListBox is not a standard Listbox, it's a custom listbox so you'll have to find some other way to get the information if the method you tried doesn't work. You could try ControlCommand but once again this may not work on custom ListBoxes. gl SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
robinsiebler Posted October 25, 2006 Author Share Posted October 25, 2006 Since that won't work, I decided to try using the the QuickSearch feture of TC to highlight the file name. However, I've run into another strange behavior. When I run the following command, I end up with 0 in the commandline: Send("{ESC}!"+ $sInputBoxAnswer) If I do this Send("{ESC}!Da") I end up with 'Da' in the quicksearch bar. In the 1st command, the value of the variable is 'Data'. I don't know why I'm getting the strange behavior. Link to comment Share on other sites More sharing options...
PaulIA Posted October 25, 2006 Share Posted October 25, 2006 Send("{ESC}!"+ $sInputBoxAnswer) oÝ÷ Ù(hºW[y«¢+ÙM¹ ÅÕ½ÐííM ôÌÌìÅÕ½ÐìµÀìÀÌØíÍ%¹ÁÕÑ ½á¹ÍÝȤ Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
robinsiebler Posted October 25, 2006 Author Share Posted October 25, 2006 That fixed it. Thanks! <wanders off to get more coffee>Don't I feel like a bonehead! Link to comment Share on other sites More sharing options...
PaulIA Posted October 25, 2006 Share Posted October 25, 2006 <wanders off to get more coffee>Don't I feel like a bonehead! I do the same thing all the time. Hang in there. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
robinsiebler Posted October 25, 2006 Author Share Posted October 25, 2006 Ok, now for the next problem:;Check for image name Send("{ESC}!" & $sInputBoxAnswer & "{ESC}") Send("^{ENTER}") If ControlClick("Total Commander", "", "Edit1") Then Dim $sFileSelected = _GUICtrlEditGetSel("Edit1") MsgBox(262144,'Debug line ~14','Selection:' & @lf & '$sFileSelected' & @lf & @lf & 'Return:' & @lf & $sFileSelected & @lf & @lf & '@Error:' & @lf & @Error);### Debug MSGBOX EndIf$sFileSelected is empty after this, but I get the debug msgbox, so I know the control was clicked and when you click on it, all the text is selected automatically. Link to comment Share on other sites More sharing options...
PaulIA Posted October 25, 2006 Share Posted October 25, 2006 Dim $sFileSelected = ControlGetText("Total Commander", "", "Edit1") Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
robinsiebler Posted October 25, 2006 Author Share Posted October 25, 2006 I'm just having a day, huh? <looks for the emoticon with a dunce hat...> Link to comment Share on other sites More sharing options...
PaulIA Posted October 25, 2006 Share Posted October 25, 2006 Ah, the joy of learning. Auto3Lib: A library of over 1200 functions for AutoIt Link to comment Share on other sites More sharing options...
robinsiebler Posted October 25, 2006 Author Share Posted October 25, 2006 Now I think you are confused. I've heard of the Joy of Cooking and the Joy of Sex but I don't recall any Joy of Learning. Link to comment Share on other sites More sharing options...
robinsiebler Posted October 25, 2006 Author Share Posted October 25, 2006 (edited) It's working now, if anyone is interested: expandcollapse popupDim $sInputBoxAnswer = GetImageName() ValidateInputBox($sInputBoxAnswer) WinActivate("Total Commander") Send("^t");Duplicate tab Send("!{UP}");Select directory path Send("\\\Virtual Disks\{ENTER}");Activate plugin ;Check for image name Send("{ESC}!" & $sInputBoxAnswer & "{ESC}") Send("^{ENTER}") If ControlClick("Total Commander", "", "Edit1") Then Dim $sFileSelected = ControlGetText("Total Commander", "", "Edit1") EndIf If StringTrimRight($sFileSelected, 5) <> $sInputBoxAnswer Then ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical MsgBox(16,"Fatal Error!","Unable to find the specified Image name!") Exit EndIf Send("{ESC}{ENTER}") If WinWaitActive("Properties", "", 5) Then Dim $sMountStatus = ControlGetText("Properties", "", "Static3") Dim $iStringPos = StringInStr($sMountStatus, "unmounted") If $iStringPos Then $sMountStatus = "Mounted";What the status will be *after* the current operation Else $sMountStatus = "Unmounted" EndIf Dim $sDriveLetter = ControlGetText("Properties", "", "ComboBox1") ControlClick("Properties", "", 1) If $sMountStatus = "Mounted" Then ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Info MsgBox(64,"Image Mounted","The image " & $sInputBoxAnswer & " was mounted on " & $sDriveLetter) Else MsgBox(64,"Image Unmounted","The image " & $sInputBoxAnswer & " was unmounted from " & $sDriveLetter) EndIf Send("^w") Else ;MsgBox features: Title=Yes, Text=Yes, Buttons=OK, Icon=Critical MsgBox(16,"Fatal Error!","The Virtual Disks Property dialog did not open!") Exit EndIf Func GetImageName() ;InputBox features: Title=Yes, Prompt=Yes, Default Text=No, Width=300, Height=150 Dim $sInputBoxAnswer = InputBox("Image to Mount","Enter the name of the Image to Mount:",""," ","300","150","-1","-1") Return $sInputBoxAnswer EndFunc Func ValidateInputBox($sInputBoxAnswer) Select Case @Error = 0;OK - The string returned is valid If StringLen($sInputBoxAnswer) < 1 Then ;MsgBox features: Title=No, Text=Yes, Buttons=OK, Icon=Warning MsgBox(48,"Input not provided!","Please enter an Image Name!") GetImageName() ValidateInputBox($sInputBoxAnswer) EndIf Case @Error = 1;The Cancel button was pushed Exit Case @Error = 3;The InputBox failed to open ;MsgBox features: Title=No, Text=Yes, Buttons=OK, Icon=Critical MsgBox(16,"Fatal Error!","An error occured! Aborting script!") Exit EndSelect EndFunc Edited October 25, 2006 by robinsiebler Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now