Jump to content

jguinch

Active Members
  • Posts

    2,003
  • Joined

  • Last visited

  • Days Won

    13

Community Answers

  1. jguinch's post in Having issues with CMD Netsh was marked as the answer   
    Try this :
    Run(@WindowsDir & "\sysnative\cmd.exe /c netsh mbn show interface > " & @DesktopDir & "\" & @Computername & ".txt")
  2. jguinch's post in Popup Menu on Label by left click was marked as the answer   
    Here is one way :
    #include <GUIConstantsEx.au3> Global $hMain = GUICreate("Context Menu") $id_Label = GUICtrlCreateLabel("Click me !", 10, 10) $id_Context = GUICtrlCreateContextMenu($id_Label) $id_MenuItem1 = GUICtrlCreateMenuItem("Item 1", $id_Context) $id_MenuItem2 = GUICtrlCreateMenuItem("Item 2", $id_Context) GUISetState() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $id_Label _ShowMenu( GUICtrlGetHandle($id_Context) ) EndSwitch WEnd Func _ShowMenu($hMenu) DllCall("user32.dll", "int", "TrackPopupMenuEx", "hwnd", $hMenu, "int", 0, "int", MouseGetPos(0), "int", MouseGetPos(1), "hwnd", $hMain, "ptr", 0) EndFunc
  3. jguinch's post in I need to get the domain name of a remote computer using the principle of your example using user credentials was marked as the answer   
    You can specify the login/password with something like this :
    $objSWbemLocator = ObjCreate("WbemScripting.SWbemLocator") $objWMIService = $objSWbemLocator.ConnectServer($strComputer,"root\CIMV2",$strUser, $strPassword)
  4. jguinch's post in Help optimize and convert code to StringRegExpReplace was marked as the answer   
    @Mikell : yours works because the " is just before a
    StringReplace( StringRegExpReplace($sPath, '\h*\\+\h*', '\\'), '"', '') )
  5. jguinch's post in procmon window can't be hidden was marked as the answer   
    It works for me, with just removing the /Minimized parameter :
    #RequireAdmin Run("procmon.exe /Nofilter /accepteula /Quiet /BackingFile ProcmonTrace.PML", "", @SW_HIDE)
  6. jguinch's post in Help with URL showing in IE window when toolbar set to False was marked as the answer   
    Did you try _IECreateEmbedded ?
  7. jguinch's post in Missing separator character before keyword was marked as the answer   
    So, add a space before each ByRef
  8. jguinch's post in Only 1 instance of my script was marked as the answer   
    You can add this kind of code at the begining of your script :
    While ProcessList(@ScriptName)[0][0] > 1 WEnd ; And then your code... MsgBox(0, "", "Hello") Compile and run it twice, you will see the 2nd script waits until the first one does not exist
  9. jguinch's post in StringReplace/StringRegExpReplace function problem was marked as the answer   
    $sInput = "index.php?var1=value1&var2=&var3=15&var4=-5" $aExtract = StringRegExp($sInput, "[?&]([^=]+)=([^&]*)", 3) For $i = 0 To UBound($aExtract) - 1 Step 2 ; ConsoleWrite("$" & $aExtract[$i] & "=" & $aExtract[$i + 1] & @CRLF) Assign($aExtract[$i], $aExtract[$i + 1]) Next ConsoleWrite("$var1=" & $var1 & @CRLF & _ "$var2=" & $var2 & @CRLF & _ "$var3=" & $var3 & @CRLF & _ "$var4=" & $var4)
  10. jguinch's post in Need to find all Virtual Comports with VID 403 and PID 6001 was marked as the answer   
    Did you search in the registry ?
    I looked at my COM1 device in the registry, so maybe you could have a HKLMSYSTEMCurrentControlSetEnumFTDIBUSVID_0403+PID_6001+A901R735A0000 key with its FriendlyName, and then the Device Parameters subkey containing the PortName value ?
  11. jguinch's post in StringRegExpReplace replaces everything in the same place was marked as the answer   
    Sorry, I didn't understand what was the expected result.
    #include <Array.au3> $t='<tr><td rowspan="1" colspan="1" data-title="Product">Windows 8</td><td rowspan="1" colspan="1" data-title="Description">Country variant</td><td rowspan="1" colspan="1" data-title="Release">RTM</td></tr><tr><td rowspan="1" colspan="1" data-title="Product">windows 8.1</td><td rowspan="1" colspan="1" data-title="Description">Country variant</td><td rowspan="1" colspan="1" data-title="Release">Technical Preview</td></tr>' $aRet = StringRegExp($t, '"(?:Product|Release)">([^<]+)', 3) For $i = 0 To UBound($aRet) - 1 Step 2 ConsoleWrite($aRet[$i] & " [" & $aRet[$i + 1] & "]" & @CRLF) Next
  12. jguinch's post in controlgetpos and true position within an app - problem was marked as the answer   
    You can use WinGetPos with a control handle, so you will have its position/dimensions relative to the screen :
    Run("notepad.exe") $hWnd = WinWait("[CLASS:Notepad]") $hEdit = ControlGetHandle($hWnd, "", "[CLASS:Edit; INSTANCE:1]") $aEditPos = WinGetPos($hEdit) ConsoleWrite("LEFT : " & $aEditPos[0] & @CRLF & _ "TOP : " & $aEditPos[1] & @CRLF & _ "WIDTH : " & $aEditPos[2] & @CRLF & _ "HEIGHT : " & $aEditPos[3] & @CRLF )
  13. jguinch's post in How to find first and last word of sentence with Regular Expression was marked as the answer   
    #Include <Array.au3> $sentence2 = "If Apple = 15 Then" $words = StringRegExp($sentence2, "(?m)\W*(\w+).*?(\w+)\W*$", 1) _ArrayDisplay($words) Here is a small explanation :
    (?m) : multiline mode. With this mode, ^ and $ operates on each line instead of the whole string
    W* : any non-word character, 0 or more times
    (w+) : capturing group. any word character, one or more times
    .*? : anything, one or more times. ? takes the smallest occurence
    $ : end of line or end of string
  14. jguinch's post in After resuming TimerInit() from pause, time starts from beginning... was marked as the answer   
    You can just to that :
    Else $TimeToSpend = $TimeLeft $Timer = TimerInit() $Pause = 0 EndIf
  15. jguinch's post in How to get the list of windows opened in task bar. was marked as the answer   
    A beginning, but not perfect:
    #Include <WinAPI.au3> #Include <WindowsConstants.au3> $aList = WinList() For $i = 1 To $aList[0][0] $iExStyle = _WinAPI_GetWindowLong($aList[$i][1], $GWL_EXSTYLE) ; get the extended style of each Window If NOT BitAND($iExStyle, $WS_EX_TOOLWINDOW) AND _ ; Search for windows without $WS_EX_TOOLWINDOW extended style BitAND(WinGetState($aList[$i][1]), 2 ) Then ; And only visible windows ConsoleWrite($aList[$i][0] & @CRLF) EndIf Next
  16. jguinch's post in GUI color wont be apply was marked as the answer   
    Your GUISetBkColor syntax is not correct : the parameters are in the wrong order
  17. jguinch's post in Unattended software installation was marked as the answer   
    If you know what is the silent parameter, you just have to put it in your Run/RunWait/ShellExecute/ShellExecuteWait command.Be careful with the simples quotes
    For example, with "setup.exe" /s : RunWait( '"setup" /s')
  18. jguinch's post in Intercept a command? was marked as the answer   
    File Renamer Turbo installer seems to use NSIS.
    So you can easily set the destination directory with /D=<Destination> :
    RunWait("filerenamerturbo-setup.exe /S /D=c:\apps\FileRenamerTurbo") ; replace it by your path
  19. jguinch's post in [3 in 1] Excel + Array + StringRegExp was marked as the answer   
    For the second question :
    #Include <Array.au3> Local $arr[6] $arr[0] = "Earth" $arr[1] = "Fire" $arr[2] = "Fire" $arr[3] = "Earth" $arr[4] = "Water" $arr[5] = "Air" Local $iCount Local $sElems = $arr[0] & @CRLF For $i = 1 To UBound($arr) - 1 $sElems &= $arr[$i] & @CRLF $iCount = UBound( StringRegExp($sElems, "(?i)\Q" & $arr[$i] & "\E\R", 3)) If $iCount > 1 Then $arr[$i] &= "(" & $iCount & ")" Next _ArrayDisplay($arr) Edit : This method only works if the strings don't contain any carriage return
  20. jguinch's post in Check if a window is not responding or not was marked as the answer   
    You can use _WinAPI_IsHungAppWindow for this
  21. jguinch's post in Creation time ftp was marked as the answer   
    _FTP_ListToArrayEx ?
  22. jguinch's post in Start Autoit script when user open a specific file was marked as the answer   
    I think >this post could help you
  23. jguinch's post in Getting Full Path After The Script File Has Been Renamed was marked as the answer   
    With _>ProcessGetPathEx, you can get the real full path of your running process. There is probably something easier...
    #include <Security.au3> #include <WinAPI.au3> #include <WinAPIInternals.au3> ; _SetDebugPriv() ; seems not necessary here $OldName = @AutoItExe While 1 $sProcessPath = _ProcessGetPathEx( @AutoItPID) If $OldName <> $sProcessPath Then MsgBox(0, "The program has been renamed", "The new name: " & $sProcessPath) $OldName = $sProcessPath EndIf Sleep(1000) WEnd Func _SetDebugPriv() Local $h_curproc = _WinAPI_GetCurrentProcess() Local $h_token = _Security__OpenProcessToken($h_curproc, _ BitOR($TOKEN_ADJUST_PRIVILEGES, $TOKEN_QUERY)) If Not $h_token Then Return SetError(2, 0, 0) EndIf Local $n_sdn = _Security__LookupPrivilegeValue("", $SE_DEBUG_NAME) Local $t_tokenpriv = DllStructCreate("dword;dword;long;dword") Local $p_tokenpriv = DllStructGetPtr($t_tokenpriv) DLLStructSetData($t_tokenpriv, 1, 1) DLLStructSetData($t_tokenpriv, 2, $n_sdn) DLLStructSetData($t_tokenpriv, 3, 0) DLLStructSetData($t_tokenpriv, 4, $SE_PRIVILEGE_ENABLED) Local $n_tokensize = DllStructGetSize($t_tokenpriv) Local $b_ret = _Security__AdjustTokenPrivileges($h_token, False, _ $p_tokenpriv, $n_tokensize) _WinAPI_CloseHandle($h_token) Return SetError(Not $b_ret, 0, $b_ret) EndFunc ; @param1 = process name or pid ; @param2 = default 0 = drive\etc format ; true = native system path format Func _ProcessGetPathEx($v_process, $b_native = 0) Local $i_pid = ProcessExists($v_process) If Not $i_pid Then ; process does not exist Return SetError(1, 0, "") EndIf Local $sz_filepath = "" ; are we working with anything less than vista? If __WINVER() < 0x0600 Then ; _WinAPI_GetProcessFileName seems misleading $sz_filepath = _WinAPI_GetProcessFileName($i_pid) Return SetError(@error, @extended, $sz_filepath) EndIf ; vista and above, should help with possible 64bit issues as well Local $h_k32 = DllOpen("Kernel32.dll") If @error Or Not $h_k32 Then ; could not open kernel32.dll Return SetError(2, 0, 0) EndIf Local Const $pgp_PROCESS_QUERY_LIMITED_INFORMATION = 0x1000 Local Const $pgp_PROCESS_QUERY_INFORMATION = 0x0400 Local Const $pgp_PROCESS_NAME_NATIVE = 0x00000001 ; open process with query info only Local $a_openprocess = DllCall($h_k32, "handle", "OpenProcess", _ "long", BitOR($pgp_PROCESS_QUERY_INFORMATION, _ $pgp_PROCESS_QUERY_LIMITED_INFORMATION), _ "int", 0, "long", $i_pid) Local $i_err = @error If $i_err Or Not IsArray($a_openprocess) Then DllClose($h_k32) ; error code from dllcall sent as extended Return SetError(3, $i_err, 0) EndIf Local $h_openproc = $a_openprocess[0] Local $n_native = $b_native ? $pgp_PROCESS_NAME_NATIVE : 0 Local $a_query = DllCall($h_k32, "bool", "QueryFullProcessImageNameW", _ "handle", $h_openproc, "dword", $n_native, "wstr", "", "int*", 4096) $i_err = @error If $i_err Or Not IsArray($a_query) Then DllClose($h_k32) ; error code from dllcall sent as extended Return SetError(4, $i_err, 0) EndIf _WinAPI_CloseHandle($h_openproc) DllClose($h_k32) ; return string length as extended Return SetError(0, $a_query[4], $a_query[3]) EndFunc
  24. jguinch's post in Replace text that does not match a givin RegExp was marked as the answer   
    SmOke_N's way can be something like this :
    #Include <Array.au3> ; just for _ArrayDisplay $text = "here is the link http://www.my-li-nk.com that should stay as is, and here are-the-dashes-that-need-to-be replaced with spaces." ; Extract all links $aLinks = StringRegExp($text, "(?i)(\b(?:https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])", 3) _ArrayDisplay($aLinks, "All links") ; Replace all links by a mark : <link{x}> For $i = 0 To UBound($aLinks) - 1 $text = StringReplace($text, $aLinks[$i], "<link{" & $i & "}>", 1) Next ConsoleWrite($text & @CRLF) ; replace all dashes between two words by a blank $text = StringRegExpReplace($text, "(?<=\w)-(\w+)", " $1") ConsoleWrite($text & @CRLF) ; Replace each mark by its variable name $text = StringReplace($text, '"', '""') $text = StringRegExpReplace('"' & $text & '"', "<link\{(\d+)\}>", '" & \$aLinks[$1] & "') ConsoleWrite($text & @CRLF) ; Replace each variable by its value $text = Execute($text) ConsoleWrite($text & @CRLF)
  25. jguinch's post in I need help - StringRegExp was marked as the answer   
    The last StringRegExp should return an array, not a string.
    You should use ConsoleWrite(StringRegExp($aArray[$i], '(?i)<published>(.*?)</published>', 1, $nOffset)[0]) instead, but in your case, $nOffset is out of range.
    I don't really understand why you want to use $nOffset for, but maybe this code would match with your need :
    Local $XML = FileRead(@ScriptDir & '\default.xml') Local $aArray = StringRegExp($XML, '(?s)<entry[^>]*>.*?</entry>', 3) If NOT @error Then For $i = 0 To UBound($aArray) - 1 $aPublisher = StringRegExp($aArray[$i], '(?i)<published>(.*?)</published>', 1) ConsoleWrite ( $aPublisher[0] ) Next EndIf
×
×
  • Create New...