-
Posts
129 -
Joined
-
Last visited
About Affe
- Birthday 05/18/1983
Profile Information
-
WWW
http://antfamous.net
Affe's Achievements

Adventurer (3/7)
1
Reputation
-
guestscripter reacted to a post in a topic: Attaching a GUI to Another Window
-
WM_COMMAND and ListView/TreeView Items
Affe replied to Affe's topic in AutoIt General Help and Support
Thanks I was searching "WM COMMAND" and "ListView"... didn't think to search "WM CONTEXTMENU" and "ListView"!!- 5 replies
-
- WM_COMMAND
- ListView
-
(and 1 more)
Tagged with:
-
WM_COMMAND and ListView/TreeView Items
Affe replied to Affe's topic in AutoIt General Help and Support
I currently use WM_NOTIFY to set global elements to tell the WM_CONTEXTMENU which menu to build. I wish I could attach my actual code, but it contains elements that are security sensitive (login information) and simply eliminating that information will yield a brick of code. Here is my WM_NOTIFY (global variables set are $menu, $menuitem, and $menuitem_key): Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTreeview, $hWndListView $hWndTreeview = $hTreeView If Not IsHWnd($hTreeView) Then $hWndTreeview = GUICtrlGetHandle($hTreeView) $hWndListView = $hListView If Not IsHWnd($hListView) Then $hWndListView = GUICtrlGetHandle($hListView) $tNMHDR = DllStructCreate($tagNMHDR, $ilParam) $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) $iIDFrom = DllStructGetData($tNMHDR, "IDFrom") $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView $menu = "listview" Switch $iCode Case $LVN_COLUMNCLICK Local $tInfo = DllStructCreate($tagNMLISTVIEW, $ilParam) Local $ColumnIndex = DllStructGetData($tInfo, "SubItem") _ListView_Sort($ColumnIndex) Return 0 Case $NM_CLICK ; The user has clicked the right mouse button within the control Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) Local $text = _GUICtrlListView_GetItemText($hWndListView, DllStructGetData($tInfo, "Index")) Local $hItem = _GUICtrlListView_GetItem($hWndListView, DllStructGetData($tInfo, "Index")) $menu = "file" $menuitem = $text $menuitem_key = $_MF_File_Tree[_GUICtrlListView_GetItemParam($hWndListView, DllStructGetData($tInfo, "Index"))][0] Return 0 Case $NM_RCLICK ; The user has clicked the right mouse button within the control Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) Local $text = _GUICtrlListView_GetItemText($hWndListView, DllStructGetData($tInfo, "Index")) Local $hItem = _GUICtrlListView_GetItem($hWndListView, DllStructGetData($tInfo, "Index")) $menu = "file" $menuitem = $text $menuitem_key = $_MF_File_Tree[_GUICtrlListView_GetItemParam($hWndListView, DllStructGetData($tInfo, "Index"))][0] Return 0 EndSwitch Case $hWndTreeview $menu = "folder" Switch $iCode Case $NM_CLICK ; The user has clicked the left mouse button within the control _DebugPrint("$NM_CLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_DBLCLK ; The user has double-clicked the left mouse button within the control _DebugPrint("$NM_DBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RCLICK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $NM_RDBLCLK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RDBLCLK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing Case $TVN_SELCHANGEDW ;~ Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam) $treeview_change = True Return 0 EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY So I suppose my question then is, how do I get WM_NOTIFY to realize that I clicked on the corresponding menu item? Here is my WM_CONTEXTMENU in case it is needed for reference: Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam Local $hMenu If $menu == "" or $menu == "none" Then Return True $hMenu = _GUICtrlMenu_CreatePopup(32) If $hMenu = 0 Then MsgBox(0, "Menu", "Error") Select Case $menu == "file" If $menuitem == "" Then _GUICtrlMenu_DestroyMenu($hMenu) Return True EndIf _GUICtrlMenu_InsertMenuItem($hMenu, 0, 'Preview "' & $menuitem & '"', $idPreview) _GUICtrlMenu_InsertMenuItem($hMenu, 1, 'Download "' & $menuitem & '"', $idDownload) _GUICtrlMenu_InsertMenuItem($hMenu, 2, "Edit Description", $idEditDescription) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Edit Tags", $idEditTags) _GUICtrlMenu_InsertMenuItem($hMenu, 4, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 5, "Rename", $idRename) _GUICtrlMenu_InsertMenuItem($hMenu, 6, "Delete key " & $menuitem_key, $idDelete) Case $menu == "folder" _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Rename", $idRename) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Delete", $idDelete) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo) Case $menu == "listview" _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Details", $idViewDetails) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Large Icon", $idViewLgIcon) _GUICtrlMenu_InsertMenuItem($hMenu, 2, "List", $idViewList) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Small Icon", $idViewSmIcon) _GUICtrlMenu_InsertMenuItem($hMenu, 4, "Tile", $idViewTile) Case Else EndSelect _GUICtrlMenu_TrackPopupMenu($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU- 5 replies
-
- WM_COMMAND
- ListView
-
(and 1 more)
Tagged with:
-
Add columns to array (inverse of _ArrayUnique)
Affe replied to Kyan's topic in AutoIt General Help and Support
I think you're confused as to what "_ArrayUnique()" does. If I'm guessing correctly, you want to take three arrays and concatenate them. You could do this by declaring a fourth, new array, with the number of columns needed, and insert each element in like this: Dim $array_1[5][2] = [[1, "A"], [2, "B"], [3, "C"], [4, "D"], [5, "E"]] Dim $array_2[5][2] = [[1, "A"], [2, "B"], [3, "C"], [4, "D"], [5, "E"]] Dim $array_3[5][2] = [[1, "A"], [2, "B"], [3, "C"], [4, "D"], [5, "E"]] Dim $new_array[5][6] ;5 rows and 6 columns to hold both columns from each array above For $x = 0 To 4 $new_array[$x][0] = $array_1[$x][0] $new_array[$x][1] = $array_1[$x][1] $new_array[$x][2] = $array_2[$x][0] $new_array[$x][3] = $array_2[$x][1] $new_array[$x][4] = $array_3[$x][0] $new_array[$x][5] = $array_4[$x][1] Next -
Trying to use WM_COMMAND and WM_CONTEXTMENU in my GUI, and I'm having issue with the fact that WM_COMMAND doesn't fire when the mouse is over a listview or treeview. You can try to simulate my issue with the example code below. The WM_COMMAND will fire whenever the menu is created over the GUI background, but not when the menu is over the listview. #include <GuiMenu.au3> #include <GUIConstantsEx.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global Enum $idOpen = 1000, $idSave, $idInfo _Main() Func _Main() ; Create GUI GUICreate("Menu", 400, 300) $hlistview = GUICtrlCreateListView("", 10, 10, 150, 280) GUISetState() ; Register message handlers GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_CONTEXTMENU, "WM_CONTEXTMENU") ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>_Main ; Handle WM_COMMAND messages Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam Switch $iwParam Case $idOpen _WinAPI_ShowMsg("Open") Case $idSave _WinAPI_ShowMsg("Save") Case $idInfo _WinAPI_ShowMsg("Info") EndSwitch EndFunc ;==>WM_COMMAND ; Handle WM_CONTEXTMENU messages Func WM_CONTEXTMENU($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $ilParam Local $hMenu $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo) _GUICtrlMenu_TrackPopupMenu($hMenu, $iwParam) _GUICtrlMenu_DestroyMenu($hMenu) Return True EndFunc ;==>WM_CONTEXTMENU Can anyone help me out with this? Thanks!
- 5 replies
-
- WM_COMMAND
- ListView
-
(and 1 more)
Tagged with:
-
WinHttp.au3 Send Request - Get Bytes Transferred?
Affe replied to Affe's topic in AutoIt General Help and Support
Waited a while before bumping (lol), anyone know if this is possible? -
How can I see HTMLayout controls using AutoIT Window Info?
Affe replied to andreib's topic in AutoIt General Help and Support
If you plan to do a lot of work manipulating IE, I suggest you download and install http://www.debugbar.com/. That will give you all the information you are hoping to find with the window info tool. -
Is there a way to poll a request made using the WinHttp.au3 UDF for how much data has been sent during a transmission? I ask because I would like to get how much data has been sent with a binary file transfer using a post method. Edit: I want to be able to do this periodically during the transmission to get upload progress. Thanks!
-
I am writing a UDF to take advantage of MediaFire's api. I'm currently able to do everything - except one thing. I can't seem to perform the upload asynchronously, which pauses the script while uploading the file and doesn't allow me to check the status (as I haven't received a response from the mediafire server containing the upload key until the upload is complete). This is what I'm currently using, I've commented out the options on _WinHttpOpen() as the Async tag causes a crash when uploading: Func _MF_HTTP_Upload($_mf_url, $_mf_filename, $_mf_file, $_mf_content) Local $hWINHTTP_STATUS_CALLBACK = DllCallbackRegister("__WINHTTP_STATUS_CALLBACK", "none", "handle;dword_ptr;dword;ptr;dword") If StringLeft($_mf_content, 1) == "&" Then $_mf_content = StringTrimLeft($_mf_content, 1) Local $_mf_open = _WinHttpOpen();Default, Default, Default, Default, $WINHTTP_FLAG_ASYNC) _WinHttpSetStatusCallback($_mf_open, $hWINHTTP_STATUS_CALLBACK) Local $_mf_connect = _WinHttpConnect($_mf_open, "www.mediafire.com") Local $_mf_request = _WinHttpOpenRequest($_mf_connect, "POST", "api/" & $_mf_url & "?" & $_mf_content, -1, -1, -1, $WINHTTP_FLAG_SECURE) Local $_mf_http_timer = TimerInit() Local $_mf_filehandle = FileOpen($_mf_file) Local $_mf_filedata = FileRead($_mf_filehandle) FileClose($_mf_filehandle) _WinHttpAddRequestHeaders($_mf_request, "Content-Type: application/octet-stream") _WinHttpAddRequestHeaders($_mf_request, "X-Filename: " & $_mf_filename) _WinHttpAddRequestHeaders($_mf_request, "X-Filesize: " & FileGetSize($_mf_file)) _WinHttpAddRequestHeaders($_mf_request, "X-Filetype: " & __WinHttpMIMEType($_mf_file)) If $_MF_Debug Then ConsoleWrite(@CRLF & "Content-Type: application/octet-stream") If $_MF_Debug Then ConsoleWrite(@CRLF & "X-Filename: " & $_mf_filename) If $_MF_Debug Then ConsoleWrite(@CRLF & "X-Filesize: " & FileGetSize($_mf_file)) If $_MF_Debug Then ConsoleWrite(@CRLF & "X-Filetype: " & __WinHttpMIMEType($_mf_file) & @CRLF & @CRLF) _WinHttpSendRequest($_mf_request, -1, StringToBinary($_mf_filedata)) ;~ MsgBox(64 + 262144, "Wait...", "Wait for the results if they are not shown already.") _WinHttpReceiveResponse($_mf_request) Local $_mf_response = "<result>Fail</result>" If _WinHttpQueryDataAvailable($_mf_request) Then ; if there is data $_mf_response = "" Do $_mf_response &= _WinHttpReadData($_mf_request) Until @error If StringLen($_mf_response) > 0 Then $_MF_Last_Response = $_mf_response $_MF_Response_Time = TimerDiff($_mf_http_timer) If $_MF_Debug_show_response Then ConsoleWrite(@CRLF & "MediaFire Response: " & @CR & $_mf_response & @CR) If $_MF_Debug_show_response_time Then ConsoleWrite("MediaFire Response Time: " & $_MF_Response_Time & " ms" & @CRLF) EndIf _WinHttpCloseHandle($_mf_request) _WinHttpCloseHandle($_mf_connect) _WinHttpCloseHandle($_mf_open) DllCallbackFree($hWINHTTP_STATUS_CALLBACK) Return $_mf_response EndFunc Anyone able to point where I'm going wrong with this function?
-
I was kinda hoping that it would help out a little -- I didn't know it was related to my main script as it said the error was in the IE script. My crystal ball tells me that no one will probably look through this, but I'm going to post it anyway... So I guess here goes the best I can with this lengthy script... First, here is the function that I start with. This function brings up a GUI where I input part numbers to be looked up: Func Create_Item_Array() Local $ListViewItems Local $numitems = 1 #region ### START Koda GUI section ### Form=C:Documents and SettingsCoryDesktopSAMOrderEntry.kxf $Form1_1_1 = GUICreate("SAM Order Entry", 635, 451, @DesktopWidth/2 - 317, @DesktopHeight/2 - 225) $Items_ListView = GUICtrlCreateListView("Part Number|Qty|Loc|Vendor", 16, 16, 305, 417) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 85) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 35) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50) GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 130) $AddItem_Group = GUICtrlCreateGroup("Add Item", 328, 16, 289, 231) $Item_Number_Input = GUICtrlCreateInput("", 432, 40, 169, 21) $Quantity_Input = GUICtrlCreateInput("", 432, 72, 169, 21) $Shop_Combo = GUICtrlCreateCombo("", 432, 112, 169, 25) GUICtrlSetData(-1, "Shop #4|Shop #5|Shop #6") $Label1 = GUICtrlCreateLabel("Part Number:", 360, 40, 66, 17) $Label2 = GUICtrlCreateLabel("Quantity:", 360, 72, 46, 17) $Label3 = GUICtrlCreateLabel("Shop:", 360, 112, 32, 17) $AddItem_btn = GUICtrlCreateButton("Add Item", 480, 176, 121, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) $RemoveItem_btn = GUICtrlCreateButton("Remove Item", 344, 176, 113, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) $GetLastVend_btn = GUICtrlCreateButton("Get Last Vendor", 480, 209, 121, 25, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) GUICtrlCreateGroup("", -99, -99, 1, 1) $CreateOrders_btn = GUICtrlCreateButton("Create Orders", 528, 384, 89, 41, $WS_GROUP) GUICtrlSetState(-1, $GUI_DISABLE) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### ;~ GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $Item_Number_Input If GUICtrlRead($Quantity_Input) = Not "" And GUICtrlRead($Shop_Combo) = Not "" Then GUICtrlSetState($AddItem_btn, $GUI_ENABLE) EndIf Case $Quantity_Input If GUICtrlRead($Item_Number_Input) = Not "" And GUICtrlRead($Shop_Combo) = Not "" Then GUICtrlSetState($AddItem_btn, $GUI_ENABLE) EndIf Case $Shop_Combo If GUICtrlRead($Quantity_Input) = Not "" And GUICtrlRead($Shop_Combo) = Not "" Then GUICtrlSetState($AddItem_btn, $GUI_ENABLE) EndIf Case $AddItem_btn GUICtrlSetState($AddItem_btn, $GUI_DISABLE) GUICtrlSetState($Item_Number_Input, $GUI_DISABLE) GUICtrlSetState($Quantity_Input, $GUI_DISABLE) GUICtrlSetState($Shop_Combo, $GUI_DISABLE) GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE) GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE) GUICtrlSetState($GetLastVend_btn, $GUI_DISABLE) $itemnum = StringUpper(GUICtrlRead($Item_Number_Input)) $itemqty = GUICtrlRead($Quantity_Input) $itemshop = GUICtrlRead($Shop_Combo) If Not IsArray($ListViewItems) Then Local $ListViewItems[1][5] If $numitems > UBound($ListViewItems) Then ReDim $ListViewItems[$numitems][5] $ListViewItems[$numitems - 1][0] = GUICtrlCreateListViewItem($itemnum & "|" & $itemqty & "|" & $itemshop & "|Awaiting Last Vendor...", $Items_ListView) $ListViewItems[$numitems - 1][1] = $itemnum $ListViewItems[$numitems - 1][2] = $itemqty $ListViewItems[$numitems - 1][3] = $itemshop $ListViewItems[$numitems - 1][4] = "Need" ;added because below code was commented, filler ;~ $lastvend = Get_Last_Vendor_Ordered($itemnum) ;~ If $lastvend = False Then ;~ $lastvend = "Unknown" ;~ EndIf ;~ $ListViewItems[$numitems - 1][4] = $lastvend ;~ GUICtrlSetData($ListViewItems[$numitems - 1][0], $itemnum & "|" & $itemqty & "|" & $itemshop & "|" & $ListViewItems[$numitems - 1][4]) ;~ If $lastvend = "Unknown" then _GUICtrlListView_SetBkColor($ListViewItems[$numitems - 1][0], (0xDA3838)) $numitems += 1 GUICtrlSetState($RemoveItem_btn, $GUI_ENABLE) GUICtrlSetState($CreateOrders_btn, $GUI_ENABLE) GUICtrlSetData($Item_Number_Input, "") GUICtrlSetData($Quantity_Input, "") _GUICtrlComboBox_SetCurSel($Shop_Combo, -1) GUICtrlSetState($Item_Number_Input, $GUI_ENABLE) GUICtrlSetState($Quantity_Input, $GUI_ENABLE) GUICtrlSetState($Shop_Combo, $GUI_ENABLE) GUICtrlSetState($GetLastVend_btn, $GUI_ENABLE) Case $RemoveItem_btn $delete = GUICtrlRead($Items_ListView) $count = 0 If IsArray($ListViewItems) Then For $x = 0 To UBound($ListViewItems) - 1 If $delete = $ListViewItems[$x][0] Then GUICtrlDelete($ListViewItems[$x][0]) _ArrayDelete($ListViewItems, $x) $numitems -= 1 ExitLoop EndIf $count += 1 Next EndIf If Not IsArray($ListViewItems) Then GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE) GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE) EndIf Case $CreateOrders_btn GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE) GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE) GUICtrlSetState($AddItem_btn, $GUI_DISABLE) GUICtrlSetState($Item_Number_Input, $GUI_DISABLE) GUICtrlSetState($Quantity_Input, $GUI_DISABLE) GUICtrlSetState($Shop_Combo, $GUI_DISABLE) GUICtrlSetState($GetLastVend_btn, $GUI_DISABLE) For $x = 0 To UBound($ListViewItems) - 1 If $ListViewItems[$x][4] = "Need" Then GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & "Getting Last Vendor...") $lastvend = Get_Last_Vendor_Ordered($ListViewItems[$x][1]) If $lastvend = False Then $lastvend = "Unknown" EndIf $ListViewItems[$x][4] = $lastvend GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4]) If $lastvend = "Unknown" Then GUICtrlSetBkColor($ListViewItems[$x][0], (0xFF0000)) ;~ GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & ": Cannot find vendor, enter order manually" & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4]) ;~ GUICtrlSetTip($ListViewItems[$x][0], "Cannot find vendor, must enter order manually.") Else GUICtrlSetBkColor($ListViewItems[$x][0], (0x00FF00)) EndIf EndIf Next ;BEGIN SORTING ARRAY ;WE MUST CREATE AN ADDITIONAL DIMENSION TO SORT ON BASED UPON VENDOR AND SHOP Local $orderarray = $ListViewItems ReDim $ListViewItems[UBound($ListViewItems)][6] For $x = 0 To UBound($ListViewItems) - 1 $ListViewItems[$x][5] = $ListViewItems[$x][4] & $ListViewItems[$x][3] Next _ArraySort($ListViewItems, 0, 0, 0, 5) ;~ ReDim $ListViewItems[UBound($ListViewItems)][5] ;~ _ArrayDisplay($ListViewItems) ;END SORTING OF ARRAY For $x = 0 To UBound($ListViewItems) - 1 GUICtrlSetData($orderarray[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4]) $ListViewItems[$x][0] = $orderarray[$x][0] If $ListViewItems[$x][4] = "Unknown" Then GUICtrlSetBkColor($ListViewItems[$x][0], (0xFF0000)) ;~ GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & ": Cannot find vendor, enter order manually" & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4]) ;~ GUICtrlSetTip($ListViewItems[$x][0], "Cannot find vendor, must enter order manually.") Else GUICtrlSetBkColor($ListViewItems[$x][0], (0x00FF00)) EndIf Next Local $createarray Local $badarray Local $badcount = 0 $lastshop = $ListViewItems[0][3] $lastvend = $ListViewItems[0][4] $last = $ListViewItems[0][5] $len = UBound($ListViewItems) ReDim $ListViewItems[$len + 1][6] $ListViewItems[$len][0] = "Done" $count = 0 For $x = 0 To UBound($ListViewItems) - 1 If $ListViewItems[$x][4] = "Unknown" Then If Not IsArray($badarray) Then Local $badarray[1][3] If $badcount + 1 > UBound($createarray) Then ReDim $badarray[$badcount + 1][3] $badarray[$badcount][0] = $ListViewItems[$x][1] $badarray[$badcount][1] = $ListViewItems[$x][2] $badarray[$badcount][2] = $ListViewItems[$x][3] $badcount += 1 ;~ _ArrayDisplay($badarray) ElseIf $ListViewItems[$x][5] = $last Then If Not IsArray($createarray) Then Local $createarray[1][2] If $count + 1 > UBound($createarray) Then ReDim $createarray[$count + 1][2] $createarray[$count][0] = $ListViewItems[$x][1] $createarray[$count][1] = $ListViewItems[$x][2] $count += 1 ;~ _ArrayDisplay($createarray) ElseIf $ListViewItems[$x][0] = "Done" Then Create_Purchase_Order($lastshop, $lastvend, "SHIP ASAP. THANKS!", $createarray) $ttlqty = 0 For $v = 0 To UBound($createarray) - 1 $ttlqty += Int($createarray[$v][1]) Next $verify = Verify_Order($lastvend, $ttlqty) ;~ If $verify = False Then ;~ MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified") ;~ Exit ;~ EndIf ;ADDING IN VERIFY CHANGE HERE If $verify = False Then $oPO_Form = _IEFormGetObjByName($Location_Frame, "purchaseOrderForm") $elements = _IEFormElementGetCollection($oPO_Form) For $element In $elements If StringInStr($element.value, "Add") > 0 Then $button = $element EndIf Next _IEAction($button, "click") _IELoadWait($Location_Frame) $neworderForm = _IEFormGetObjByName($Location_Frame, "receiptForm") $elements = _IEFormElementGetCollection($neworderForm) For $element In $elements If StringInStr($element.name, "arPartNumber[" & $x & "]") > 0 Then $partform = $element $focuselement1 = $element ElseIf StringInStr($element.name, "arDescription[" & $x & "]") > 0 Then $focuselement2 = $element ElseIf StringInStr($element.name, "arPartLocationID[" & $x & "]") > 0 Then $partlocationform = $element ElseIf StringInStr($element.name, "arQuantity[" & $x & "]") > 0 Then $qtyform = $element ElseIf StringInStr($element.name, "arPromiseDate[" & $x & "]") > 0 Then $dateform = $element EndIf Next For $x = 1 To UBound($createarray) _IEFormElementOptionSelect($partlocationform, StringRight($lastshop, 1), 1, "byText", 1) Next For $element In $elements If StringInStr($element.value, "Submit") > 0 Then $button = $element EndIf Next _IEAction($button, "click") _IELoadWait($Location_Frame) $verify = Verify_Order($lastvend, $ttlqty) If $verify = False Then MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified") Exit EndIf EndIf ;ABOVE IS VERIFY CHANGE Email_Order($verify, $lastvend) For $v = 0 To UBound($createarray) - 1 _ArrayDelete($createarray, $v) Next ReDim $ListViewItems[$len][6] If IsArray($badarray) Then MsgBox(48, "WARNING: Not Ordered", "The items on the next chart could not be " & @CRLF & "ordered because no last vendor was available.") _ArrayDisplay($badarray, "No Vendor/Bad Part Number") For $v = 0 To UBound($badarray) - 1 _ArrayDelete($badarray, $v) Next EndIf Else;If $ListViewItems[$x][5] = Not $last Then Create_Purchase_Order($lastshop, $lastvend, "SHIP ASAP. THANKS!", $createarray) $ttlqty = 0 For $v = 0 To UBound($createarray) - 1 $ttlqty += Int($createarray[$v][1]) Next $verify = Verify_Order($lastvend, $ttlqty) ;~ If $verify = False Then ;~ MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified") ;~ Exit ;~ EndIf ;ADDING IN VERIFY CHANGE HERE If $verify = False Then $oPO_Form = _IEFormGetObjByName($Location_Frame, "purchaseOrderForm") $elements = _IEFormElementGetCollection($oPO_Form) For $element In $elements If StringInStr($element.value, "Add") > 0 Then $button = $element EndIf Next _IEAction($button, "click") _IELoadWait($Location_Frame) $neworderForm = _IEFormGetObjByName($Location_Frame, "receiptForm") $elements = _IEFormElementGetCollection($neworderForm) For $element In $elements If StringInStr($element.name, "arPartNumber[" & $x & "]") > 0 Then $partform = $element $focuselement1 = $element ElseIf StringInStr($element.name, "arDescription[" & $x & "]") > 0 Then $focuselement2 = $element ElseIf StringInStr($element.name, "arPartLocationID[" & $x & "]") > 0 Then $partlocationform = $element ElseIf StringInStr($element.name, "arQuantity[" & $x & "]") > 0 Then $qtyform = $element ElseIf StringInStr($element.name, "arPromiseDate[" & $x & "]") > 0 Then $dateform = $element EndIf Next For $x = 1 To UBound($createarray) _IEFormElementOptionSelect($partlocationform, StringRight($lastshop, 1), 1, "byText", 1) Next For $element In $elements If StringInStr($element.value, "Submit") > 0 Then $button = $element EndIf Next _IEAction($button, "click") _IELoadWait($Location_Frame) $verify = Verify_Order($lastvend, $ttlqty) If $verify = False Then MsgBox(0, "ORDER ERROR", "The purchase order for " & $lastvend & " could not be verified") Exit EndIf EndIf ;ABOVE IS VERIFY CHANGE Email_Order($verify, $lastvend) $count = 0 For $v = 0 To UBound($createarray) - 1 _ArrayDelete($createarray, $v) Next $lastshop = $ListViewItems[$x][3] $lastvend = $ListViewItems[$x][4] $last = $ListViewItems[$x][5] If Not IsArray($createarray) Then Local $createarray[1][2] If $count + 1 > UBound($createarray) Then ReDim $createarray[$count + 1][2] $createarray[$count][0] = $ListViewItems[$x][1] $createarray[$count][1] = $ListViewItems[$x][2] $count += 1 ;~ _ArrayDisplay($createarray) EndIf Next If $fax_array[0] > 0 Then _ArrayDisplay($fax_array, "These orders could not be emailed") EndIf WinActivate("SAM Order Entry") ;~ GUICtrlSetState($CreateOrders_btn, $GUI_ENABLE) ;~ GUICtrlSetState($RemoveItem_btn, $GUI_ENABLE) GUICtrlSetState($Item_Number_Input, $GUI_ENABLE) GUICtrlSetState($Quantity_Input, $GUI_ENABLE) GUICtrlSetState($Shop_Combo, $GUI_ENABLE) ;~ GUICtrlSetState($GetLastVend_btn, $GUI_ENABLE) Case $GetLastVend_btn GUICtrlSetState($CreateOrders_btn, $GUI_DISABLE) GUICtrlSetState($RemoveItem_btn, $GUI_DISABLE) GUICtrlSetState($AddItem_btn, $GUI_DISABLE) GUICtrlSetState($Item_Number_Input, $GUI_DISABLE) GUICtrlSetState($Quantity_Input, $GUI_DISABLE) GUICtrlSetState($Shop_Combo, $GUI_DISABLE) GUICtrlSetState($GetLastVend_btn, $GUI_DISABLE) For $x = 0 To UBound($ListViewItems) - 1 If $ListViewItems[$x][4] = "Need" Then GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & "Getting Last Vendor...") $lastvend = Get_Last_Vendor_Ordered($ListViewItems[$x][1]) If $lastvend = False Then $lastvend = "Unknown" EndIf $ListViewItems[$x][4] = $lastvend GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4]) If $lastvend = "Unknown" Then GUICtrlSetBkColor($ListViewItems[$x][0], (0xFF0000)) ;~ GUICtrlSetData($ListViewItems[$x][0], $ListViewItems[$x][1] & ": Cannot find vendor, enter order manually" & "|" & $ListViewItems[$x][2] & "|" & $ListViewItems[$x][3] & "|" & $ListViewItems[$x][4]) ;~ GUICtrlSetTip($ListViewItems[$x][0], "Cannot find vendor, must enter order manually.") Else GUICtrlSetBkColor($ListViewItems[$x][0], (0x00FF00)) EndIf EndIf Next GUICtrlSetState($CreateOrders_btn, $GUI_ENABLE) GUICtrlSetState($RemoveItem_btn, $GUI_ENABLE) GUICtrlSetState($Item_Number_Input, $GUI_ENABLE) GUICtrlSetState($Quantity_Input, $GUI_ENABLE) GUICtrlSetState($Shop_Combo, $GUI_ENABLE) GUICtrlSetState($GetLastVend_btn, $GUI_ENABLE) Case $GUI_EVENT_CLOSE GUIDelete($Form1_1_1) Return EndSwitch WEnd EndFunc ;==>Create_Item_Array You don't even need to look at that, but I figured I'd better put it in there because someone will say "THERE IS CODE MISSING, HOW AM I SUPPOSED TO HELP YOU". Now, part of that function calls the "Get_Last_Vendor_Ordered" function below. This will loop for each $partnum passed to it. THIS IS WHERE THE ERROR IS OCCURRING, SOMEWHERE IN HERE: Func Get_Last_Vendor_Ordered($partnum) Open_Filters() Filters_Select_Closed() Filters_Set_PartNumber($partnum) Filters_Submit() $result = Filters_Get_Results(1) If StringLen($result) < 1 Then $result = False EndIf Return $result EndFunc ;==>Get_Last_Vendor_Ordered Now, the functions that function calls: Func Open_Filters() _IELoadWaitTimeout(5000) ;~ _IENavigate($Location_Frame, $main_url & $Operations_PurchaseOrders_url) EY_Navigate("Purchase Orders") $oPO_Form = _IEFormGetObjByName($Location_Frame, "purchaseOrderForm") ;~ While 1 ;~ $oPO_Form = _IEFormGetObjByName($Location_Frame, "purchaseOrderForm") ;~ If $oPO_Form = 0 Then ;~ _IENavigate($Location_Frame, $main_url & $Operations_PurchaseOrders_url) ;~ Else ;~ Sleep(100) ;~ ExitLoop ;~ EndIf ;~ WEnd $filterstoggle = _IEGetObjById($oPO_Form, "filtersToggle") _IEAction($filterstoggle, "click") EndFunc ;==>Open_Filters Func Filters_Select_Closed() $oFilter_Form = _IEFormGetObjByName($Location_Frame, "filterForm") $select = _IEFormElementGetObjByName($oFilter_Form, "sFilterStatus") _IEFormElementOptionSelect($select, "Closed", 1, "byText", 1) EndFunc ;==>Filters_Select_Closed Func Filters_Set_PartNumber($number) $oFilter_Form = _IEFormGetObjByName($Location_Frame, "filterForm") $input = _IEFormElementGetObjByName($oFilter_Form, "sFilterPartNumber") _IEFormElementSetValue($input, $number) EndFunc ;==>Filters_Set_PartNumber Func Filters_Submit() $oFilter_Form = _IEFormGetObjByName($Location_Frame, "filterForm") $elements = _IEFormElementGetCollection($oFilter_Form) For $element In $elements If StringInStr($element.value, "Apply Filters") > 0 Then $button = $element EndIf Next _IEAction($button, "click") _IELoadWait($Location_Frame) EndFunc ;==>Filters_Submit Func Filters_Get_Results($mode = 1) ;modes: ;1 = last ordered ;2 = most common Local $x = 0 Local $count = 0 Local $t = 0 Local $FilterResults_Array[1][6] _IELoadWait($Location_Frame) Local $shtml = StringSplit(_IEDocReadHTML($Location_Frame), Chr(10)) For $x = 0 To UBound($shtml) - 1 $line = $shtml[$x] ;================= Below reads the temp file into the $Results_Array ================= ;================= $Results_Array[0] = PO Number ================= ;================= $Results_Array[1] = HTML Control for PO ================= ;================= $Results_Array[2] = Vendor ================= ;================= $Results_Array[4] = Qutantity Rec'd ================= ;================= $Results_Array[5] = Total Quantity ================= If StringInStr($line, "<TD class=whiteBordered><INPUT id=") = 0 Then $x = $x + 1 ElseIf StringInStr($line, "<TD class=whiteBordered><INPUT id=") > 0 Then If UBound($FilterResults_Array) < $count + 1 Then ReDim $FilterResults_Array[$count + 1][6] $FilterResults_Array[$count][1] = $line $temp = StringStripWS(StringReplace($shtml[$x + 1], "<TD class=whiteBordered><NOBR>", ""), 3) $temp = StringReplace($temp, "&", "&") $FilterResults_Array[$count][2] = StringReplace($temp, "</NOBR></TD>", "") $temp = StringStripWS(StringReplace($shtml[$x + 2], "<TD class=whiteBordered><NOBR>", ""), 3) $FilterResults_Array[$count][0] = Int(StringReplace($temp, "</NOBR></TD>", "")) $temp = StringStripWS(StringReplace($shtml[$x + 3], "<TD class=whiteBordered>", ""), 3) $FilterResults_Array[$count][3] = StringReplace($temp, "</TD>", "") $temp = StringStripWS(StringReplace($shtml[$x + 4], "<TD class=whiteBordered align=right>", ""), 3) $t = StringInStr($temp, "<") $temp = StringSplit(StringLeft($temp, $t - 1), "/") $FilterResults_Array[$count][4] = $temp[1] $FilterResults_Array[$count][5] = $temp[2] $x = $x + 6 $count = $count + 1 EndIf Next If $mode = 1 Then _ArraySort($FilterResults_Array, 0, 0, 0, 0) Return $FilterResults_Array[UBound($FilterResults_Array) - 1][2] ;~ ElseIf $mode = 2 Then ;~ _ArraySort($Results_Array, 0, 0, 0, 2) ;~ $tempvendor = $Results_Array[0][2] ;~ Local $SortingArray[1][2] ;~ Local $vendors = 0 ;~ For $x = 0 to UBound($Results_Array) - 1 ;~ If $Results_Array[$x][2] = Not $tempvendor Then ;~ $SortingArray[$vendors][0] = $tempvendor ;~ $SortingArray[$vendors][1] = $x + 1 EndIf EndFunc ;==>Filters_Get_Results Func EY_Navigate($page) $page2 = StringLower(StringStripWS($page, 8)) ;====MY YARD==== $viewyard = _IEGetObjById($oEY_MAIN, "O1") $addcar = _IEGetObjById($oEY_MAIN, "O2") $addmultiplecars = _IEGetObjById($oEY_MAIN, "O3") $search = _IEGetObjById($oEY_MAIN, "O4") ;====OPERATIONS==== $purchaseorders = _IEGetObjById($oEY_MAIN, "O5") $customerassignment = _IEGetObjById($oEY_MAIN, "O6") $repairestimates = _IEGetObjById($oEY_MAIN, "O7") $workorders = _IEGetObjById($oEY_MAIN, "O8") $pickinventory = _IEGetObjById($oEY_MAIN, "O9") $releaseforbilling = _IEGetObjById($oEY_MAIN, "O10") $handheldimages = _IEGetObjById($oEY_MAIN, "O11") $relieveinventory = _IEGetObjById($oEY_MAIN, "O12") $page2 = Eval($page2) _IEAction($page2, "click") $pathbar = _IEGetObjById($oEY_MAIN, "pathbar") While(StringInStr($pathbar.innerhtml, "Loading") <= 0) Sleep(100) WEnd While(StringInStr($pathbar.innerhtml, $page) <= 0) Sleep(100) WEnd _IELoadWait($Location_Frame) EndFunc I still don't understand how this causes an issue with "WEnd" in the IE script. Especially when this script has worked for over 2 years until I updated AutoIt last week.
-
Please see image below. I have a program that has worked reliable for some time. I just updated Autoit, and now my script will randomly error out as it is manipulating Internet Explorer. The error makes little sense to me (screen attached) Does anyone know what is going on?
-
Okay, I've been trying to see if I can get anywhere with the link you gave me, water. This is what I have so far... Below gives a COM error when trying to set the height (unspecified error, number 80020009) : $oExcelDoc.Application.CommandBars("Ribbon").Controls(1).Height = 4 Below gives no error, but doesn't actually do anything. Note: Using a MsgBox prompt, I can actually read this information, as well as the height info above, I just can't change it... $oExcelDoc.Application.CommandBars("Ribbon").Enabled = False $oExcelDoc.Application.CommandBars("Ribbon").Visible = False Below gives me a COM error, stating that "The parameter is incorrect" (number 80020009 again): $oExcelDoc.Application.CommandBars.ExecuteMso("MinimizeRibbon") Below just showing the MsgBoxes that I used to see if I was indeed accessing the correct parameters: MsgBox(0, "", $oExcelDoc.Application.CommandBars("Ribbon").Controls(1).Height) MsgBox(0, "", $oExcelDoc.Application.CommandBars("Ribbon").Visible) Anyone able to expand on this, maybe show me where I'm going wrong?
-
OK, for anyone who ends up on this page with the same issue, I reposted my question
-
I'm trying to add an excel object into a GUI for the purpose of using it for graphing functions. I'm currently stuck at the following example set of code, as I cannot seem to remove the menu that comes from Excel (note, you will need an excel file to open with this): #include <GUIConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; ; Embedding an Excel document inside an AutoIt GUI ; ; Limitations: ; ; 1. Integrating the GUI Menu with the Objects Menu does not work. ; (they have seperate menu bars) ; ; Initialize my error handler $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") ;~ $FileName=@ScriptDir & "\Worksheet.xls" $FileName = FileOpenDialog("Pick a file", @ScriptDir, "Excel Files (*.xls;*.xlsx)") if not FileExists($FileName) then Msgbox (0,"Excel File Test","Can't run this test, because it requires an Excel file in "& $FileName) Exit endif $oExcelDoc = ObjGet($FileName) ; Get an Excel Object from an existing filename if IsObj($oExcelDoc) then GUICreate ( "Embedded ActiveX Test", 640, 580, (@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_MINIMIZEBOX +$WS_SYSMENU + $WS_CLIPCHILDREN) $GUI_ActiveX = GUICtrlCreateObj ( $oExcelDoc, 1, 95 , 400 , 300 ) For $Bar In $oExcelDoc.CommandBars If $Bar.Enabled = True Then $Bar.Enabled = False If $Bar.Visible = True Then $Bar.Visible = False Next $oExcelDoc.Application.DisplayFormulaBar = False $oExcelDoc.Application.CommandBars("Shadow Settings").Visible = False $oExcelDoc.Application.DisplayScrollBars = True $oExcelDoc.Application.DisplayStatusBar = False GUISetState (@SW_SHOW) ;Show GUI ; GUI Message loop While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE;or $msg = $GUI_FileExit ExitLoop EndSelect Wend GUIDelete () ; Don't forget to close your workbook, otherwise Excel will stay in memory after the script exits ! $oExcelDoc.Close (0) ; Close the Excel workbook - Save prompt will not open EndIf Exit ; This is my custom error handler Func MyErrFunc() $HexNumber=hex($oMyError.number,8) Msgbox(0,"AutoItCOM Test","We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & $HexNumber & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) SetError(1) ; to check for after this function returns Endfunc Is there any way to remove the menu bar? All I search seem to still have this issue unresolved.
-
Still having the same issue with Excel 2007 - the menu bar stubbornly stays visible on top of the GUI. Any suggestions?