Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/20/2020 in all areas

  1. @ScriptLineNumber knows the #include. I can write Func this($var = @ScriptLineNumber) and it knows, just knows, now, somewhere ( in AutoIt ) is kept\noted. @ScriptFullPath and @ScriptName are that of the executed script and is the same if called in an included script. As it should and should not be otherwise. Hence there are missing macros, call them @IncludeScriptFullPath and @IncludeScriptName. Once compiled, the @IncludeScriptName and @ScriptName would obviously have the same value but while coding, these would come in handy. I came up with the inspiration and that is perfectly possible to do, while writing the "register almost all 219 messages (UDF/tool)". Not that is a great achievement as a tool but the ConsoleWrite("Script.au3"(@ScriptLineNumber) : note.. ) shows to know where to jump to. All that was missing was the @IncludeScriptName, to not hardcode the script name. And since @ScriptLineNumber knows the #include, where is my macro !!! I hope ( and honestly believe ), that is a useful macro, and a motion to add these be taken to the Overlord for immediate implementation. PS: I understand that there are more pressing things to do but, this may be just there, without much to do to the AutoIt code, other than add the macro. I'll add it to the trac, see where it goes. Added ticket # 3766.
    1 point
  2. This : #RequireAdmin #NoTrayIcon #include <AutoItConstants.au3> #include <StringConstants.au3> #include <Array.au3> #include <WinAPIFiles.au3> _WinAPI_Wow64EnableWow64FsRedirection(False) Local $aFeature = _Windows_Get_Features() _ArrayDisplay ($aFeature) Func _Windows_Get_Features() Local $i_Dism_Run = Run("DISM /online /english /get-features /format:table", "", @SW_HIDE, BitOR($STDERR_CHILD, $STDOUT_CHILD)) ProcessWaitClose ($i_Dism_Run) Local $s_OutputDism = StdoutRead($i_Dism_Run) Local $array = StringSplit ($s_OutputDism, @CRLF, $STR_ENTIRESPLIT), $tmp, $final [$array[0]][2], $count For $i = 1 to $array[0] $tmp = StringSplit ($array[$i], "|") If $tmp[0] <> 2 Or StringLeft($array[$i], 4) = "----" Or StringLeft($array[$i],12) = "Feature Name" Then ContinueLoop $final[$count][0] = $tmp [1] $final[$count][1] = $tmp [2] $count += 1 Next ReDim $final[$count][2] Return $final EndFunc ;==>_Windows_Get_Features
    1 point
  3. Change: Func WideMode() $WinCoords = WinGetPos($GUI) If $WideM = 0 Then WinMove($GUI, '', $WinCoords[0], $WinCoords[1], 605, $WinCoords[3]) GUICtrlSetPos($ButtonWide, 575, 20, 7, 50) $WideM = 1 Else WinMove($GUI, '', $WinCoords[0], $WinCoords[1], 150, $WinCoords[3]) GUICtrlSetPos($ButtonWide, 120, 20, 7, 50) $WideM = 0 EndIf _GuiRoundCorners($GUI, $i_x1, $i_y1, $i_x3, $i_y3) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< EndFunc ;==>WideMode and it works. Maybe other ways to start a repaint of the Gui are also possible.
    1 point
  4. emendelson, This shows how to use my Scrollbar_Ex UDF in your script: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <Array.au3> #include "GUIScrollbars_Ex.au3" Opt("GUIOnEventMode", 1) Global $gh, $hAperture $ptrselmsg = "Select a printer for this document:" $printername = 0 Global $printer_list_ext[1] Global $printer_radio_array[1] GetPrinter($ptrselmsg) Do Sleep(100) Until $printername Exit Func GetPrinter($ptrselmsg) ; based on the excellent code by mfectau at ; https://www.autoitscript.com/forum/topic/40388-printer-selector-gui/?do=findComment&comment=869533 Local $printer_list[1] Local $regprinters = "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Devices" Local $currentprinter = RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\", "Device") Local $defaultprinter = StringLeft($currentprinter, StringInStr($currentprinter, ",") - 1) Local $i = 1 Local $erreur_reg = False While 1 $imprimante = RegEnumVal($regprinters, $i) If @error Then ExitLoop Else _ArrayAdd($printer_list, $imprimante) $printer_list[0] += 1 _ArrayAdd($printer_list_ext, $imprimante & "," & RegRead($regprinters, $imprimante)) $printer_list_ext[0] += 1 EndIf $i += 1 WEnd ; Just for test ################################################################################# For $i = 1 To 0 ; Increase this number to get a longer list _ArrayAdd($printer_list, "Test printer " & $i) $printer_list[0] += 1 _ArrayAdd($printer_list_ext, "Test printer " & $i & "," & "RegRead " & $i) $printer_list_ext[0] += 1 Next ; ############################################################################################### If UBound($printer_list) >= 2 Then ; if 2 or more printers available, we show the dialog Local $font = "Verdana" Local $position_vertical = 5 ; 0 $gh = GUICreate($ptrselmsg, 400, 400) GUISetFont(10, 400, 0, $font) GUISetOnEvent($GUI_EVENT_CLOSE, "CLOSEClicked") $okbutton = GUICtrlCreateButton("OK", 10, 365, 50, 25) GUICtrlSetOnEvent($okbutton, "OKButton") Local $AccelKeys[2][2] = [["{ENTER}", $okbutton], ["^O", $okbutton]] GUISetAccelerators($AccelKeys) GUISetState(@SW_SHOW, $gh) Local $groupheight = (UBound($printer_list) + 1) * 25 ;30 Local $hCurrent_GUI = $gh If $groupheight > 335 Then ; Height chosen according to the size of the main GUI of course ; We need scrollbars, so create a child GUI $hAperture = GUICreate("", 380, 335, 10, 10, $WS_POPUP, $WS_EX_MDICHILD, $gh) ; Generate the scrollbars $aAperture = _GUIScrollbars_Generate($hAperture, 0, $groupheight) ; Show the GUI GUISetState(@SW_SHOW, $hAperture) ; Set handle of GUI in which to create the controls $hCurrent_GUI = $hAperture Else ; No scroll bars GUICtrlCreateGroup("Available printers:", 10, 10, 380, $groupheight) EndIf GUISwitch($hCurrent_GUI) For $i = 1 To $printer_list[0] $position_vertical = $position_vertical + 25 ;30 $radio = GUICtrlCreateRadio($printer_list[$i], 20, $position_vertical, 350, 20) _ArrayAdd($printer_radio_array, $radio) $printer_radio_array[0] += 1 If $currentprinter = $printer_list_ext[$i] Then GUICtrlSetState($radio, $GUI_CHECKED) EndIf Next EndIf EndFunc ;==>GetPrinter Func OKButton() For $i = 1 To $printer_radio_array[0] If GUICtrlRead($printer_radio_array[$i]) = $GUI_CHECKED Then $printername = StringLeft($printer_list_ext[$i], StringInStr($printer_list_ext[$i], ",") - 1) EndIf Next GUIDelete($gh) GUIDelete($hAperture) ConsoleWrite($printername & @LF) EndFunc ;==>OKButton Func CLOSEClicked() GUIDelete($gh) GUIDelete($hAperture) $printername = "nul" ConsoleWrite($printername & @LF) EndFunc ;==>CLOSEClicked I made a few other changes too - such as why not use the [0] element of your arrays to hold the count. Please ask if you have any questions. M23
    1 point
  5. you can use a listview with checkbutton (andset a control only one check is flagged work ), or if you want only radio button controll here
    1 point
  6. > Wouldn't it be more simple to just revert to GUICtrlCreateListView? Yes. Emphatically. I actually looked into that, and decided it would be intractable. Because basically I didn't see the forest for the trees. Here's the explanation, for what it's worth. The way the code is now, I create and populate my ListView like this: _GUICtrlListView_Create() _GUICtrlListView_AddColumn() ... _GUICtrlListView_AddItem()/_GUICtrlListView_AddSubItem() Then when I want to operate on the selected ListView item: $index = _GUICtrlListView_GetSelectedIndices() _GUICtrlListView_GetItemText($listview, $index) My whole code base essentially operates by passing that $index around and using it to access the ListView item. I thought that if I created the ListView using GUICtrlCreateListView(), then I had to populate it with GUICtrlCreateListViewItem(), which seems to follow a different paradigm -- each ListView item gets its own ControlID, and you access by ControlID instead of by index. Not accessing by index was going to mess with a bunch of my code. But it seems I was wrong about that. Even if you use GUICtrlCreateListView() to create the ListView, you can still populate it with _GUICtrlListView_AddColumn() and _GUICtrlListView_AddItem()/SubItem(). And then you can access by index. So this is probably the way to go. I just needed to think outside the box a little. Thanks, @careca. /John
    1 point
  7. my way AutoItSetOption("WinTitleMatchMode",2) WinSetOnTop("Chrome","",1)
    1 point
  8. in my windows 7 work perferct your code #include <AutoItConstants.au3> Run("C:\Program Files\Google\Chrome\Application\chrome.exe") MsgBox(0,'','chrome is up ?') Local $chrome = '[CLASS:Chrome_WidgetWin_1]' WinActivate($chrome) Local $hwnd = WinWaitActive($chrome, '', 10) ;~ MouseClick('left', 500, 500) ;focus chrome WinSetOnTop($hwnd, '', $WINDOWS_ONTOP) WinActivate($hwnd) ;reset top most window ;~ WinSetState($chrome, '', @SW_MAXIMIZE)) ;reset top most window ;~ WinSetState($chrome, '', @SW_ENABLE)) ;reset top most window MsgBox(0, @ScriptLineNumber&':'&$hwnd, 'Set OnTop')
    1 point
  9. Could you try the advanced mode with your code? If it doesnt work, try this one. Opt("WinTitleMatchMode", 4) ;1=start, 2=subStr, 3=exact, 4=advanced, -1 to -4=Nocase WinWait("[W:286;H:74]","",30) ConsoleWrite('popped up' & @CRLF)
    1 point
  10. It doesn't ignore anything, on the contrary. Under the hood, AutoIt parses the format string and since the type specifier is i (integer) it automagically invokes Int(argument) for you. Contrary to C with printf(), AutoIt is smart enough to implicitely perform necessary conversions for you. StringFormat("%f", 6) yields 6 after converting 6 to a double StringFormat("%f", ".3zz") yields 0.300000 after converting the string ".3zz" to a double. StringFormat("%12i", "-.5abc") yields 0 after converting the string "-.5abc" to an int. In C the first and second calls would likely produce garbage or core dump because 6 would be an integer (typically 32 bit), shorter than a double in memory (64 bit), causing an exception or converting data beyond the actual int boundary. The third call would definitely yield garbage.
    1 point
  11. Are both the target program and your Autoit the same bit-wise (Program = 32bit and Autoit = 32bit)? https://www.autoitscript.com/autoit3/docs/functions/ControlTreeView.htm "Remarks: As AutoIt is a 32-bit application some commands are not available when referencing a 64-bit application as Explorer when running on 64-bit Windows."
    1 point
  12. I had to create this DXRW4E. I used Enum in the function for removing the use of magic numbers and readability too. #include <Constants.au3> Local $sData = FileRead(@ScriptFullPath) _SourceCleanup($sData) MsgBox($MB_SYSTEMMODAL, '', $sData) ; $iFlags = 1 Remove multi-comments (#cs or #comment-start & #ce or #comment-end) ; $iFlags = 2 Remove single-line comments (; Comment ... ) ; $iFlags = 4 Strip all leading white space; ; $iFlags = 8 Strip all trailing white space. ; $iFlags = 16 Remove lines containing only @LF, @CR or @CRLF. ; $iFlags = 32 Remove lines containing only @LF, @CR, @CRLF or whitespace characters. ; $iFlags = 64 Remove #region or #endregion directives. Func _SourceCleanup(ByRef $sData, $iFlags = Default) ; Regular expressions by DXRW4E & function layout by guinness. Local Enum Step *2 $eCLEANUP_MULTICOMMENTS, $eCLEANUP_SINGLECOMMENTS, $eCLEANUP_LEADINGWS, $eCLEANUP_TRAILINGWS, $eCLEANUP_EMPTYLINESONLY, _ $eCLEANUP_STRIPEMPTYLINESPLUSWS, $eCLEANUP_REGIONS If $iFlags = Default Then $iFlags = BitOR($eCLEANUP_MULTICOMMENTS, $eCLEANUP_SINGLECOMMENTS, $eCLEANUP_LEADINGWS, $eCLEANUP_TRAILINGWS, $eCLEANUP_EMPTYLINESONLY, _ $eCLEANUP_STRIPEMPTYLINESPLUSWS, $eCLEANUP_REGIONS) EndIf If BitAND($iFlags, $eCLEANUP_MULTICOMMENTS) = $eCLEANUP_MULTICOMMENTS Then $sData = StringRegExpReplace($sData, '(?is)(\n\h*#(?:cs|comments?-start)[^\n]*\n.*?\n\h*#(?:ce|comments?-end)[^\n]*)', @LF) EndIf If BitAND($iFlags, $eCLEANUP_SINGLECOMMENTS) = $eCLEANUP_SINGLECOMMENTS Then $sData = StringRegExpReplace($sData, '\n\h*;[^\n]*', '') EndIf If BitAND($iFlags, $eCLEANUP_LEADINGWS) = $eCLEANUP_LEADINGWS Then $sData = StringRegExpReplace($sData, '\n\h+', @LF) EndIf If BitAND($iFlags, $eCLEANUP_TRAILINGWS) = $eCLEANUP_TRAILINGWS Then $sData = StringRegExpReplace($sData, '\h+(?=[\r\n])', '') EndIf If BitAND($iFlags, $eCLEANUP_EMPTYLINESONLY) = $eCLEANUP_EMPTYLINESONLY Then $sData = StringRegExpReplace($sData, '\n[\r\n]*\n', @LF) EndIf If BitAND($iFlags, $eCLEANUP_STRIPEMPTYLINESPLUSWS) = $eCLEANUP_STRIPEMPTYLINESPLUSWS Then $sData = StringRegExpReplace($sData, '\n\s*\n', @LF) EndIf If BitAND($iFlags, $eCLEANUP_REGIONS) = $eCLEANUP_REGIONS Then $sData = StringRegExpReplace($sData, '(?i)\n\h*(?:#Region|#EndRegion)(?!\w)[^\n]*\n', @LF) EndIf EndFunc ;==>_SourceCleanup
    1 point
×
×
  • Create New...