Suicid3 Posted April 27, 2009 Share Posted April 27, 2009 I want to read the value of a user defined cell in a excel worksheet. I have made 1 inputboxes, 1 for row_number and 1 for col_number. But when i try to read the value of the inputbox with GUICtrlRead() _ExcelReadCell() crashes and close the applet. I've made the input like this: $GLOBAL_ROW_1 = GUICtrlCreateInput("",70,240,50,20) $GLOBAL_COL_1 = GUICtrlCreateInput("",190,240,50,20) and the Func that reads the input: Func reverse_algo() Local $oExcel Local $aPass Local $bPass Local $cPass Local $dPass Local $ePass $oExcel = _ExcelBookOpen($GLOBAL_EXCEL_FILE,0,True) $aPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_1), GUICtrlRead($GLOBAL_COL_1)) $bPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_2), GUICtrlRead($GLOBAL_COL_2)) $cPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_3), GUICtrlRead($GLOBAL_COL_3)) $dPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_4), GUICtrlRead($GLOBAL_COL_4)) $ePass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_5), GUICtrlRead($GLOBAL_COL_5)) $GLOBAL_REVERSE_PASS = $aPass & $bPass & $cPass & $dPass & $ePass GUICtrlCreateLabel("Password: " & $GLOBAL_REVERSE_PASS,150,360,330,20) _ExcelBookClose($oExcel,0,0) EndFunc Any help is well appreciated. P.S. I'm a newbie at AutoIT Link to comment Share on other sites More sharing options...
Authenticity Posted April 27, 2009 Share Posted April 27, 2009 (edited) $GLOBAL_ROW_2 or $GLOBAL_ROW_* greater than 1 are defined? Can you post the console output of SciTE? Edited April 27, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Suicid3 Posted April 27, 2009 Author Share Posted April 27, 2009 This is the entire code i have writen: CODE#Region Includes #include <StaticConstants.au3> #include <GUIConstantsEx.au3> #include <Date.au3> #include <Excel.au3> #EndRegion #Region Options Opt("TrayIconHide",1) Opt("GUICloseOnESC",1) Opt("MustDeclareVars",1) #EndRegion #Region Declaration of Global Variables Global $GLOBAL_GUI_FONT = "Ariel" Global $GLOBAL_GUI_MSG Global $GLOBAL_GUI_X = 500 Global $GLOBAL_GUI_Y = 480 Global $GLOBAL_BUTTON_EXIT Global $GLOBAL_GET_PASSWORD Global $GLOBAL_COPY_PASSWORD Global $GLOBAL_COPY_ALGORITHM Global $GLOBAL_ALGORITHM Global $GLOBAL_CELL_VALUE Global $GLOBAL_REVERSE_ALGO Global $GLOBAL_ROW_1 Global $GLOBAL_ROW_2 Global $GLOBAL_ROW_3 Global $GLOBAL_ROW_4 Global $GLOBAL_ROW_5 Global $GLOBAL_COL_1 Global $GLOBAL_COL_2 Global $GLOBAL_COL_3 Global $GLOBAL_COL_4 Global $GLOBAL_COL_5 Global $GLOBAL_REVERSE_PASS Global $GLOBAL_COPY_REV_PASS GLobal $GLOBAL_EXCEL_FILE = "c:\temp\encryption_excel.xls" #EndRegion create_gui() populate_gui() #Region Main Application ;~ Applicatin Execution While 1 $GLOBAL_GUI_MSG = GUIGetMsg() Select Case $GLOBAL_GUI_MSG = $GUI_EVENT_CLOSE Exit Case $GLOBAL_GUI_MSG = $GLOBAL_BUTTON_EXIT Exit Case $GLOBAL_GUI_MSG = $GLOBAL_GET_PASSWORD get_password() Case $GLOBAL_GUI_MSG = $GLOBAL_COPY_ALGORITHM copy_algo_clipboard() Case $GLOBAL_GUI_MSG = $GLOBAL_COPY_PASSWORD copy_pass_clipboard() Case $GLOBAL_GUI_MSG = $GLOBAL_REVERSE_ALGO reverse_algo() Case $GLOBAL_GUI_MSG = $GLOBAL_COPY_REV_PASS copy_rev_pass_clipboard() EndSelect WEnd #EndRegion #Region GUI Creation Func create_gui() ;~ Create GUI GUICreate("Applicaton Title",$GLOBAL_GUI_X,$GLOBAL_GUI_Y) GUISetFont(9.5,400,0,$GLOBAL_GUI_FONT) ;~ White Top Box GUICtrlCreateGraphic(0,0,500,80) GUICtrlSetBkColor(-1,0xffffff) GUICtrlCreateGraphic(0,80,500,1,$SS_SUNKEN) ;~ App Header Large Text GUICtrlCreateLabel(StringUpper("Applcation Headline"),20,20,300,40) GUICtrlSetBkColor(-1,0xffffff) GUICtrlSetFont(-1,16,600,$GLOBAL_GUI_FONT) ;~ App Header Small Text GUICtrlCreateLabel("Copyright 2009 - Suicid3",20,45,300,30) GUICtrlSetBkColor(-1,0xffffff) ;~ Date Label GUICtrlCreateLabel(_DateTimeFormat( _NowCalc(),2),430,65,150,14) GUICtrlSetBkColor(-1,0xffffff) ;~ Applicatin Image GUICtrlCreatePic("encryption_image.jpg",435,15,50,50) ;~ "Exit" Button $GLOBAL_BUTTON_EXIT = GUICtrlCreateButton("Exit",380,440,100) GUISetState(@SW_SHOW) EndFunc #EndRegion Func populate_gui() $GLOBAL_GET_PASSWORD = GUICtrlCreateButton("Get Password",20,100,120) GUICtrlCreateLabel("Password: Not Generated",150,100,330) GUICtrlCreateLabel("Algorythme: Not Generated",150,115,330) $GLOBAL_COPY_PASSWORD= GUICtrlCreateButton("Copy Password",20,140,120) $GLOBAL_COPY_ALGORITHM = GUICtrlCreateButton("Copy Algorithm",160,140,120) GUICtrlCreateLabel("Row 1:",20,240,50,20) GUICtrlCreateLabel("Row 2:",20,260,50,20) GUICtrlCreateLabel("Row 3:",20,280,50,20) GUICtrlCreateLabel("Row 4:",20,300,50,20) GUICtrlCreateLabel("Row 5:",20,320,50,20) GUICtrlCreateLabel("Col 1:",140,240,50,20) GUICtrlCreateLabel("Col 2:",140,260,50,20) GUICtrlCreateLabel("Col 3:",140,280,50,20) GUICtrlCreateLabel("Col 4:",140,300,50,20) GUICtrlCreateLabel("Col 5:",140,320,50,20) $GLOBAL_ROW_1 = GUICtrlCreateInput("",70,240,50,20) $GLOBAL_COL_1 = GUICtrlCreateInput("",190,240,50,20) $GLOBAL_ROW_2 = GUICtrlCreateInput("",70,260,50,20) $GLOBAL_COL_2 = GUICtrlCreateInput("",190,260,50,20) $GLOBAL_ROW_3 = GUICtrlCreateInput("",70,280,50,20) $GLOBAL_COL_3 = GUICtrlCreateInput("",190,280,50,20) $GLOBAL_ROW_4 = GUICtrlCreateInput("",70,300,50,20) $GLOBAL_COL_4 = GUICtrlCreateInput("",190,300,50,20) $GLOBAL_ROW_5 = GUICtrlCreateInput("",70,320,50,20) $GLOBAL_COL_5 = GUICtrlCreateInput("",190,320,50,20) $GLOBAL_REVERSE_ALGO = GUICtrlCreateButton("Reverse Algorithm",20,360,120) GUICtrlCreateLabel("Password: " & $GLOBAL_REVERSE_PASS,150,360,330,20) $GLOBAL_COPY_REV_PASS = GUICtrlCreateButton("Copy Password",20,400,120) EndFunc Func get_password() Local $Select_Row Local $Select_Col Local $oExcel Local $sCellValueStep Local $cCount ;~ Reseting Variables $GLOBAL_ALGORITHM = "" $GLOBAL_CELL_VALUE = "" $oExcel = _ExcelBookOpen($GLOBAL_EXCEL_FILE,0,True) For $cCount = 1 To 5 Step 1 $Select_Row = Random(2,101,1) $Select_Col = Random(1,18,1) $sCellValueStep = _ExcelReadCell($oExcel,$Select_Row,$Select_Col) $GLOBAL_CELL_VALUE = $GLOBAL_CELL_VALUE & $sCellValueStep $GLOBAL_ALGORITHM = $GLOBAL_ALGORITHM & $Select_Row & "." & $Select_Col & "-" Next GUICtrlCreateLabel("Password: " & $GLOBAL_CELL_VALUE,150,100,330) GUICtrlCreateLabel("Algorythme: " & $GLOBAL_ALGORITHM,150,115,330) _ExcelBookClose($oExcel,0,0) EndFunc Func reverse_algo() Local $oExcel Local $aPass Local $bPass Local $cPass Local $dPass Local $ePass $oExcel = _ExcelBookOpen($GLOBAL_EXCEL_FILE,0,True) $aPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_1), GUICtrlRead($GLOBAL_COL_1)) $bPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_2), GUICtrlRead($GLOBAL_COL_2)) $cPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_3), GUICtrlRead($GLOBAL_COL_3)) $dPass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_4), GUICtrlRead($GLOBAL_COL_4)) $ePass = _ExcelReadCell($oExcel, GUICtrlRead($GLOBAL_ROW_5), GUICtrlRead($GLOBAL_COL_5)) $GLOBAL_REVERSE_PASS = $aPass & $bPass & $cPass & $dPass & $ePass GUICtrlCreateLabel("Password: " & $GLOBAL_REVERSE_PASS,150,360,330,20) _ExcelBookClose($oExcel,0,0) EndFunc Func copy_pass_clipboard() ClipPut($GLOBAL_CELL_VALUE) EndFunc Func copy_algo_clipboard() ClipPut($GLOBAL_ALGORITHM) EndFunc Func copy_rev_pass_clipboard() ClipPut($GLOBAL_REVERSE_PASS) EndFunc And this is the error message from SciTE CODE>"C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Users\HFS-ITMAT16\Documents\AutoIT\encryption_script.au3" /autoit3dir "C:\Program Files (x86)\AutoIt3" /UserParams +>13:14:01 Starting AutoIt3Wrapper v.1.10.1.14 Environment(Language:0409 Keyboard:00000406 OS:WIN_VISTA/Service Pack 1 CPU:X64 ANSI) >Running AU3Check (1.54.14.0) from:C:\Program Files (x86)\AutoIt3 +>13:14:01 AU3Check ended.rc:0 >Running:(3.3.0.0):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\HFS-ITMAT16\Documents\AutoIT\encryption_script.au3" C:\Program Files (x86)\AutoIt3\Include\Excel.au3 (685) : ==> The requested action with this object has failed.: Return $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).Value Return $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn)^ ERROR ->13:14:14 AutoIT3.exe ended.rc:1 +>13:14:15 AutoIt3Wrapper Finished >Exit code: 1 Time: 14.957 Link to comment Share on other sites More sharing options...
Juvigy Posted April 27, 2009 Share Posted April 27, 2009 i think GUICtrlRead reads the data as string from inputs .You need to convert the string to number first. Link to comment Share on other sites More sharing options...
Suicid3 Posted April 27, 2009 Author Share Posted April 27, 2009 Okay. That might be it. I'll try and have a look at it:) THX Link to comment Share on other sites More sharing options...
Suicid3 Posted April 27, 2009 Author Share Posted April 27, 2009 i think GUICtrlRead reads the data as string from inputs .You need to convert the string to number first.IT WORKED I just changed GUICtrlRead($GLOBAL_ROW_1) to Int(GUICtrlRead($GLOBAL_ROW_1)) and all was fineTHX for the help 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