Leaderboard
Popular Content
Showing content with the highest reputation on 10/05/2016 in all areas
-
Hello World! (always wanted to say that) Wrote this when I needed low-level access to unmountable parts of a physical drive. The resulting UDF is BuildPartitionTable, and takes as single argument a designated physical drive ID, for example: BuildPartitionTable(".physicaldrive0") for your first harddisk. This UDF scans a physical drive's partition table to fill three partition-related arrays: partition_table extracted from the MBR and its linked list(s) allocation_table entire disk mapping volumes_table subset of $allocation_table with volumes only It does NOT alter your data or drives; it just reads and reports. BuildPartitionTable.v1.1.zip (AutoIt 3.3.12-1 compliant updated version, with small example) You can use the UDF's output for low-level drive I/O (use at your own risk!), for example (NB code for this is not included): identify unallocated regions for space optimisation or hidden storage (listed in allocation table array) resize/remove existing partitions change which single partition is primary (i.e., used for booting) change an existing partition's type add new partitions of any type hide/unhide logical volumes (simply set/reset bit4 of a volume's Partition_Type in its (E)MBR partition entry) It should in theory be able to handle many types of MBR partition tables, not just Microsoft-approved ones. If you're going to analyse Linux MBRs or ancient tech, you may want to replace internal calls to _Partition_type_string() (DOS/Microsoft only) to its internal alternative _Partition_Anytype_string(), which supports many types I'd never heard of before (but results can be unreliable). Furthermore, you may be puzzled by references in the annotations to my "FATsuite UDF". Please follow the link in my signature if you wish to know more. Should the script crash or produce wrong results at your end, there's unfortunately not much I can do at this end, since the problem is likely related to the specific hardware you're testing. Of course, I'll try to fix whatever bugs I am able to reproduce... Hope it helps! RT1 point
-
Hi. First of all, the return seems to be XML, not HTML. The current return you get is HTML because IE tries to show you the return visually with styling in HTML. I would advise not using IE. It's slower than just getting the return with something like InetGet. Also as mentioned it's not formatted by IE. I've made a small example, showing one way to do it $oHTTP = ObjCreate("WinHttp.WinHttpRequest.5.1") $oHTTP.Open("GET", "http://api.napiarfolyam.hu/?bank=mnb&valuta=eur&datum=20160601&datumend=20160603", False) $oHTTP.Send() $sXML = $oHTTP.responseText $oXML = ObjCreate("Microsoft.XMLDOM") $oXML.loadXML( $sXML ) $oXML_Nodes = $oXML.SelectNodes("./arfolyamok/deviza/item") For $i=0 To $oXML_Nodes.Length-1 $oXML_Node = $oXML_Nodes.Item($i) $oXML_Node_Bank = $oXML_Node.SelectNodes("./bank") $oXML_Node_Bank = $oXML_Node_Bank.Length>0?$oXML_Node_Bank.Item(0).text:"" $oXML_Node_Datum = $oXML_Node.SelectNodes("./datum") $oXML_Node_Datum = $oXML_Node_Datum.Length>0?$oXML_Node_Datum.Item(0).text:"" $oXML_Node_Penznem = $oXML_Node.SelectNodes("./penznem") $oXML_Node_Penznem = $oXML_Node_Penznem.Length>0?$oXML_Node_Penznem.Item(0).text:"" $oXML_Node_Kozeps = $oXML_Node.SelectNodes("./kozep") $oXML_Node_Kozep01 = $oXML_Node_Kozeps.Length>0?$oXML_Node_Kozeps.Item(0).text:"" $oXML_Node_Kozep02 = $oXML_Node_Kozeps.Length>1?$oXML_Node_Kozeps.Item(1).text:"" ConsoleWrite( "Match [" & StringFormat("%02i", $i+1) & "]:"&@CRLF& _ @TAB&"Bank: "&@TAB&$oXML_Node_Bank&@CRLF& _ @TAB&"Datum: "&@TAB&$oXML_Node_Datum&@CRLF& _ @TAB&"Penznem: "&@TAB&$oXML_Node_Penznem&@CRLF& _ @TAB&"Kozep01: "&@TAB&$oXML_Node_Kozep01&@CRLF& _ @TAB&"Kozep02: "&@TAB&$oXML_Node_Kozep02&@CRLF _ ) Next Sources: DOM Reference, XPath Syntax and WinHttpRequest object Let me know if you have questions, I'm happy to answer1 point
-
U.S. English is good to go. I've named this project "Date_Czar_Hard" because i am witty AF1 point
-
Check "ScriptoMatic" in the Example Scripts forum. This tool generates AutoIt code for you to query WMI.1 point
-
variables
ZeroByDevide reacted to l3ill for a topic
That or this... was already all typed out when you posted Bert This code works on my PC Local $rndSleep = Int (Random(180000,240000,1000)) MsgBox(0, "NaaaNuuu", "This message box will show the sleeptime after closing the tabs, you got " & $rndSleep & " seconds left.", $rndSleep) Please use the <> in the menu when posting code.1 point -
#Include <Array.au3> $text = "https://www.autoitscript.com/forum/" & @crlf& _ "http://autoitscript.test.com/" $aStr = StringRegExp($text, 'https?://(?:www.)?([^.]+)', 3) _ArrayDisplay($aStr)1 point
-
[SOLVED] Stop using #requireadmin?
coffeeturtle reacted to legend for a topic
Hi, My main script is using #requireadmin, I'm launching a command line tool from my script that also is evalated with admin rights, since i ran it from a script that was evalated. Is there any possible way to run the command line tool from my script without evalated rights, without removing requireadmin? I don't wish to use runas, as I don't wanna store any credentials. EDIT: Found the answer here : https://sites.google.com/site/ascend4ntscode/runwithreducedprivileges _RunWithReducedPrivileges1 point -
Edit: final solution: #include <GUIConstantsEx.au3> #include <GuiScrollBars.au3> #include <StructureConstants.au3> #include <WindowsConstants.au3> #AutoIt3Wrapper_AU3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 Global Const $iGUI_W = 600 Global Const $iGUI_H = 450 Example() Func Example() Local $hGUIMsg, $hGUI, $hGui2 $hGUI = GUICreate("ScrollBar Example", $iGUI_W, $iGUI_H) GUISetBkColor(0xFEDCBA) $hGui2 = GUICreate("Child GUI", $iGUI_W, 70, 0, 0, $WS_CHILD, $WS_EX_CLIENTEDGE, $hGUI) For $i = 0 To 60 GUICtrlCreateLabel($i, $i * 20, 10) Next GUISetState(@SW_SHOW) GUIRegisterMsg($WM_HSCROLL, "WM_HSCROLL") _GUIScrollBars_Init($hGui2,$iGUI_W*2,0) GUISetState(@SW_SHOW,$hGUI) While 1 $hGUIMsg = GUIGetMsg() Switch $hGUIMsg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd Exit EndFunc ;==>Example Func WM_HSCROLL($hWnd, $iMsg, $wParam, $lParam) #forceref $iMsg, $lParam Local $iScrollCode = BitAND($wParam, 0x0000FFFF) Local $iIndex = -1, $iCharX, $iPosX Local $iMin, $iMax, $iPage, $iPos, $iTrackPos For $x = 0 To UBound($__g_aSB_WindowInfo) - 1 If $__g_aSB_WindowInfo[$x][0] = $hWnd Then $iIndex = $x $iCharX = $__g_aSB_WindowInfo[$iIndex][2] ExitLoop EndIf Next If $iIndex = -1 Then Return 0 ; ; Get all the horizontal scroll bar information Local $tSCROLLINFO = _GUIScrollBars_GetScrollInfoEx($hWnd, $SB_HORZ) $iMin = DllStructGetData($tSCROLLINFO, "nMin") $iMax = DllStructGetData($tSCROLLINFO, "nMax") $iPage = DllStructGetData($tSCROLLINFO, "nPage") ; Save the position for comparison later on $iPosX = DllStructGetData($tSCROLLINFO, "nPos") $iPos = $iPosX $iTrackPos = DllStructGetData($tSCROLLINFO, "nTrackPos") #forceref $iMin, $iMax Switch $iScrollCode Case $SB_LINELEFT ; user clicked left arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos - 1) Case $SB_LINERIGHT ; user clicked right arrow DllStructSetData($tSCROLLINFO, "nPos", $iPos + 1) Case $SB_PAGELEFT ; user clicked the scroll bar shaft left of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos - $iPage) Case $SB_PAGERIGHT ; user clicked the scroll bar shaft right of the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iPos + $iPage) Case $SB_THUMBTRACK ; user dragged the scroll box DllStructSetData($tSCROLLINFO, "nPos", $iTrackPos) EndSwitch ; // Set the position and then retrieve it. Due to adjustments ; // by Windows it may not be the same as the value set. DllStructSetData($tSCROLLINFO, "fMask", $SIF_POS) _GUIScrollBars_SetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) _GUIScrollBars_GetScrollInfo($hWnd, $SB_HORZ, $tSCROLLINFO) ;// If the position has changed, scroll the window and update it $iPos = DllStructGetData($tSCROLLINFO, "nPos") If ($iPos <> $iPosX) Then _GUIScrollBars_ScrollWindow($hWnd, $iCharX * ($iPosX - $iPos), 0) Return $GUI_RUNDEFMSG EndFunc ;==>WM_HSCROLL1 point
-
passing a pointer to a child process via command line
Muhammad_Awais_Sharif reacted to trancexx for a topic
No, it's not. It's loaded for each process. Physical memory is one thing and virtual another. Yo have some insights at https://msdn.microsoft.com/en-us/library/windows/desktop/aa366785(v=vs.85).aspx1 point -
AutoIt allows you to get the DPI of the screen, which you can use to move the "map" around according to each user screen. Hope that helps. Edit: _WinAPI_GetThemeSysSize may be what I was referring to. Again, really hope this helps.1 point
-
no regex needed, just two splits #include<array.au3> ;~ $string = "http://test.1sthostname.com/whatever" ;~ $string = "http://test2.2ndhostname2.net" $string = "http://3test.3rdhostname.info/whomever" ;~ $string = "http://4test.hostnumber4.xxx/wtfever" ;~ $string = "http://test.hostname.google/TLDwtfbbq/forever" $aStringSplit1 = stringsplit($string , "/" , 2) _ArrayDelete($aStringSplit1 , ubound($aStringSplit1) - 1) $aStringSplit2 = stringsplit($aStringSplit1[2] , "." , 2) _ArrayDelete($aStringSplit2 , ubound($aStringSplit2) - 1) msgbox(0 , '' , _ArrayToString($aStringSplit2 , "."))1 point
-
Post an example of your test file...1 point
-
Parts / Inventory / Database Manager
coffeeturtle reacted to Damein for a topic
Hey, wasn't quite sure what to call it on here so we'll go with that, lol. It's pretty simple but pretty efficient IMO and is going to help me out a lot. When I finish a job I have to present all the part numbers and the serial numbers of whatever I work on. Each facility is different but I can load a database and have it all in one easy location. It started out as something I just made for myself but turned into something more professional and universal. The Listviews and INI's can be pretty much changed to whatever is needed for anything so I thought I'd share. Thanks! Images So when you click on the "Manage Database" button it requests a folder with stored Databases. If the folder contains no Parts/Equipment INI's it will automatically create them. The rest is pretty self-explanatory. Sources #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=Images\Icon.ico #AutoIt3Wrapper_Compression=0 #AutoIt3Wrapper_Res_Fileversion=1.3.0.0 #AutoIt3Wrapper_Res_LegalCopyright=R.S.S. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #AutoIt3Wrapper_Add_Constants=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** ; *** Start added by AutoIt3Wrapper *** ; *** End added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> #include <Misc.au3> #include <EditConstants.au3> #include <MsgBoxConstants.au3> #include <Excel.au3> #include <ListViewConstants.au3> #include <GuiListView.au3> #include <Array.au3> #include <WindowsConstants.au3> #include <File.au3> #include "SearchWorkOrdersModule.au3" #include "ManageDatabaseModule.au3" Local $hDLL = DllOpen("user32.dll") Opt("GUIOnEventMode", 1) Opt("WinTitleMatchMode", 3) Global $CurrentGUI, $MainGUI, $ManageGUI, $ManagePartsGUI, $ManageUnitsGUI, $DatabasePath, $WorkOrdersGUI, $ViewWorkOrdersGUI _CreateMainGUI() Func _CreateMainGUI() $CurrentGUI = "Main" $MainGUI = GUICreate("Waddell Power Database Manager", 400, 250) GUISetOnEvent($GUI_EVENT_CLOSE, "_Exit") GUISetBkColor(0xFFFFFF) $ManageDatabasesButton = GUICtrlCreateButton("Manage Databases", 10, 90, 185, 60) GUICtrlSetOnEvent(-1, "_CreateManageGUI") GUICtrlSetFont(-1, 15) $SearchWorkOrdersButton = GUICtrlCreateButton("Search Work Orders", 205, 90, 185, 60) GUICtrlSetOnEvent(-1, "_CreateWorkOrdersGUI") GUICtrlSetFont(-1, 14.5) $ExitButton = GUICtrlCreateButton("Exit", 110, 170, 185, 60) GUICtrlSetOnEvent(-1, "_Exit") GUICtrlSetFont(-1, 15) GUICtrlCreateLabel("© RS Software", 335, 240, 200) GUICtrlSetFont(-1, 7) GUICtrlCreateLabel("Version 1.2", 1, 240, 200) GUICtrlSetFont(-1, 7) GUICtrlCreatePic(@ScriptDir & "\Images\Logo.bmp", 50, 5, 300, 70) GUISetState() EndFunc ;==>_CreateMainGUI Func _CloseGUI() If $CurrentGUI = "Manage" Then GUIDelete($ManageGUI) GUISetState(@SW_ENABLE, $MainGUI) Sleep(100) WinActivate($MainGUI) $CurrentGUI = "Main" EndIf If $CurrentGUI = "Parts" Then GUIDelete($ManagePartsGUI) GUISetState(@SW_ENABLE, $ManageGUI) Sleep(100) WinActivate($ManageGUI) $CurrentGUI = "Manage" EndIf If $CurrentGUI = "Units" Then GUIDelete($ManageUnitsGUI) GUISetState(@SW_ENABLE, $ManageGUI) Sleep(100) WinActivate($ManageGUI) $CurrentGUI = "Manage" EndIf If $CurrentGUI = "Work Orders" Then GUIDelete($WorkOrdersGUI) GUISetState(@SW_ENABLE, $MainGUI) Sleep(100) WinActivate($MainGUI) $CurrentGUI = "Main" EndIf If $CurrentGUI = "View Work Orders" Then GUIDelete($ViewWorkOrdersGUI) GUISetState(@SW_ENABLE, $MainGUI) Sleep(100) WinActivate($MainGUI) $CurrentGUI = "Main" EndIf EndFunc ;==>_CloseGUI Func _Exit() Exit EndFunc ;==>_Exit While 1 Sleep(10) WEnd ManageDatabaseModule Global $CurrentGUI, $ManageGUI, $ListView, $ManagePartsGUI, $ManageUnitsGUI, $DatabasePath, $SearchPartsInput, $SearchEquipmentInput, $PartList Global $g_bSortSense = True Func _CreateManageGui() $DatabasePath = FileSelectFolder("Select Folder...", @MyDocumentsDir) If $DatabasePath = "" Then MsgBox(48, "Error", "No database selected, cancelling operation!") Else GUISetState(@SW_DISABLE, $MainGui) $CurrentGUI = "Manage" $ManageGUI = GUICreate("Manage Database's", 400, 250) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGUI") GUISetBkColor(0xFFFFFF) $ManagePartsButton = GUICtrlCreateButton("Manage Parts", 10, 90, 185, 60) GUICtrlSetOnEvent(-1, "_ManageParts") GUICtrlSetFont(-1, 15) $ManageUnitsButton = GUICtrlCreateButton("Manage Equipment", 205, 90, 185, 60) GUICtrlSetOnEvent(-1, "_ManageEquipment") GUICtrlSetFont(-1, 15) $ExitButton = GUICtrlCreateButton("Close", 100, 180, 185, 60) GUICtrlSetOnEvent(-1, "_CloseGUI") GUICtrlSetFont(-1, 15) GUICtrlCreatePic(@ScriptDir & "\Images\Logo.bmp", 50, 5, 300, 70) GUISetState() EndIf EndFunc ;==>_CreateManageGui Func _ManageParts() GUISetState(@SW_DISABLE, $ManageGUI) $CurrentGUI = "Parts" If FileExists($DatabasePath & "/Parts Database.ini") Then $ReadData = IniReadSection($DatabasePath & "/Parts Database.ini", "Parts") Else MsgBox(0, "Database Created", "No database was found, creating new database!") FileCopy(@ScriptDir & "/Data/Default Parts Database.ini", $DatabasePath & "/Parts Database.ini") FileCopy(@ScriptDir & "/Data/Default Equipment Database.ini", $DatabasePath & "/Equipment Database.ini") $ReadData = IniReadSection($DatabasePath & "/Parts Database.ini", "Parts") EndIf $ManagePartsGUI = GUICreate("Parts", 600, 660) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGUI") GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("Search Parts", 12, 20, 130, 40) GUICtrlSetFont(-1, 16) $SearchPartsInput = GUICtrlCreateInput("", 150, 18, 250, 30) GUICtrlSetFont(-1, 16) $SearchPartsButton = GUICtrlCreateButton("Search", 450, 5, 100, 50) GUICtrlSetOnEvent(-1, "_SearchParts") GUICtrlSetFont(-1, 16) $ListView = GUICtrlCreateListView("Part Number|Description|Product Line|Bin Number", 10, 60, 580, 500, $LVS_SORTASCENDING) _GUICtrlListView_SetColumnWidth(-1, 0, 200) _GUICtrlListView_SetColumnWidth(-1, 1, 500) _GUICtrlListView_SetColumnWidth(-1, 2, 200) _GUICtrlListView_SetColumnWidth(-1, 3, 200) For $i = 1 To UBound($ReadData) - 1 GUICtrlCreateListViewItem($ReadData[$i][0] & "|" & $ReadData[$i][1], $ListView) Next $AddNewPartButton = GUICtrlCreateButton("Add", 10, 565, 220, 40) GUICtrlSetOnEvent(-1, "_AddPart") GUICtrlSetFont(-1, 16) $EditPartButton = GUICtrlCreateButton("Edit", 370, 565, 220, 40) GUICtrlSetOnEvent(-1, "_EditPart") GUICtrlSetFont(-1, 16) $RemovePartButton = GUICtrlCreateButton("Remove", 10, 615, 220, 40) GUICtrlSetOnEvent(-1, "_RemovePart") GUICtrlSetFont(-1, 16) $CloseButton = GUICtrlCreateButton("Close", 370, 615, 220, 40) GUICtrlSetOnEvent(-1, "_CloseGUI") GUICtrlSetFont(-1, 16) $ExportButton = GUICtrlCreateButton("Export", 250, 590, 100, 50) GUICtrlSetOnEvent(-1, "_Export") GUICtrlSetFont(-1, 16) GUISetState() GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") EndFunc ;==>_ManageParts Func _Export() SplashTextOn("Exporting...", "Exporting... please wait...", 300, 50, Default, Default, 33) Local $oExcel = _Excel_Open() If @error Then Exit MsgBox(16, "Excel UDF: _Excel_BookOpenText Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) ; ***************************************************************************** ; Open a text file as delimited, separator = |, pass fieldinfo and set ; DecimalSeparator and ThousandsSeparator. ; ***************************************************************************** _FileReadToArray($DatabasePath & "/Parts Database.ini", $PartList) FileDelete(@TempDir & "/Temp Part Database.txt") FileWrite(@TempDir & "/Temp Part Database.txt", "Part Number|Part Description|Product Line|Bin Number|Count" & @CRLF) For $i = 2 To UBound($PartList) - 1 If StringInStr($PartList[$i], "=") Then $PartList[$i] = StringReplace($PartList[$i], "=", "|") EndIf FileWrite(@TempDir & "/Temp Part Database.txt", $PartList[$i] & @CRLF) Next Local $sTextFile = @TempDir & "/Temp Part Database.txt" $oWorkbook = _Excel_BookOpenText($oExcel, $sTextFile, Default, $xlGeneralFormat, Default, Default, "|") If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_BookOpenText Example 1", "Error opening '" & $sTextFile & "'." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Exit Else EndIf SplashOff() EndFunc ;==>_Export Func _AddPart() GUISetState(@SW_DISABLE, $ManagePartsGUI) $Stop = 0 $NewPartNumber = InputBox("Add Part", "Please input the part number you wish to add.") If $NewPartNumber = "" Then MsgBox(48, "Error", "No part number input, cancelling addition of a new part!") $Stop = 1 EndIf If $Stop = 0 Then $NewPartDescription = InputBox("Add Part", "Please input the part description you wish to add.") If $NewPartDescription = "" Then MsgBox(48, "Error", "No part description was inputted, cancelling addition of a new part!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $NewPartProductLine = InputBox("Add Part", "Please input the product line associated with this part that you wish to add.") If $NewPartProductLine = "" Then MsgBox(48, "Error", "No product line was inputted, cancelling addition of a new part!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $NewPartBin = InputBox("Add Part", "Please input the part bin number you wish to add.") If $NewPartBin = "" Then MsgBox(48, "Error", "No part bin number was inputted, cancelling addition of a new part!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $CheckMsgBox = MsgBox(4, "Add Part", "Are you sure you wish to add the following part?" & @CRLF & @CRLF & "Part Number: " & $NewPartNumber & @CRLF & "Part Description: " & $NewPartDescription & @CRLF & "Product Line: " & $NewPartProductLine & @CRLF & "Bin Number: " & $NewPartBin) If $CheckMsgBox = 6 Then IniWrite($DatabasePath & "/Parts Database.ini", "Parts", $NewPartNumber, $NewPartDescription & "|" & $NewPartProductLine & "|" & $NewPartBin) MsgBox(0, "Add Part", "Part number: " & $NewPartNumber & " has been added!") GUICtrlCreateListViewItem($NewPartNumber & "|" & $NewPartDescription & "|" & $NewPartProductLine & "|" & $NewPartBin, $ListView) Else MsgBox(48, "Add Part", "You have chosen to cancel the addition of a new part!") EndIf EndIf GUISetState(@SW_ENABLE, $ManagePartsGUI) Sleep(100) WinActivate($ManagePartsGUI) EndFunc ;==>_AddPart Func _EditPart() GUISetState(@SW_DISABLE, $ManagePartsGUI) $ListViewGetSelection = _GUICtrlListView_GetSelectionMark($ListView) $GetPartNumber = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 0) $GetPartDescription = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 1) $GetPartProductLine = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 2) $GetPartBin = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 3) If $GetPartNumber[3] = "" Then MsgBox(48, "Error", "No part was selected, cancelling operation!") Else $Stop = 0 $EditPartNumber = InputBox("Edit Part", "Please input a new part number or leave the part number the same.", $GetPartNumber[3]) If $EditPartNumber = "" Then MsgBox(48, "Error", "No part number input, cancelling edit of part!") $Stop = 1 EndIf If $Stop = 0 Then $EditPartDescription = InputBox("Edit Part", "Please input a new part description or leave the description the same.", $GetPartDescription[3]) If $EditPartDescription = "" Then MsgBox(48, "Error", "No part description was inputted, cancelling edit of part!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $EditPartProductLine = InputBox("Edit Part", "Please input a new product line associated with this part that you wish to edit or leave it the same.", $GetPartProductLine[3]) If $EditPartProductLine = "" Then MsgBox(48, "Error", "No product line was inputted, cancelling edit of part!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $EditPartBin = InputBox("Edit Part", "Please input a new part bin number or leave the number the same.", $GetPartBin[3]) If $EditPartDescription = "" Then MsgBox(48, "Error", "No part bin number was inputted, cancelling edit of part!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $CheckMsgBox = MsgBox(4, "Edit Part", "Are you sure you wish to edit the following part?" & @CRLF & @CRLF & "Part Number: " & $EditPartNumber & @CRLF & "Part Description: " & $EditPartDescription & @CRLF & "Product Line: " & $EditPartProductLine & @CRLF & "Bin Number: " & $EditPartBin) If $CheckMsgBox = 6 Then IniDelete($DatabasePath & "/Parts Database.ini", "Parts", $GetPartNumber[3]) IniWrite($DatabasePath & "/Parts Database.ini", "Parts", $EditPartNumber, $EditPartDescription & "|" & $EditPartProductLine & "|" & $EditPartBin) MsgBox(0, "Edit Part", "Part number: " & $EditPartNumber & " has been changed!") _GUICtrlListView_DeleteItem($ListView, $ListViewGetSelection) GUICtrlCreateListViewItem($EditPartNumber & "|" & $EditPartDescription & "|" & $EditPartProductLine & "|" & $EditPartBin, $ListView) Else MsgBox(48, "Edit Part", "You have chosen to cancel the edit of the part!") EndIf EndIf EndIf GUISetState(@SW_ENABLE, $ManagePartsGUI) Sleep(100) WinActivate($ManagePartsGUI) EndFunc ;==>_EditPart Func _RemovePart() GUISetState(@SW_DISABLE, $ManagePartsGUI) $ListViewGetSelection = _GUICtrlListView_GetSelectionMark($ListView) $GetPartNumber = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 0) If $GetPartNumber[3] = "" Then MsgBox(48, "Error", "No part was selected, cancelling operation!") Else $CheckMsgBox = MsgBox(4, "Remove Part", "Are you sure you wish to remove the following part?" & @CRLF & @CRLF & $GetPartNumber[3]) If $CheckMsgBox = 6 Then _GUICtrlListView_DeleteItem($ListView, $ListViewGetSelection) IniDelete($DatabasePath & "/Parts Database.ini", "Parts", $GetPartNumber[3]) MsgBox(0, "Remove Part", "The part has been removed from the database!") Else MsgBox(48, "Remove Part", "You have chosen to cancel the removal of the part!") EndIf EndIf GUISetState(@SW_ENABLE, $ManagePartsGUI) Sleep(100) WinActivate($ManagePartsGUI) EndFunc ;==>_RemovePart Func _ManageEquipment() GUISetState(@SW_DISABLE, $ManageGUI) $CurrentGUI = "Units" If FileExists($DatabasePath & "/Equipment Database.ini") Then $ReadData = IniReadSection($DatabasePath & "/Equipment Database.ini", "Equipment") Else MsgBox(0, "Database Created", "No database was found, creating new database!") FileCopy(@ScriptDir & "/Data/Default Parts Database.ini", $DatabasePath & "/Parts Database.ini") FileCopy(@ScriptDir & "/Data/Default Equipment Database.ini", $DatabasePath & "/Equipment Database.ini") $ReadData = IniReadSection($DatabasePath & "/Equipment Database.ini", "Equipment") EndIf $ManageUnitsGUI = GUICreate("Equipment", 600, 660) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGUI") GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("Search Equipment", 12, 20, 170, 40) GUICtrlSetFont(-1, 16) $SearchEquipmentInput = GUICtrlCreateInput("", 200, 18, 250, 30) GUICtrlSetFont(-1, 16) $SearchEquipmentButton = GUICtrlCreateButton("Search", 480, 5, 100, 50) GUICtrlSetOnEvent(-1, "_SearchEquipment") GUICtrlSetFont(-1, 16) $ListView = GUICtrlCreateListView("Unit Number|Model Number|Serial Number", 10, 60, 580, 500, $LVS_SORTASCENDING) _GUICtrlListView_SetColumnWidth(-1, 0, 100) _GUICtrlListView_SetColumnWidth(-1, 1, 250) _GUICtrlListView_SetColumnWidth(-1, 2, 250) For $i = 1 To UBound($ReadData) - 1 GUICtrlCreateListViewItem($ReadData[$i][0] & "|" & $ReadData[$i][1], $ListView) Next $AddNewUnitButton = GUICtrlCreateButton("Add", 10, 565, 220, 40) GUICtrlSetOnEvent(-1, "_AddUnit") GUICtrlSetFont(-1, 16) $EditUnitButton = GUICtrlCreateButton("Edit", 370, 565, 220, 40) GUICtrlSetOnEvent(-1, "_EditUnit") GUICtrlSetFont(-1, 16) $RemoveUnitButton = GUICtrlCreateButton("Remove", 10, 615, 220, 40) GUICtrlSetOnEvent(-1, "_RemoveUnit") GUICtrlSetFont(-1, 16) $CloseButton = GUICtrlCreateButton("Close", 370, 615, 220, 40) GUICtrlSetOnEvent(-1, "_CloseGUI") GUICtrlSetFont(-1, 16) GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY") GUISetState() EndFunc ;==>_ManageEquipment Func _AddUnit() GUISetState(@SW_DISABLE, $ManageUnitsGUI) $Stop = 0 $NewUnitNumber = InputBox("Add Equipment", "Please input the unit number you wish to add.") If $NewUnitNumber = "" Then MsgBox(48, "Error", "No unit number input, cancelling addition of a new unit!") $Stop = 1 EndIf If $Stop = 0 Then $NewUnitModelNumber = InputBox("Add Equipment", "Please input the model number of this unit.") If $NewUnitModelNumber = "" Then MsgBox(48, "Error", "No model number was inputted, cancelling addition of a new unit!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $NewUnitBatterySerial = InputBox("Add Unit", "Please input the serial number with this unit.") If $NewUnitBatterySerial = "" Then MsgBox(48, "Error", "No serial number was inputted, cancelling addition of a new unit!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $CheckMsgBox = MsgBox(4, "Add Unit", "Are you sure you wish to add the following unit?" & @CRLF & @CRLF & "Unit Number: " & $NewUnitNumber & @CRLF & "Model Number: " & $NewUnitModelNumber & @CRLF & "Serial Number: " & $NewUnitBatterySerial) If $CheckMsgBox = 6 Then IniWrite($DatabasePath & "/Equipment Database.ini", "Equipment", $NewUnitNumber, $NewUnitModelNumber & "|" & $NewUnitBatterySerial) MsgBox(0, "Add Unit", "Unit number: " & $NewUnitNumber & " has been added!") GUICtrlCreateListViewItem($NewUnitNumber & "|" & $NewUnitModelNumber & "|" & $NewUnitBatterySerial, $ListView) Else MsgBox(48, "Add Unit", "You have chosen to cancel the addition of a new unit!") EndIf EndIf GUISetState(@SW_ENABLE, $ManageUnitsGUI) Sleep(100) WinActivate($ManageUnitsGUI) EndFunc ;==>_AddUnit Func _EditUnit() GUISetState(@SW_DISABLE, $ManageUnitsGUI) $ListViewGetSelection = _GUICtrlListView_GetSelectionMark($ListView) $GetUnitNumber = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 0) $GetUnitModelNumber = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 1) $GetUnitBatterySerial = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 2) $Stop = 0 If $GetUnitNumber[3] = "" Then MsgBox(48, "Error", "No unit was selected, cancelling operation!") Else $EditUnitNumber = InputBox("Edit Unit", "Please input the unit number you wish to edit.", $GetUnitNumber[3]) If $EditUnitNumber = "" Then MsgBox(48, "Error", "No unit number input, cancelling edit of the unit!") $Stop = 1 EndIf If $Stop = 0 Then $EditUnitModelNumber = InputBox("Edit Unit", "Please input the model number with this unit.", $GetUnitModelNumber[3]) If $EditUnitModelNumber = "" Then MsgBox(48, "Error", "No model number was inputted, cancelling edit of the unit!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $EditUnitBatterySerial = InputBox("Edit Unit", "Please input the serial number with this unit.", $GetUnitBatterySerial[3]) If $EditUnitBatterySerial = "" Then MsgBox(48, "Error", "No serial number was inputted, cancelling edit of the unit!") $Stop = 1 EndIf EndIf If $Stop = 0 Then $CheckMsgBox = MsgBox(4, "Edit Unit", "Are you sure you wish to edit the following Unit?" & @CRLF & @CRLF & "Unit Number: " & $EditUnitNumber & @CRLF & "Model Number: " & $EditUnitModelNumber & @CRLF & "Serial Number: " & $EditUnitBatterySerial) If $CheckMsgBox = 6 Then IniDelete($DatabasePath & "/Equipment Database.ini", "Equipment", $GetUnitNumber[3]) IniWrite($DatabasePath & "/Equipment Database.ini", "Equipment", $EditUnitNumber, $EditUnitModelNumber & "|" & $EditUnitBatterySerial) MsgBox(0, "Edit Unit", "Unit number: " & $EditUnitNumber & " has been changed!") _GUICtrlListView_DeleteItem($ListView, $ListViewGetSelection) GUICtrlCreateListViewItem($EditUnitNumber & "|" & $EditUnitModelNumber & "|" & $EditUnitBatterySerial, $ListView) Else MsgBox(48, "Edit Part", "You have chosen to cancel the edit of the unit!") EndIf EndIf EndIf GUISetState(@SW_ENABLE, $ManageUnitsGUI) Sleep(100) WinActivate($ManageUnitsGUI) EndFunc ;==>_EditUnit Func _RemoveUnit() GUISetState(@SW_DISABLE, $ManageUnitsGUI) $ListViewGetSelection = _GUICtrlListView_GetSelectionMark($ListView) $GetUnitNumber = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 0) If $GetUnitNumber[3] = "" Then MsgBox(48, "Error", "No unit was selected, cancelling operation!") Else $CheckMsgBox = MsgBox(4, "Remove Part", "Are you sure you wish to remove the following unit?" & @CRLF & @CRLF & $GetUnitNumber[3]) If $CheckMsgBox = 6 Then _GUICtrlListView_DeleteItem($ListView, $ListViewGetSelection) IniDelete($DatabasePath & "/Equipment Database.ini", "Equipment", $GetUnitNumber[3]) MsgBox(0, "Remove Unit", "The unit has been removed from the database!") Else MsgBox(48, "Remove Unit", "You have chosen to cancel the removal of the unit!") EndIf EndIf GUISetState(@SW_ENABLE, $ManageUnitsGUI) Sleep(100) WinActivate($ManageUnitsGUI) EndFunc ;==>_RemoveUnit Func _SearchParts() Dim $FoundEntries[1] $ReadPartLookupInput = GUICtrlRead($SearchPartsInput) $Found = 0 $SearchAll = 0 $ReadPartsData = IniReadSection($DatabasePath & "/Parts Database.ini", "Parts") If $ReadPartLookupInput = "all" Then $SearchAll = 1 _GUICtrlListView_DeleteAllItems($ListView) For $i = 1 To UBound($ReadPartsData) - 1 GUICtrlCreateListViewItem($ReadPartsData[$i][0] & "|" & $ReadPartsData[$i][1], $ListView) Next Else For $i = 1 To UBound($ReadPartsData) - 1 If StringInStr($ReadPartsData[$i][0], $ReadPartLookupInput) Then $PartInfo = $ReadPartsData[$i][0] & "|" & $ReadPartsData[$i][1] _ArrayInsert($FoundEntries, 0, $PartInfo, 0) $Found = 1 EndIf Next If $Found = 0 Then MsgBox(0, "Searching...", "No parts found matching that part number, searching part descriptions!") For $i = 1 To UBound($ReadPartsData) - 1 $SplitData = StringSplit($ReadPartsData[$i][1], "|") If StringInStr($SplitData[1], $ReadPartLookupInput) Then $PartInfo = $ReadPartsData[$i][0] & "|" & $ReadPartsData[$i][1] _ArrayInsert($FoundEntries, 0, $PartInfo, 0) $Found = 1 EndIf Next EndIf If $Found = 0 Then MsgBox(0, "Searching...", "No parts found matching that part description, searching product lines!") For $i = 1 To UBound($ReadPartsData) - 1 $SplitData = StringSplit($ReadPartsData[$i][1], "|") If StringInStr($SplitData[2], $ReadPartLookupInput) Then $PartInfo = $ReadPartsData[$i][0] & "|" & $ReadPartsData[$i][1] _ArrayInsert($FoundEntries, 0, $PartInfo, 0) $Found = 1 EndIf Next EndIf If $Found = 0 Then MsgBox(0, "Searching...", "No parts found matching that product line, searching part bin numbers!") For $i = 1 To UBound($ReadPartsData) - 1 $SplitData = StringSplit($ReadPartsData[$i][1], "|") If StringInStr($SplitData[3], $ReadPartLookupInput) Then $PartInfo = $ReadPartsData[$i][0] & "|" & $ReadPartsData[$i][1] _ArrayInsert($FoundEntries, 0, $PartInfo, 0) $Found = 1 EndIf Next EndIf If $Found = 0 Then MsgBox(48, "Error", "No parts found matching your input in the database!") Else _ArrayInsert($FoundEntries, 0, "RDaughertyPlaceHolder") _GUICtrlListView_DeleteAllItems($ListView) For $i = 1 To UBound($FoundEntries) - 1 For $a = 1 To UBound($ReadPartsData) - 1 If StringInStr($FoundEntries[$i], $ReadPartsData[$a][0]) Then GUICtrlCreateListViewItem($FoundEntries[$i] & "|" & $ReadPartsData[$a][1], $ListView) EndIf Next Next EndIf EndIf GUICtrlSetData($SearchPartsInput, "") EndFunc ;==>_SearchParts Func _SearchEquipment() Dim $FoundEntries[1] $ReadUnitNumberInput = GUICtrlRead($SearchEquipmentInput) $Found = 0 $SearchAll = 0 $ReadUnitsData = IniReadSection($DatabasePath & "/Equipment Database.ini", "Equipment") If $ReadUnitNumberInput = "all" Then $SearchAll = 1 _GUICtrlListView_DeleteAllItems($ListView) For $i = 1 To UBound($ReadUnitsData) - 1 GUICtrlCreateListViewItem($ReadUnitsData[$i][0] & "|" & $ReadUnitsData[$i][1], $ListView) Next Else For $i = 1 To UBound($ReadUnitsData) - 1 If StringInStr($ReadUnitsData[$i][0], $ReadUnitNumberInput) Then $UnitsInfo = $ReadUnitsData[$i][0] & "|" & $ReadUnitsData[$i][1] _ArrayInsert($FoundEntries, 0, $UnitsInfo, 0) $Found = 1 EndIf Next If $Found = 0 Then MsgBox(0, "Searching...", "No units found matching that number, searching model numbers!") For $i = 1 To UBound($ReadUnitsData) - 1 $SplitData = StringSplit($ReadUnitsData[$i][1], "|") If StringInStr($SplitData[1], $ReadUnitNumberInput) Then $UnitsInfo = $ReadUnitsData[$i][0] & "|" & $ReadUnitsData[$i][1] _ArrayInsert($FoundEntries, 0, $UnitsInfo, 0) $Found = 1 EndIf Next EndIf If $Found = 0 Then MsgBox(0, "Searching...", "No units found matching that model number, searching serial numbers!") For $i = 1 To UBound($ReadUnitsData) - 1 $SplitData = StringSplit($ReadUnitsData[$i][1], "|") If StringInStr($SplitData[2], $ReadUnitNumberInput) Then $UnitsInfo = $ReadUnitsData[$i][0] & "|" & $ReadUnitsData[$i][1] _ArrayInsert($FoundEntries, 0, $UnitsInfo, 0) $Found = 1 EndIf Next EndIf If $Found = 0 Then MsgBox(48, "Error", "No units, model numbers or serial numbers found matching that search criteria!") Else _ArrayInsert($FoundEntries, 0, "RDaughertyPlaceHolder") _GUICtrlListView_DeleteAllItems($ListView) For $i = 1 To UBound($FoundEntries) - 1 For $a = 1 To UBound($ReadUnitsData) - 1 If StringInStr($FoundEntries[$i], $ReadUnitsData[$a][0]) Then GUICtrlCreateListViewItem($FoundEntries[$i] & "|" & $ReadUnitsData[$a][1], $ListView) EndIf Next Next EndIf EndIf GUICtrlSetData($SearchEquipmentInput, "") EndFunc ;==>_SearchEquipment Func _WM_NOTIFY($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam Local $hWndListView = $ListView If Not IsHWnd($ListView) Then $hWndListView = GUICtrlGetHandle($ListView) Local $tNMHDR = DllStructCreate($tagNMLISTVIEW, $lParam) Local $hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom")) Local $iCode = DllStructGetData($tNMHDR, "Code") Switch $hWndFrom Case $hWndListView Switch $iCode Case $LVN_COLUMNCLICK ; A column was clicked _GUICtrlListView_SimpleSort($hWndListView, $g_bSortSense, DllStructGetData($tNMHDR, "SubItem")) ; Sort direction for next sort toggled by default EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>_WM_NOTIFY SearchWorkOrdersModule Global $Found, $ReadSerialNumberInput, $FoundCount = 0, $WorkOrdersGUI, $MainGUI, $DatabasePath, $SerialNumberInput, $SearchOrdersInput Global $SearchAll = 0, $ListView, $ViewWorkOrdersGUI, $MainGUI Global $g_bSortSense = True Dim $FoundEntries[1][4] Func _CreateWorkOrdersGui() Dim $FoundEntries[1] $Found = 0 $FoundCount = 0 $SearchAll = 0 $DatabasePath = FileSelectFolder("Select Folder...", @MyDocumentsDir) If $DatabasePath = "" Then MsgBox(48, "Error", "No database selected, cancelling operation!") Else GUISetState(@SW_DISABLE, $MainGUI) $CurrentGUI = "View Work Orders" $ViewWorkOrdersGUI = GUICreate("Work Orders", 600, 660) GUISetOnEvent($GUI_EVENT_CLOSE, "_CloseGUI") GUISetBkColor(0xFFFFFF) GUICtrlCreateLabel("Search Orders", 12, 20, 150, 40) GUICtrlSetFont(-1, 16) $SearchOrdersInput = GUICtrlCreateInput("", 160, 18, 250, 30) GUICtrlSetFont(-1, 16) $SearchOrdersButton = GUICtrlCreateButton("Search", 470, 5, 100, 50) GUICtrlSetOnEvent(-1, "_SearchWorkOrders") GUICtrlSetFont(-1, 16) $ListView = GUICtrlCreateListView("Work Orders", 10, 60, 580, 500, $LVS_SORTASCENDING) _GUICtrlListView_SetColumnWidth(-1, 0, 575) $ReadWorkOrders = _FileListToArray($DatabasePath, Default, 1) For $i = 1 To UBound($ReadWorkOrders) - 1 $SplitData = StringSplit($ReadWorkOrders[$i], ".") GUICtrlCreateListViewItem($SplitData[1], $ListView) Next $ViewWorkOrderButton = GUICtrlCreateButton("View", 60, 590, 220, 40) GUICtrlSetOnEvent(-1, "_ViewWorkOrder") GUICtrlSetFont(-1, 16) $CloseButton = GUICtrlCreateButton("Close", 320, 590, 220, 40) GUICtrlSetOnEvent(-1, "_CloseGUI") GUICtrlSetFont(-1, 16) GUISetState() EndIf EndFunc ;==>_CreateWorkOrdersGui Func _SearchWorkOrders() $SearchAll = 0 $Found = 0 Dim $FoundEntries[1] $ReadWorkOrderInput = GUICtrlRead($SearchOrdersInput) $ReadWorkOrders = _FileListToArray($DatabasePath, Default, 1) If $ReadWorkOrderInput = "all" Then $SearchAll = 1 _GUICtrlListView_DeleteAllItems($ListView) For $i = 1 To UBound($ReadWorkOrders) - 1 $SplitData = StringSplit($ReadWorkOrders[$i], ".") GUICtrlCreateListViewItem($SplitData[1], $ListView) Next Else For $i = 1 To UBound($ReadWorkOrders) - 1 $SplitData = StringSplit($ReadWorkOrders[$i], ".") If StringInStr($SplitData[1], $ReadWorkOrderInput) Then _ArrayInsert($FoundEntries, 0, $SplitData[1], 0) $Found = 1 $FoundCount += 1 EndIf Next If $Found = 0 Then MsgBox(48, "Error", "No work orders found with those search criterias!") Else _ArrayInsert($FoundEntries, 0, $FoundCount) _GUICtrlListView_DeleteAllItems($ListView) $ReadWorkOrders = _FileListToArray($DatabasePath, Default, 1) For $i = 1 To UBound($FoundEntries) - 1 For $a = 1 To UBound($ReadWorkOrders) - 1 $SplitData = StringSplit($ReadWorkOrders[$a], ".") If StringInStr($FoundEntries[$i], $SplitData[1]) Then GUICtrlCreateListViewItem($SplitData[1], $ListView) EndIf Next Next EndIf EndIf GUICtrlSetData($SearchOrdersInput, "") EndFunc ;==>_SearchWorkOrders Func _ViewWorkOrder() $ListViewGetSelection = _GUICtrlListView_GetSelectionMark($ListView) $GetSelectionInfo = _GUICtrlListView_GetItem($ListView, $ListViewGetSelection, 0) $ReadWorkOrders = _FileListToArray($DatabasePath & "\" & $ReadSerialNumberInput, Default, 1) For $i = 1 To UBound($ReadWorkOrders) - 1 If StringInStr($ReadWorkOrders[$i], $GetSelectionInfo[3]) Then ShellExecute($DatabasePath & "\" & $ReadSerialNumberInput & "\" & $ReadWorkOrders[$i]) EndIf Next EndFunc ;==>_ViewWorkOrder1 point -
Works fine with Windows 10 Pro x64 French Nice! Edit : for me, the date format should be 04/10/2016 instead of 04-10-2016, but I see in your code Local $sDelim = '-' ; read from settings ??? [maybe] ... it should be easy for you It works with Local $sDelim = StringRegExp(_WinAPI_GetDateFormat(), "[\D]", 1)[0] on line 1831 point
-
Works nice on my good ole French XP1 point
-
https://msdn.microsoft.com/en-us/library/h90dkhs0(v=vs.90).aspx The dll is taking advantage of IMAGE_SCN_MEM_SHARED. Each process that loads the dll gets its own copy, that section is simply coherent across all processes that utilize the dll. It works much the same way as memory mapped files. section '.data' data readable writeable shareable1 point
-
F.W.I.W. - Listview's of various ways of reporting disk properties ; *** Start added by AutoIt3Wrapper *** #include <GUIConstantsEx.au3> ; *** End added by AutoIt3Wrapper *** #include <Array.au3> #include <WinAPIEx.au3> #include <GUIListView.au3> #AutoIt3Wrapper_Add_Constants=n local $gui010 = guicreate('',300,850) local $aSize = wingetclientsize($gui010) guictrlcreatelabel('Using _WINAPI_GetDriveNumber',10,20,300) guictrlsetfont(-1,9,800,default,'lucinda console') local $lsv010 = guictrlcreatelistview('Disk|Partition|Logical Drive|Type',10,40,$aSize[0]-20,200) guictrlcreatelabel('Using DeviceIoControl method',10,270,300) guictrlsetfont(-1,9,800,default,'lucinda console') local $lsv020 = guictrlcreatelistview('Disk|Partition|Logical Drive|Type',10,290,$aSize[0]-20,200) guictrlcreatelabel('Using WMI method',10,520,300) guictrlsetfont(-1,9,800,default,'lucinda console') local $lsv030 = guictrlcreatelistview('Disk|Partition|Logical Drive|Type',10,540,$aSize[0]-20,200) ;======================================================================================================================================= ; populate listview using _winapi method ;======================================================================================================================================= local $aDRV = drivegetdrive('all') For $1 = 1 to $aDRV[0] $aDRVSTAT = _WinAPI_GetDriveNumber($aDRV[$1]) If Not @error Then if $aDRVSTAT[2] > 10 then $aDRVSTAT[2] = 'N/A' guictrlcreatelistviewitem( $aDRVSTAT[1] & '|' & $aDRVSTAT[2] & '|' & stringupper($aDRV[$1]) & '|' & $aDRVSTAT[0], $lsv010) endif Next ;======================================================================================================================================= ; populate listview using DeviceIoControl method ;======================================================================================================================================= Local $aCall = DllCall("kernel32.dll", "dword", "GetLogicalDrives") Local $iMask = $aCall[0] Local $tIOCTL_STORAGE_GET_DEVICE_NUMBER = DllStructCreate("dword DeviceType;" & _ "dword DeviceNumber;" & _ "int PartitionNumber") Local $hDevice Local $a_hCall, $a_iCall For $i = 0 To 25; alphabet (A = 0) If BitAND(BitShift($iMask, $i), 1) Then; drive exists $a_hCall = DllCall("kernel32.dll", "hwnd", "CreateFile", _ "str", "\\.\" & Chr(65 + $i) & ":", _; want handle to the logical drive "dword", 0, _ "dword", 0, _ "ptr", 0, _ "dword", 3, _; OPEN_EXISTING "dword", 128, _; FILE_ATTRIBUTE_NORMAL "ptr", 0) $hDevice = $a_hCall[0] $a_iCall = DllCall("kernel32.dll", "int", "DeviceIoControl", _ "hwnd", $hDevice, _ "dword", 0x2D1080, _; IOCTL_STORAGE_GET_DEVICE_NUMBER "ptr", 0, _ "dword", 0, _ "ptr", DllStructGetPtr($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _ "dword", DllStructGetSize($tIOCTL_STORAGE_GET_DEVICE_NUMBER), _ "dword*", 0, _ "ptr", 0) DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $hDevice) guictrlcreatelistviewitem( DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceNumber") & '|' & _ DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "PartitionNumber") & '|' & _ Chr(65 + $i) & '|' & _ DllStructGetData($tIOCTL_STORAGE_GET_DEVICE_NUMBER, "DeviceType"),$lsv020 ) EndIf Next ;======================================================================================================================================= ; populate listview using WMI method ;======================================================================================================================================= local $drv, $part $oWMISvc = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2") $colDiskDrives = $oWMISvc.ExecQuery("SELECT * FROM Win32_DiskDrive") For $oDiskDrive In $colDiskDrives $drv = $oDiskDrive.DeviceId ConsoleWrite("DiskDrive = " & $oDiskDrive.DeviceId & " Caption = " & $oDiskDrive.Caption & @LF) $sQuery = "ASSOCIATORS OF {Win32_DiskDrive.DeviceID='" & $oDiskDrive.DeviceId & "'} WHERE AssocClass = Win32_DiskDriveToDiskPartition" $colPartitions = $oWMISvc.ExecQuery($sQuery) For $oPartition In $colPartitions $part = $oPartition.DeviceId ConsoleWrite(@TAB & "Partition = " & $oPartition.DeviceId & @LF) $sQuery = "ASSOCIATORS OF {Win32_DiskPartition.DeviceID='" & $oPartition.DeviceId & "'} WHERE AssocClass = Win32_LogicalDiskToPartition" $colLogicalDisks = $oWMISvc.ExecQuery($sQuery) For $oLogicalDisk In $colLogicalDisks if GUICtrlCreateListViewItem($drv & '|' & $part & '|' & $oLogicalDisk.DeviceId , $lsv030) = 0 then ConsoleWrite('LV create failed' & @LF) ConsoleWrite(@TAB & @TAB & "LogicalDisk = " & $oLogicalDisk.DeviceId & @LF) Next Next Next ;======================================================================================================================================= ; adjust column widths and finish off gui shit ;======================================================================================================================================= for $1 = 0 to _GUICtrlListView_GetColumnCount($lsv010) + 1 _GUICtrlListView_SetColumnWidth($lsv010, $1, $aSize[0]/_GUICtrlListView_GetColumnCount($lsv010)-6) next for $1 = 0 to _GUICtrlListView_GetColumnCount($lsv020) + 1 _GUICtrlListView_SetColumnWidth($lsv020, $1, $aSize[0]/_GUICtrlListView_GetColumnCount($lsv020)-6) next guisetstate() while 1 switch guigetmsg() case $gui_event_close Exit EndSwitch WEnd kylomas1 point
-
mircea, Try something like this: $destination = "eroare.jpg" SplashImageOn("Splash Screen", $destination, 1200, 860, -1, -1, 3) While 1 $passwd = InputBox("Enter password", "Enter the password.", "", "*") If $passwd = "1" Then ExitLoop ElseIf @Error = 1 Then If MsgBox(4, "Cancel", "Are you sure?") = 6 Then Exit Else MsgBox(0, "Error", "Incorrect Password") EndIf WEnd SplashOff() MsgBox(0, "Success", "You entered the correct password!") All clear? M23 Edit: Trop lent encore!1 point
-
This seems to work: Global Const $DESKTOP_ENUMERATE = 0x40 Global Const $SPI_GETSCREENSAVERRUNNING = 114 Global Const $DESKTOP_SWITCHDESKTOP = 0x100 HotKeySet("{ESC}", "_Terminate") AdlibEnable("IsDeskTopLocked", 500) While 1 Sleep(10) WEnd Func IsDeskTopLocked() Local $p_lngHwnd, $p_lngRtn, $p_lngErr, $p_lngScreenSaver, $p_blnIsScreenSaver ;~ ' ------------------------------------------ ;~ ' First check for screen saver one of 2 ways, ;~ ' based of OS ;~ ' ------------------------------------------ If @OSTYPE = "WIN32_WINDOWS" Then ;~ ' --------------------------------------- ;~ ' Pre W2K -- Note, will only be TRUE if ;~ ' the "Password Protected" box is ;~ ' checked. ;~ ' --------------------------------------- $p_lngHwnd = DllCall("user32.dll", "int", "OpenDesktopA", "str", "screen-saver", "int", 0, "int", False, "int", $DESKTOP_ENUMERATE) If $p_lngHwnd[0] <> 0 Then $p_blnIsScreenSaver = True Else $p_blnIsScreenSaver = False EndIf Else ;~ ' --------------------------------------- ;~ ' W2K+ -- Will determine if screen saver ;~ ' is running whether or not the ;~ ' "Password Protected" box is checked ;~ ' --------------------------------------- $p_lngRtn = DllCall("user32.dll", "int", "SystemParametersInfoA", "int", $SPI_GETSCREENSAVERRUNNING, "int", 0, "int", $p_lngScreenSaver, "int", 0) If $p_lngRtn[0] = 0 Then ConsoleWrite("Error detecting screen saver" & @LF) Else $p_blnIsScreenSaver = $p_lngScreenSaver EndIf EndIf ;~ ' ------------------------------------------ ;~ ' If screen saver is *not* running, then ;~ ' check for locked workstation ;~ ' ------------------------------------------ If $p_blnIsScreenSaver Then If @OSTYPE = "WIN32_WINDOWS" Then ConsoleWrite("Screen saver is running..., Handle #" & $p_lngHwnd[0] & @LF) $p_lngHwnd = DllCall("user32.dll", "int", "CloseDesktop", "int", $p_lngHwnd[0]) Else ConsoleWrite("Screen saver is running on W2K+" & @LF) EndIf Else $p_lngHwnd = DllCall("user32.dll", "int", "OpenDesktopA", "str", "Default", "int", 0, "int", False, "int", $DESKTOP_SWITCHDESKTOP) If $p_lngHwnd[0] = 0 Then ConsoleWrite("Error with OpenDesktop" & @LF) Else $p_lngRtn = DllCall("user32.dll", "int", "SwitchDesktop", "int", $p_lngHwnd[0]) $p_lngErr = _GetLastErrorMessage() If $p_lngRtn[0] = 0 Then If $p_lngErr = 0 Then ConsoleWrite("Desktop is locked" & @LF) Else ConsoleWrite("Error with SwitchDesktop" & @LF) EndIf Else ConsoleWrite("Not locked!" & @LF) EndIf $p_lngHwnd = DllCall("user32.dll", "int", "CloseDesktop", "int", $p_lngHwnd[0]) EndIf EndIf EndFunc ;==>IsDeskTopLocked Func _Terminate() Exit EndFunc ;==>_Terminate ;=============================================== ; _GetLastErrorMessage($DisplayMsgBox="") ; Format the last windows error as a string and return it ; if $DisplayMsgBox <> "" Then it will display a message box w/ the error ; Return Window's error as a string ;=============================================== Func _GetLastErrorMessage($DisplayMsgBox = "") Local $ret, $s Local $p = DllStructCreate("char[4096]") Local Const $FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000 If @error Then Return "" $ret = DllCall("Kernel32.dll", "int", "GetLastError") $ret = DllCall("kernel32.dll", "int", "FormatMessage", _ "int", $FORMAT_MESSAGE_FROM_SYSTEM, _ "ptr", 0, _ "int", $ret[0], _ "int", 0, _ "ptr", DllStructGetPtr($p), _ "int", 4096, _ "ptr", 0) $s = DllStructGetData($p, 1) If $DisplayMsgBox <> "" Then MsgBox(0, "_GetLastErrorMessage", $DisplayMsgBox & @CRLF & $s) Return $s EndFunc ;==>_GetLastErrorMessage1 point