Jump to content

pl123

Active Members
  • Posts

    20
  • Joined

  • Last visited

Everything posted by pl123

  1. The second problem is in the first post, but my problem is making the first tab show when I run the GUI. When I use $GUI_SHOW, it the tab flash over and over really fast.
  2. Thanks for your reply, BrewManNH! I got it fixed. =) Now, can anyone help me with my second problem? Thanks!
  3. I borrowed the following script to add to my GUI from this link, So I changed it around a bit, and added into the GUI. However, whenever I run it, it gives the me error 'Next' statement with no matching 'For' statement However, there is a For statement before the Next statement... What's wrong? Thanks! Also, I've marked the errors in the code. Func _HighestRes () Local $tDEVMODE = DllStructCreate ('byte[32];dword[10];byte[32];dword[6]') Local $pDEVMODE = DllStructGetPtr ($tDEVMODE) Local $i = 0, $Ret $Res = "" ; popluate resources into buffer While 1 $Ret = DllCall('user32.dll', 'int', 'EnumDisplaySettings', 'ptr', 0, 'dword', $i, 'ptr', $pDEVMODE) If (@error) Or ($Ret[0] = 0) Then ExitLoop EndIf $HighWidth = DllStructGetData ($tDEVMODE, 4, 2) $HHeight = DllStructGetData ($tDEVMODE, 4, 3) $Bits = DllStructGetData ($tDEVMODE, 4, 1) $Res = $Res & $HighWidth & "," & $HighHeight & "," & $Bits & ":" $i += 1 WEnd $arrRes = StringSplit($Res, ":") ; Split string using : as delimiter $ColorDepth = 0 For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then ExitLoop If UBound($tmp1) = 4 Then ; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[3]) > $ColorDepth Then $ColorDepth = Number($tmp1[3]) EndIf EndIf Next ; ERROR! $XResHigh = 0 For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then ExitLoop If UBound($tmp1) = 4 Then; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[1]) > $XResHigh Then $XResHigh = Number($tmp1[1]) EndIf EndIf Next ; ERROR! $YResHigh = 0 For $i = 1 To 5000 $tmp1 = StringSplit($arrRes[$i], ",") If @error Then ExitLoop If UBound($tmp1) = 4 Then ; check if array has 4 elements (640, 480, 8, null), if so, obtain the highest color depth from the array If Number($tmp1[1]) = $XResHigh Then ; only query array objects that match the X resolution If Number($tmp1[2]) > $YResHigh Then $YResHigh = Number($tmp1[2]) EndIf EndIf EndIf Next ; ERROR! EndFunc I have several tabs in my GUI, and when I run it, the first tab doesn't show anything, until I click on another tab then click on that first tab. I tried using While 1 $GetMsg = GUIGetMsg (0) Switch $GetMsg Case $Tab[0] GUICtrlSetState ($CTRLID, $GUI_SHOW) EndSwitch WEnd but all that does is make it flash a lot. How do I fix that? Thanks for your help! =)
  4. How do you insert an function generated array into a ListView control? And by "function generated", I mean that a function runs, gets some data, and then if it the function succeeds, it returns an array. I want to place that generated array in a ListView. In one of my previous threads, enaiman told me that there was a function which would add an array to a listview control (_GUICtrlListView_AddArray), so I tried using it like this: $LeftBorder = 10 $ListView = GUICtrlCreateListView ("", $LeftBorder, 75, 390, 425) _GUICtrlListView_AddColumn ($ListView, "Col 1") _GUICtrlListView_SetItemCount ($ListView, 750) _GUICtrlListView_AddArray ($ListView, $Array)and it failed miserably (incorrect number of subscripts), which I predicted would happen... Apparently, you need to declare each element in the array (do you have to?) first, so how would I do that with the function-generated array? Even if I try $Array[170][1] (there's 170 elements, and one column), it doesn't work too well. ---------------------------------------------------------- $LeftBorder = 10 Global $Array[170][1] $ListView = GUICtrlCreateListView ("", $LeftBorder, 75, 390, 425) _GUICtrlListView_AddColumn ($ListView, "Col 1") _GUICtrlListView_SetItemCount ($ListView, 750) _GUICtrlListView_AddArray ($ListView, $Array) This code (right above this sentence) doesn't give me an error, but returns nothing in the list view when I load it. _GUICtrlListView_AddArray ($ListView, $Array[170][1]) And when I replace the last line with this, it still returns nothing. --- Am I doing something wrong? Thanks for your help! =) ------------------------------------------------------------------------ random notes: Here's the function for the array, based on Danny35d's in a previous thread: Func _ProgramList () Local $Count = 1 While 1 $EnumKey = RegEnumKey ($ProgramReg, $Count) If Not @error = 0 then ExitLoop $ReadName = RegRead ($ProgramReg & "\" & $EnumKey, "DisplayName") $ReadName = StringReplace ($ReadName, " (remove only)", "") If Not $ReadName = "" Then ReDim $ProgramArray[UBound($ProgramArray) + 1] $ProgramArray[0] = UBound($ProgramArray) - 1 $ProgramArray[UBound($ProgramArray) - 1] = $ReadName EndIf $Count = $Count + 1 WEnd If IsDeclared("ProgramArray") = 1 Then Return ($ProgramArray) ElseIf IsDeclared("ProgramArray") = 0 SetError (1) EndIf EndFunc And if this matters, I use AutoIt v.3.3.6.1 (stable). Thanks for your help again! =)
  5. Thanks for your help!
  6. enaiman: I think in a list would be best.
  7. I need to place an array in a GUI. For example, when this code below finishes executing, I want to place the resulting array in a GUI. Is this possible? Func _InstalledPrograms () Local $Count = 1 While 1 $Key = RegEnumKey ($InstalledProgramRegKey, $Count) If Not @error = 0 then ExitLoop $Line = RegRead ($InstalledProgramRegKey & '\' & $Key, 'Displayname') $Line = StringReplace ($Line, ' (remove only)', '') If Not $Line = "" Then ; If Not IsDeclared('ProgramArray') Then Dim $ProgramArray[1] ReDim $ProgramArray[UBound($ProgramArray) + 1] $ProgramArray[0] = UBound($ProgramArray) - 1 $ProgramArray[UBound($ProgramArray) - 1] = $Line EndIf $Count = $Count + 1 WEnd Select Case IsDeclared('ProgramArray') = 0 SetError (1) Return ('') Case IsDeclared('ProgramArray') = 1 SetError (0) Return($ProgramArray) EndSelect EndFunc EDIT: I want the array to show as a list in the GUI.
  8. Ok, I got it fixed now. Thanks both of you for your help! =)
  9. I'm trying to make the total amount of RAM, pagefile, and virtual show in a ListView, so I used MemGetStats (), and setting the values for the arrays [1],[3],[5]: $MemStats = MemGetStats () $MemStats[1] = $TotalPhysRAM $MemStats[3] = $TotalPagefile $MemStats[5] = $TotalVirtual Then, I'm adding them to the ListView: Global Const $LeftBorder = 10 ; Left 'margin' size $MainWindow = GUICreate ($GUITitle, 400, 450) GUISetState (@SW_SHOW, $MainWindow) WinSetOnTop ($GUITitle, "", 1) GUICtrlCreateTab (5, 5, 390, 25) ---- omitted ---- $Tab[1] = GUICtrlCreateTabItem ("Computer Specs") GUICtrlCreateLabel ("******************", $LeftBorder, 35) GUICtrlCreateLabel ("******************", $LeftBorder, 50) GUICtrlCreateLabel ("————————————————————————————————————————————————————————————————", $LeftBorder, 62) ; divider line $MemStats = MemGetStats () $MemStats[1] = $TotalPhysRAM $MemStats[3] = $TotalPagefile $MemStats[5] = $TotalVirtual $SpecsList = GUICtrlCreateListView ("****************|Value", $LeftBorder, 75, 380, 300) GUICtrlCreateListViewItem ("Total Physical RAM|" & $TotalPhysRAM & "", $SpecsList) GUICtrlCreateListViewItem ("Total Pagefile|" & $TotalPagefile & "", $SpecsList) GUICtrlCreateListViewItem ("Total Virtual Memory|" & $TotalVirtual & "", $SpecsList) However, the three items do not show up on the list view thingy. Is there anything wrong? Thanks! =)
  10. I got it (the never ending while statement) fixed; thanks to iamtheky. I placed If Not @error = 0 then ExitLoop in between these two lines of code. $Key = RegEnumKey ($RunAtStartupRegKey, $NumberOfKeys) If Not @error = 0 then ExitLoop $Line = RegRead ($RunAtStartupRegKey & '\' & $Key, 'Displayname') But now, when it saves, it gives me a blank file with the timestamp only. Is there anything else wrong? _DetermineMonthName () _DetermineDayName () Dim $RunAtStartupArray[1] $SaveAs = FileSaveDialog ("Select folder for output of list of programs that run at startup", "Desktop", "Text files (*.txt)", 16, "RunAtStartup.txt" ) $RunAtStartup = _RunAtStartup () _ArraySort ($RunAtStartup, 0, 1) ReDim $RunAtStartup [UBound($RunAtStartup)] ReDim $RunAtStartup [UBound($RunAtStartup)] _ArrayAdd ($RunAtStartup, "-----------------------------------------------------") _ArrayAdd ($RunAtStartup, "This list was created on " & $DayName & ", " & $MonthName & " " & @MDAY & ", " & @YEAR & " at " & @HOUR & ":" & @MIN & ":" & @SEC & ":" & @MSEC) _FileWriteFromArray ($SaveAs, $RunAtStartup) $StartupPrgmListingDone = MsgBox (65, "Startup Programs List - Completed", "Your programs have been successfully listed." & @CRLF & "To continue to the next part (file listing), click OK to continue." & @CRLF & "Click Cancel to quit.") Select Case $StartupPrgmListingDone = 6 _DoNothing () Case $StartupPrgmListingDone = 7 Exit EndSelect Func _RunAtStartup () Local $NumberOfKeys = 1 While 1 $Key = RegEnumKey ($RunAtStartupRegKey, $NumberOfKeys) If Not @error = 0 then ExitLoop $Line = RegRead ($RunAtStartupRegKey & '\' & $Key, 'Displayname') If Not $Line = "" Then If Not IsDeclared ('RunAtStartupArray') Then Dim $RunAtStartupArray[1] ReDim $RunAtStartupArray[UBound($RunAtStartupArray) + 1] $RunAtStartupArray[0] = UBound($RunAtStartupArray) - 1 $RunAtStartupArray[UBound($RunAtStartupArray) - 1] = $Line EndIf $NumberOfKeys = $NumberOfKeys + 1 WEnd Select Case IsDeclared('RunAtStartupArray') = 0 SetError (1) Return ('') Case IsDeclared('RunAtStartupArray') = 1 SetError (0) Return($RunAtStartupArray) EndSelect EndFunc Other functions are in the first post.
  11. I'm making a script that will list all the run at startup programs on your computer in an array, and then save it to a file, based on Danny35d's script for listing installed programs at http://www.autoitscript.com/forum/index.php?showtopic=18034 This is what I have so far: #include <Array.au3> #include <File.au3> #include <WindowsConstants.au3> Global Const $RunAtStartupRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" Global $MonthName, $DayName _DetermineMonthName () _DetermineDayName () Dim $RunAtStartupArray[1] $SaveAs = FileSaveDialog ("Select folder for output of list of programs that run at startup", "Desktop", "Text files (*.txt)", 16, "RunAtStartup.txt" ) $RunAtStartup = _RunAtStartup () _ArraySort ($RunAtStartup, 0, 1) ReDim $RunAtStartup [UBound($RunAtStartup)] ReDim $RunAtStartup [UBound($RunAtStartup)] _ArrayAdd ($RunAtStartup, "-----------------------------------------------------") _ArrayAdd ($RunAtStartup, "This list was created on " & $DayName & ", " & $MonthName & " " & @MDAY & ", " & @YEAR & " at " & @HOUR & ":" & @MIN & ":" & @SEC & ":" & @MSEC) _FileWriteFromArray ($SaveAs, $RunAtStartup) Func _DetermineMonthName () Select Case @MON = 01 $MonthName = "January" Case @MON = 02 $MonthName = "February" Case @MON = 03 $MonthName = "March" Case @MON = 04 $MonthName = "April" Case @MON = 05 $MonthName = "May" Case @MON = 06 $MonthName = "June" Case @MON = 07 $MonthName = "July" Case @MON = 08 $MonthName = "August" Case @MON = 09 $MonthName = "September" Case @MON = 10 $MonthName = "October" Case @MON = 11 $MonthName = "November" Case @MON = 12 $MonthName = "December" EndSelect EndFunc Func _DetermineDayName () Select Case @WDAY = 1 $DayName = "Sunday" Case @WDAY = 02 $DayName = "Monday" Case @WDAY = 03 $DayName = "Tuesday" Case @WDAY = 04 $DayName = "Wednesday" Case @WDAY = 05 $DayName = "Thursday" Case @WDAY = 06 $DayName = "Friday" Case @WDAY = 07 $DayName = "Saturday" EndSelect EndFunc Func _RunAtStartup () Local $NumberOfKeys = 1 While 1 $Key = RegEnumKey ($RunAtStartupRegKey, $NumberOfKeys) $Line = RegRead ($RunAtStartupRegKey & '\' & $Key, 'Displayname') If Not $Line = "" Then If Not IsDeclared ('RunAtStartupArray') Then Dim $RunAtStartupArray[1] ReDim $RunAtStartupArray[UBound($RunAtStartupArray) + 1] $RunAtStartupArray[0] = UBound($RunAtStartupArray) - 1 $RunAtStartupArray[UBound($RunAtStartupArray) - 1] = $Line EndIf $NumberOfKeys = $NumberOfKeys + 1 WEnd Select Case IsDeclared('RunAtStartupArray') = 0 SetError (1) Return ('') Case IsDeclared('RunAtStartupArray') = 1 SetError (0) Return($RunAtStartupArray) EndSelect EndFunc And also, how can I make a array that saves the name of a program, the version number, and the developer to a file? Thanks for your help!
  12. Thanks for helping me, both of you. I get what you're saying.
  13. I made a GUI, and it has lots of checkboxes, so I made two buttons, one of which would uncheck all the boxes, one of which would check all the boxes. It didn't work, but with the advice of some people, I got them working. Now, after I added tons more of stuff, they don't seem to work anymore. Here's a largely abbreviated version of my script... ; ----------------------------------------------- ; --------------- Include files ----------------- ; ----------------------------------------------- #include <ButtonConstants.au3> #include <ComboConstants.au3> #include <EditConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <IE.au3> #include <Misc.au3> #include <Process.au3> #include <ProgressConstants.au3> #include <WindowsConstants.au3> ; ----------------------------------------------- ; ----------------- Functions ------------------- ; ----------------------------------------------- ; _Continue() - Close "About" box ; _CheckAll() - Check all boxes ; _UncheckAll() - Uncheck all boxes ; _Settings() - Create settings menu ; _Exit() - Close script ; _DoNothing() - Don't do anything ; _DrawLine() - Draw the divider line for the GUI ; ----------------------------------------------- ; ------------------ Variables ------------------ ; ----------------------------------------------- Global $Checkbox[8], $InputID[2] Global $Settings, $Calculate, $GUI Global $Title = "Test" Global $Pen, $Graphic ; ----------------------------------------------- ; --------------- Read .ini file ---------------- ; ----------------------------------------------- ; space filler for .ini file If FileExists(@ScriptDir & "\settings.ini") Then $open = IniRead(@ScriptDir & "\settings.ini", "settings", "open", "") Else IniWrite(@ScriptDir & "\settings.ini", "settings", "open", "1") EndIf ; ----------------------------------------------- ; ------------- Create main menu ---------------- ; ----------------------------------------------- If _Singleton($GUI) = 0 Then MsgBox (48, "Error", "...") EndIf $GUI = GUICreate($Title, 400, 450, 350, 250, $WS_OVERLAPPEDWINDOW) WinSetOnTop($Title, "", 1) GUISetState(@SW_SHOW) GUICtrlCreateLabel("...", 10, 10) _DrawLine() GUICtrlCreateLabel("...", 10, 45) $InputID[0] = GUICtrlCreateInput("", 10, 65, 100, 20, $ES_NUMBER) $InputID[1] = GUICtrlCreateInput("", 225, 90, 85, "", $ES_READONLY) GUICtrlCreateLabel("...", 10, 90) GUICtrlCreateLabel("...", 10, 115) $Calculate = GUICtrlCreateButton("...", 325, 90, 60, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetOnEvent($Calculate, "_Calculate") $Settings = GUICtrlCreateButton("...", 325, 110, 60, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetOnEvent($Settings, "_Settings") GUICtrlCreateLabel("...", 10, 155) $Checkbox[0] = GUICtrlCreateCheckbox("...", 10, 175) $Checkbox[1] = GUICtrlCreateCheckbox("...", 10, 195) $Checkbox[2] = GUICtrlCreateCheckbox("...", 10, 215) $Checkbox[3] = GUICtrlCreateCheckbox("...", 10, 235) $Checkbox[4] = GUICtrlCreateCheckbox("...", 10, 255) $Checkbox[5] = GUICtrlCreateCheckbox("...", 10, 275) $Checkbox[6] = GUICtrlCreateCheckbox("...", 10, 295) $Checkbox[7] = GUICtrlCreateCheckbox("...", 10, 315) $CheckAll = GUICtrlCreateButton("Check all", 315, 175, 70, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetOnEvent($CheckAll, "_CheckAll") $UncheckAll = GUICtrlCreateButton("Check none", 315, 195, 70, 20, $BS_VCENTER + $BS_CENTER) GUICtrlSetOnEvent($UncheckAll, "_UncheckAll") GUICtrlCreateLabel("...", 10, 370) While 1 $nMsg = GUIGetMsg(0) Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd ; ----------------------------------------------- ; --------------- main functions! --------------- ; ----------------------------------------------- Func _CheckAll() For $i = 0 To 7 GUICtrlSetState($Checkbox[$i], $GUI_CHECKED) Next EndFunc ;==>_CheckAll Func _UnCheckAll() For $i = 0 To 7 GUICtrlSetState($Checkbox[$i], $GUI_UNCHECKED) Next EndFunc ;==>_UnCheckAll Func _Settings() GUICreate("Settings", 350, 350, 325, 250, $WS_OVERLAPPEDWINDOW) WinSetOnTop("Settings", "", 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg(0) Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd EndFunc ;==>_Settings Func _DrawLine() _GDIPlus_Startup () $Graphic = _GDIPlus_GraphicsCreateFromHWND ($GUI) $Pen = _GDIPlus_PenCreate ("", 20, 2) _GDIPlus_GraphicsDrawLine ($Graphic, 10, 40, 375, 40) _GDIPlus_PenDispose ($Pen) _GDIPlus_GraphicsDispose ($Graphic) _GDIPlus_ShutDown () EndFunc Func _Exit() Exit EndFunc ;==>_Exit Func _DoNothing() EndFunc ;==>_DoNothing Also, I need help with something else: when I click one of the buttons, I want a new GUI to popup, so I use GUICtrlSetOnEvent, but it doesn't work. Can someone tell me how to do this so it works?
  14. @Melba23 I understand what you mean about the control IDs, and your suggestion works fine for me. Thanks for your help!
  15. I'm trying to create two buttons, one of which will check all the checkboxes, and the other will uncheck them, but it isn't working. When I click the buttons, nothing happens. GUICreate ("title", 400, 450, 325, 250) GUISetState(@SW_SHOW) ... GUICtrlCreateCheckbox("...", 10, 140, "", "", $BS_AUTOCHECKBOX) GUICtrlCreateCheckbox("...", 10, 160, "", "", $BS_AUTOCHECKBOX) GUICtrlCreateCheckbox("...", 10, 180, "", "", $BS_AUTOCHECKBOX) GUICtrlCreateCheckbox("...", 10, 200, "", "", $BS_AUTOCHECKBOX) GUICtrlCreateCheckbox("...", 10, 220, "", "", $BS_AUTOCHECKBOX) GUICtrlCreateCheckbox("...", 10, 240, "", "", $BS_AUTOCHECKBOX) GUICtrlCreateCheckbox("...", 10, 260, "", "", $BS_AUTOCHECKBOX) GUICtrlCreateCheckbox("...", 10, 280, "", "", $BS_AUTOCHECKBOX) ... The CtrlIDs are 10 for the first one, then 11 for the next, and so on. The last one's 17. So right now, everything's working fine, everything's in the right place. Now, the buttons... GUICtrlCreateButton("Check all", 315, 140, 70, 20, $BS_VCENTER + $BS_CENTER) ;ctrlID = 19 GUICtrlCreateButton("Check none", 315, 160, 70, 20, $BS_VCENTER + $BS_CENTER) ;ctrlID = 20 And here is where I don't understand why it doesn't work. I'm still a beginner with GUIs, so I don't know what's wrong. GUICtrlSetOnEvent (19, "_CheckAll") ... Func _CheckAll() GUICtrlSetState (10, $GUI_CHECKED) GUICtrlSetState (11, $GUI_CHECKED) GUICtrlSetState (12, $GUI_CHECKED) GUICtrlSetState (13, $GUI_CHECKED) GUICtrlSetState (14, $GUI_CHECKED) GUICtrlSetState (15, $GUI_CHECKED) GUICtrlSetState (16, $GUI_CHECKED) GUICtrlSetState (17, $GUI_CHECKED) EndFunc Either I did something wrong with the GUICtrlSetOnEvent, the Func _CheckAll(), or something else. Can someone help me with this problem?
  16. I'm trying to make the text inside one of my input boxes move to a different place. I can't really explain it, so see the arrows in the picture. By the way, I edited the box in Paint. This is what I have so far. InputBox ("Title", "Text Text Text Text Text Text 1. Text 2. Text 3. Text", "", "M", "145") I've tried limiting the width, but that doesn't seem to help.
  17. Alright, thanks for the advice =)
  18. So, I've been trying to make a loop script, and I'm done with that part. Now, I can't seem to set a hotkey to make the message box pop up, or cancel the script when I press a certain combo of keys. For example, I typed blah blah blah.... .... HotKeySet ("^!d", MsgBox (1, "Paused", "This script has been paused") then I ran it. Then, I hit the key combo...but no box popped up. This is what I have: Do ... ... ... Until $i = 1 HotKeySet ("+!d", MsgBox (1, "Paused", "This script has been paused") Can someone help me?
×
×
  • Create New...