-
Posts
349 -
Joined
-
Last visited
-
Days Won
2
Everything posted by j0kky
-
Hi folks, Last morning I needed to know programmatically which were my DNS(s) for the current connection, and I searched for an API which fitted my needs... I just tried dnsqueryconfig, which shows the DNS(s) used, if you have manually selected them in the past. The API is little tricky (or maybe I'm little rusty), so I decided to write a small UDF function to avoid a waste of time in the future... here you are. ; #FUNCTION# ==================================================================================================================== ; Name...........: _WinAPI_DnsQueryConfig ; Description ...: Retrieves the currently used DNS servers, if they were selected by user ; Syntax.........: _WinAPI_DnsQueryConfig() ; Return values .: On success it returns an array with the list of currently used DNS servers ; ; On failure it returns 0 and sets @error to non zero (these values are useful only for debugging reasons): ; |1 - DllCall error ; |2 - Generic error, DNS could be generated automatically ; Author ........: j0kky ; Modified ......: 1.0.0 14/11/2018 ; Link ..........: https://docs.microsoft.com/en-us/windows/desktop/api/windns/nf-windns-dnsqueryconfig ; =============================================================================================================================== Func _WinAPI_DnsQueryConfig() Local Const $DnsConfigDnsServerList = 6 Local $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", Null, "dword*", 0) If @error Then Return SetError(1, 0, 0) if $aRet[6] <= 4 Then Return SetError(2, 0, 0) Local $tagBuffer = "" For $i = 1 To ($aRet[6] / 4) $tagBuffer &= "dword;" Next Local $tBuffer = DllStructCreate($tagBuffer) $aRet = DllCall("Dnsapi.dll", "LONG", "DnsQueryConfig", "int", $DnsConfigDnsServerList, "dword", 0, "ptr", Null, "ptr", 0, "ptr", DllStructGetPtr($tBuffer), "dword*", $aRet[6]) Local $aDNS[($aRet[6] / 4) - 1] For $i = 2 to (UBound($aDNS) + 1) $aRet = DllCall("Ws2_32.dll", "str", "inet_ntoa", "dword", DllStructGetData($tBuffer, $i)) if @error Then Return SetError(1, 0, 0) $aDNS[$i - 2] = $aRet[0] Next Return SetError(0, 0, $aDNS) EndFunc
-
No, it is not. But you can develope a console application which interacts with a browser window that enable the user to login and set the right permission to your app. You can try tons of material on the FB Dev Network, you are interested in Graph API part, avoid the SDKs one. From https://developers.facebook.com/docs/sharing/web:
-
Write n strings to file, then @CRLF
j0kky replied to FrancescoDiMuro's topic in AutoIt General Help and Support
You could concatenate strings through &= operator, add the final @CRLF and then write to a file with FileWrite... -
Read in my signature
-
How to detect Qwerty vs Dvorak layout?
j0kky replied to WoodGrain's topic in AutoIt General Help and Support
That's really strange... Try this switching between the two keyboard setup without closing the application (and mantaining it on the top level). #include <WinAPI.au3> Global Const $WM_INPUTLANGCHANGE = 0x0051 $hGUI = GUICreate("My GUI") GUIRegisterMsg($WM_INPUTLANGCHANGE, "_WM_INPUTLANGCHANGE") GUISetState(@SW_SHOW) HotKeySet("{ESC}", _Exit) WinActivate($hGUI) While 1 Sleep(100) WEnd Func _WM_INPUTLANGCHANGE($hWnd, $iMsg, $wParam, $lParam) Local $aRet = DllCall("user32.dll", "HANDLE", "GetKeyboardLayout", "DWORD", 0) If @error Then ConsoleWrite("ERROR!" & @CRLF) Return EndIf ConsoleWrite("Handle: " & $aRet[0] & @CRLF & _ "Language Identifier: " & Hex(_WinAPI_LoWord($aRet[0]), 4) & @CRLF & _ "Device Identifier: " & Hex(_WinAPI_HiWord($aRet[0]), 4) & @CRLF & _ "wParam: " & $wParam & @CRLF & _ "lParam: " & $lParam & @CRLF & @CRLF) Return 'GUI_RUNDEFMSG' EndFunc Func _Exit() Exit EndFunc Then post here full console output. -
I didn't run your script and I don't know which protocol this particular procedure uses, but if you want to receive binary data, TCPRecv should have $flag = 1... Anyway what is your problem? What do you get instead of the wanted meta-data?
-
Does it work?
-
$sString = _WinAPI_WideCharToMultiByte($sString,65001,True) Why do you add this line? Have you tried to remove it?
-
Doing a quick check, I saw this: Local $bString = StringToBinary($sString,2) ;compress function $sString = BinaryToString(DllStructGetData(DllStructCreate('byte[' & $iSize & ']', $pUncompressedBuffer), 1),4) ;uncompress function You should use the same UNICODE character set.
-
How to detect Qwerty vs Dvorak layout?
j0kky replied to WoodGrain's topic in AutoIt General Help and Support
Don't you like GetKeyboardLayout? #include <WinAPI.au3> HotKeySet("{SPACE}", _GetKeyboardLayout) HotKeySet("{ESC}", _Exit) While 1 Sleep(100) WEnd Func _GetKeyboardLayout() Local $aRet = DllCall("user32.dll", "HANDLE", "GetKeyboardLayout", "DWORD", 0) If @error Then ConsoleWrite("ERROR!" & @CRLF) Return EndIf ConsoleWrite("Language Identifier: " & Hex(_WinAPI_LoWord($aRet[0]), 4) & @CRLF & _ "Device Identifier: " & Hex(_WinAPI_HiWord($aRet[0]), 4) & @CRLF & @CRLF) EndFunc Func _Exit() Exit EndFunc -
How do I keep updating Runtime in my GUI?
j0kky replied to CT83's topic in AutoIt General Help and Support
No, but you can register an AdLibRegister function which can start automatically, and when it ends, your script continues its job. EDIT: also, there is another interesting function that uses callback: _Timer_SetTimer -
How to detect Qwerty vs Dvorak layout?
j0kky replied to WoodGrain's topic in AutoIt General Help and Support
I think @kblayout macro calls GetKeyboardLayout API, but it retrieves only low order byte, so it gets only the language identifier, you need the device identifier (also known as device handle or physical layout) too that's contained in high order bytes. EDIT: On second thought, @kblayout macro calls GetKeyboardLayoutName function, which retrieves by default only language ID. -
Hi, I recently used _WinAPI_GetProcessFileName, I noticed it uses GetModuleFileNameEx function to retrieve the path, and it requires PROCESS_QUERY_INFORMATION and PROCESS_VM_READ. Well, from Vista there is another function, QueryFullProcessImageName, which requires only PROCESS_QUERY_LIMITED_INFORMATION access rights, and it allows to retrieve some process which GetModuleFileNameEx can't get because of its requirements. Here is an example which shows the issue: #include <WinAPIProc.au3> $array = ProcessList() For $i = 1 To $array[0][0] If $array[$i][1] Then $output1 = _WinAPI_GetProcessFileName2($array[$i][1]) $output2 = _WinAPI_GetProcessFileName($array[$i][1]) If @error Then $output2 = -1 If Not ($output1 = $output2) Then If Not ($output1 = -1) Then ConsoleWrite($output1 & "--> _WinAPI_GetProcessFileName2" & @CRLF) If Not ($output2 = -1) Then ConsoleWrite($output2 & "--> _WinAPI_GetProcessFileName" & @CRLF) EndIf EndIf Next Func _WinAPI_GetProcessFileName2($iPID) Local $dwDesiredAccess = __Iif($__WINVER < 0x0600, 0x0410, 0x1000), $sPath = "" Local $aRet = DllCall("Kernel32.dll", "HANDLE", "OpenProcess", "DWORD", $dwDesiredAccess, "BOOL", False, "DWORD", $iPID) If @error Or $aRet[0] = Null Or $aRet[0] = 0 Or $aRet[0] = Ptr(0) Then Return SetError(-1, 0, -1) Local $hProcess = $aRet[0] If $dwDesiredAccess = 0x0410 Then $aRet = DllCall(@SystemDir & "\psapi.dll", "DWORD", "GetModuleFileNameExW", "HANDLE", $hProcess, "HANDLE", 0, "wstr", "", "DWORD", 65535) Else $aRet = DllCall("Kernel32.dll", "BOOL", "QueryFullProcessImageNameW", "HANDLE", $hProcess, "DWORD", 0, "wstr", "", "dword*", 65535) EndIf If Not (@error Or $aRet[0] = 0) Then $sPath = $aRet[3] DllCall("Kernel32.dll", "BOOL", "CloseHandle", "HANDLE", $hProcess) Return $sPath = "" ? SetError(-1, 0, -1) : $sPath EndFunc ;==>_GetProcessPath
-
Autoit Defective When Compile With Options
j0kky replied to minhvnnhut's topic in AutoIt General Help and Support
Copy&Paste here the console output of this script, so we can have an idea about the program which is interfering. $array = ProcessList() For $i = 1 to $array[0][0] $output = _PidGetPath($array[$i][1]) If Not ($output = "0") Then ConsoleWrite($output & @CRLF) Next Func _PidGetPath($pid = "", $strComputer = 'localhost') If $pid = "" Then $pid = WinGetProcess(WinGetTitle("")) $wbemFlagReturnImmediately = 0x10 $wbemFlagForwardOnly = 0x20 $colItems = "" $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_Process WHERE ProcessId = " & $pid, "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly) If IsObj($colItems) Then For $objItem In $colItems If $objItem.ExecutablePath Then Return $objItem.ExecutablePath Next EndIf EndFunc ;==>_PidGetPath -
Cool way Mikell! I didn't know about its existence
-
Another fast solution which avoids _ArrayDelete function: #include <Array.au3> Local $Array1[5] = [1,2,3,4,5] Local $Array2[5] = [7,4,5,6,3] _ArrayDisplay($Array2) Func _ArrayCompare(ByRef $a1, ByRef $a2) Local $nOldSize = UBound($a2) Local $a3[$nOldSize], $nNewSize = $nOldSize For $i = 0 To UBound($a1) - 1 For $j = 0 To $nOldSize - 1 If Not $a3[$j] And ($a1[$i] = $a2[$j]) Then $a3[$j] = 1 $nNewSize -= 1 EndIf Next Next Local $a4[$nNewSize], $j = 0 For $i = 0 To $nOldSize - 1 If Not $a3[$i] Then $a4[$j] = $a2[$i] $j += 1 EndIf Next Return $a4 EndFunc _ArrayDisplay(_ArrayCompare($Array1, $Array2)) An array ($a3) can be saved if $Array2 could be edited.
-
Txt to CSV and some other information...
j0kky replied to FrancescoDiMuro's topic in AutoIt General Help and Support
A simple example: #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> Global Const $EN_KILLFOCUS = 0x0200 Global $hGUI = GUICreate("My gui") Global $hEdit1 = GUICtrlCreateEdit("", 10, 30) Global $hEdit2 = GUICtrlCreateEdit("Prova a cliccarmi senza scrivere niente nel primo riquadro", 180, 230) GUIRegisterMsg($WM_COMMAND, "_WM_COMMAND") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() If $nMsg = $GUI_EVENT_CLOSE Then Exit WEnd Func _WM_COMMAND($hwnd, $msg, $wparam, $lparam) If _WinAPI_LoWord($wparam) = $hEdit1 _ And _WinAPI_HiWord($wparam) = $EN_KILLFOCUS _ And GUICtrlRead($hEdit1) = "" Then ControlFocus($hGUI, "", $hEdit1) Return $GUI_RUNDEFMSG EndFunc -
Txt to CSV and some other information...
j0kky replied to FrancescoDiMuro's topic in AutoIt General Help and Support
for example you could add an AdLibRegister function which checks for the field content\focus, when it tries the field has lost its focus and it has no content, the function does something... But there are lots of solutions, another one is registering with GUIRegisterMsg for WM_COMMAND message to receive EN_KILLFOCUS notification and check with the called function for the content in the field. -
Txt to CSV and some other information...
j0kky replied to FrancescoDiMuro's topic in AutoIt General Help and Support
@FrancescoDiMuro: my italian friend, the help file has a beautiful guide on event mode GUI, then you can try tons of related snippets on the wiki and on this forum -
Simple StringRegExp question [SOLVED]
j0kky replied to ludocus's topic in AutoIt General Help and Support
StringRegExpReplace("hello\something.something", "[\\\.\^\$\|\[\(\{\*\+\?\#\)\]\}]", "\\\0") -
Simple StringRegExp question [SOLVED]
j0kky replied to ludocus's topic in AutoIt General Help and Support
It indicates a non-captouring group, try to delete it and see what happens to console output -
Simple StringRegExp question [SOLVED]
j0kky replied to ludocus's topic in AutoIt General Help and Support
@mikell: you're right, I didn't read he needs exatly those three strings, my new version: $s = "test-1.5-A, test-1,5-A, test-11/5-A" $a = StringRegExp($s, "test-(?:1\.5|1,5|11/5)-A", 3) For $n In $a ConsoleWrite($n & @CRLF) Next which can be easily changed at need if he wants to search for more string version adding other characters between parentesis. -
String($oForm.value) not String($oForm.value())
-
Simple StringRegExp question [SOLVED]
j0kky replied to ludocus's topic in AutoIt General Help and Support
$a = StringRegExp("test-1.5-A, test-1,5-A, test-11/5-A", "test-.+?-A", 3) For $n In $a ConsoleWrite($n & @CRLF) Next