Jump to content

Search the Community

Showing results for tags 'c++'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office


  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Member Title




Found 22 results

  1. hi, I made a software for managing dtmf tones. For the moment the pc audio output is connected to an Arduino with an mt8870 module which decodes the tone and returns the correct value via serial. I wanted to make sure not to use external hardware and so I tried with the bass.dll library to read the microphone input. I can read the volume and interpret the data, but I haven't found a way to handle the dtmfs. Searching the internet I found a project with source in Delphi and C++ with examples to import a library called DTMFScanner.dll (https://www.3delite.hu/Object Pascal Developer Resources/download.html#dtmf) the DTMFScannerLibrary.h file is attached to this post. There are examples on how to use the external library with Delphi too I tried to modify an example of the bass library to integrate the request for the DTMFScanner.dll library but it always returns the value 0. I'm afraid I'm using the wrong library recall method This is my script: #include 'Bass.au3' #include <WinAPICOM.au3> #include <WinAPIConv.au3> #include <Array.au3> Global $hStream, $iLong, $nLeft, $nRight, $iColor Global $ID_GUI = GUICreate('BASS Audio Levels', 190, 200, -1, -1, Default, 0x00000008) GUICtrlCreateLabel('L', 52, 20, 34, 22) GUICtrlCreateLabel('R', 82, 20, 34, 22) Global $ProgressBarL = GUICtrlCreateProgress(50, 40, 14, 100, 0x04) Global $ProgressBarR = GUICtrlCreateProgress(80, 40, 14, 100, 0x04) Global $InputL = GUICtrlCreateLabel('', 50, 150, 34, 22) Global $InputR = GUICtrlCreateLabel('', 80, 150, 34, 22) Global $DtmlDLL Global $parameters = DllStructCreate("ptr FileName; dword Channel; float Treshold; int Thread; int64 User; ptr DetectCallback") Global $inputChannel = 3 ;<------- my mic input Global $result1 GUISetOnEvent(-3, '_Exit') Opt('GUIOnEventMode', 1) GUISetState(@SW_SHOW, $ID_GUI) _BASS_Startup(@ScriptDir & '\Bass.dll') If @error Then Exit MsgBox(16, 'BASS Function Error', 'EC1') _BASS_Init(16, -1, 44100, 0, 'NULL') If @error Then Exit MsgBox(16, 'BASS Function Error', 'EC2') _BASS_RecordInit(-1) If @error Then Exit MsgBox(16, 'BASS Function Error', 'EC3') ; choose input. I use n.3 in this moment _BASS_RecordSetInput($inputChannel, $BASS_INPUT_TYPE_WAVE, 1) ;~ Global $hStream = _BASS_RecordStart(44100, 2, 0, 0) Global $hStream = _BASS_RecordStart(44100, 2, $BASS_SAMPLE_FLOAT);_WinAPI_MakeLong(0, 10)) If @error Then Exit MsgBox(16, 'BASS Function Error', 'EC4') _BASS_ChannelPlay($hStream, True) If @error Then Exit MsgBox(16, 'BASS Function Error', 'EC5') While _BASS_ChannelIsActive($hStream) ;********************************* VUMETER WITH BASS.DLL ******************************************************* $iLong = _BASS_ChannelGetLevel($hStream) $nLeft = _BASS_LoWord($iLong) / 32768 * 100 $nRight = _BASS_HiWord($iLong) / 32768 * 100 $nLeft = Round($nLeft) $nRight = Round($nRight) ; $iColor = 0xFFFFFF If $nLeft > 99 Then $iColor = 0xFF0000 GUICtrlSetColor($ProgressBarL, $iColor) $iColor = 0xFFFFFF If $nRight > 99 Then $iColor = 0xFF0000 GUICtrlSetColor($ProgressBarR, $iColor) ; GUICtrlSetData($ProgressBarL, $nLeft) GUICtrlSetData($ProgressBarR, $nRight) GUICtrlSetData($InputL, $nLeft); <-- Left numeric audio level GUICtrlSetData($InputR, $nRight); <-- Right numeric audio level ; Sleep(10) ;********************************* LOAD EXTERNAL DTMFScanner.dll ******************************************************* $DtmlDLL = DllOpen("DTMFScanner.dll") if @error then ConsoleWrite("DTMFScanner.dll Load Error!!" & @CRLF) Else ConsoleWrite("DTMFScanner external Funcion ok" & @CRLF) $parameters = DllStructCreate("ptr FileName; dword Channel; float Treshold; int Thread; int64 User; ptr DetectCallback") DllStructSetData($parameters, "FileName", DllStructCreate("wchar[260]")) DllStructSetData($parameters, "Channel", $inputChannel) DllStructSetData($parameters, "Treshold", 0.5) DllStructSetData($parameters, "Thread", 0) DllStructSetData($parameters, "User", 0) DllStructSetData($parameters, "DetectCallback", "DetectCallback") $result = DllCall($DtmlDLL, "int", "DTMFScan", "ptr", DllStructGetPtr($parameters)) if @error then ConsoleWrite("error = " & @error & @CRLF) DllClose($DtmlDLL) ConsoleWrite("DTMF = " & $result[0] & " - other returned values (I don't know which ones): " & ($result[1]) & @CRLF) EndIf Sleep(40) WEnd Func _Exit() _BASS_RecordFree() _BASS_Free() GUIDelete($ID_GUI) Exit EndFunc DTMFScannerLibrary.h: //******************************************************************************************************************************** //* * //* DTMF Scanner Library © 3delite 2023 * //* See DTMF Scanner Library ReadMe.txt for details. * //* * //* Licenses available for usege of this library: * //* Freeeware License: €15 * //* http://www.shareit.com/product.html?productid=301011183 * //* Shareware License: €25 * //* http://www.shareit.com/product.html?productid=301011182 * //* Commercial License: €125 * //* http://www.shareit.com/product.html?productid=301011181 * //* * //* https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/DTMFScannerLibrary.html * //* * //* If you have any questions or enquiries please mail: 3delite@3delite.hu * //* * //* Good coding! :) * //* 3delite * //******************************************************************************************************************************** #pragma once #ifdef _WIN32 // Windows //* .dll file name #define FILENAME_DLL_DTMF_SCANNER_LIBRARY "DTMFScanner.dll" #define DTMFSLIBCALL __stdcall //* Exported function names (Windows) #define NAME_DTMFScan "DTMFScan" #endif //* Error codes #define DTMFSL_OK = 0 #define DTMFSL_ERROR = 1 #ifdef _WIN32 #include <wtypes.h> typedef unsigned __int64 QWORD; #else #include <stdint.h> #define WINAPI #define CALLBACK typedef uint8_t BYTE; typedef uint16_t WORD; typedef uint32_t DWORD; typedef uint64_t QWORD; typedef void* HANDLE; #ifndef __OBJC__ typedef int BOOL; #endif #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #endif typedef enum { dtetStart = 0, dtetContinuing = 1, dtetEnd = 2 } TDTElementType; //* Callback typedef int(DTMFSLIBCALL *TDetectCallback)(int DTMF, TDTElementType Status, float Position, QWORD User); typedef struct { LPWSTR FileName; DWORD Channel; float Treshold; BOOL Thread; QWORD User; TDetectCallback DetectCallback; } *PDTMFScannerParameters, TDTMFScannerParameters; //* Exported functions typedef int(DTMFSLIBCALL* t_DTMFScan)(TDTMFScannerParameters* Parameters); #ifdef __cplusplus extern "C" { #endif static HMODULE DTMFScannerLibraryDLLHandle = NULL; BOOL DTMFScannerLibraryDLLLoaded = FALSE; t_DTMFScan DTMFScan = NULL; #ifdef __cplusplus } #endif BOOL InitDTMFScannerLibrary() { DTMFScannerLibraryDLLHandle = LoadLibrary(FILENAME_DLL_DTMF_SCANNER_LIBRARY); if (NULL != DTMFScannerLibraryDLLHandle) { DTMFScan = (t_DTMFScan)GetProcAddress(DTMFScannerLibraryDLLHandle, NAME_DTMFScan); if (NULL == DTMFScan) { DTMFScannerLibraryDLLLoaded = FALSE; } else { DTMFScannerLibraryDLLLoaded = TRUE; } } return DTMFScannerLibraryDLLLoaded; } BOOL FreeDTMFScannerLibrary() { if (NULL != DTMFScannerLibraryDLLHandle) { DTMFScannerLibraryDLLLoaded = !FreeLibrary(DTMFScannerLibraryDLLHandle); } return !DTMFScannerLibraryDLLLoaded; } DTMFScannerLibrary.pas: //******************************************************************************************************************************** //* * //* DTMF Scanner Library © 3delite 2023 * //* See DTMF Scanner Library ReadMe.txt for details. * //* * //* Licenses available for usege of this library: * //* Freeeware License: €15 * //* http://www.shareit.com/product.html?productid=301011183 * //* Shareware License: €25 * //* http://www.shareit.com/product.html?productid=301011182 * //* Commercial License: €125 * //* http://www.shareit.com/product.html?productid=301011181 * //* * //* https://www.3delite.hu/Object%20Pascal%20Developer%20Resources/DTMFScannerLibrary.html * //* * //* If you have any questions or enquiries please mail: 3delite@3delite.hu * //* * //* Good coding! :) * //* 3delite * //******************************************************************************************************************************** unit DTMFScannerLibrary; interface type TDTElementType = (dtetStart, dtetContinuing, dtetEnd); type TDetectCallback = function(DTMF: Integer; Status: TDTElementType; Position: Single; User: UInt64): Integer; stdcall; type PDTMFScannerParameters = ^TDTMFScannerParameters; TDTMFScannerParameters = record FileName: PChar; Channel: Cardinal; Treshold: Single; Thread: LongBool; User: Int64; DetectCallback: TDetectCallback; end; function DTMFScan(var Parameters: TDTMFScannerParameters): Integer; stdcall; external 'DTMFScanner.dll'; implementation end. Delphi Example: unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, bass, Vcl.StdCtrls, DTMFScannerLibrary; type TForm1 = class(TForm) Memo1: TMemo; Button2: TButton; Label2: TLabel; Edit2: TEdit; ComboBoxInput: TComboBox; Label1: TLabel; Button1: TButton; procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } protected procedure WndProc(var Message: TMessage); override; public { Public declarations } procedure ListDevices; end; Const MSG_DTMF_DETECTED = WM_USER * 4 + 111; var Form1: TForm1; Counter: Integer; implementation {$R *.dfm} procedure TForm1.ListDevices; var Device: AnsiString; Count: Integer; Info: BASS_DEVICEINFO; begin ComboBoxInput.Items.Clear; Count := 0; while BASS_RecordGetDeviceInfo(count, Info) do begin Device := Info.name; ComboBoxInput.Items.Add(String(Device)); Inc(Count); end; ComboBoxInput.ItemIndex := - 1; ComboBoxInput.Text := 'Select...'; end; procedure TForm1.FormCreate(Sender: TObject); begin BASS_Init(- 1, 44100, 0, Handle, nil); ListDevices; end; procedure TForm1.FormDestroy(Sender: TObject); begin BASS_Free; end; procedure TForm1.WndProc(var Message: TMessage); begin case Message.Msg of MSG_DTMF_DETECTED: begin Form1.Memo1.Lines.Append('Tone detected: ' + Char(Message.WParam)); end; else inherited WndProc(Message); end; end; function DetectCallback(DTMF: Integer; Status: TDTElementType; Position: Single; User: UInt64): Integer; stdcall; begin //* List only new detections if Status = dtetStart then begin //* This callback is called from a thread, no UI access is allowed in threads so send the params to the main thread PostMessage(Form1.Handle, MSG_DTMF_DETECTED, wParam(DTMF), 0); Inc(Counter); end; Result := 0; end; procedure TForm1.Button1Click(Sender: TObject); begin //* Freeing the channel handle automatically terminates the scanning thread BASS_RecordFree; end; procedure TForm1.Button2Click(Sender: TObject); var Parameters: TDTMFScannerParameters; ChannelInput: HRecord; begin //StopProcessing := False; BASS_RecordFree; BASS_RecordInit(ComboBoxInput.ItemIndex); //* Always use BASS_SAMPLE_FLOAT flag ChannelInput := BASS_RecordStart(11025, 1, BASS_SAMPLE_FLOAT, nil, nil); Counter := 0; Parameters.FileName := nil; Parameters.Channel := ChannelInput; Parameters.Treshold := StrToFloat(Edit2.Text); Parameters.Thread := True; Parameters.User := 0; Parameters.DetectCallback := DetectCallback; DTMFScan(Parameters); end; end. the return in debug is always 0 and another values that change: DTMFScanner external Funcion ok DTMF = 0 - other returned values (I don't know which ones): 0x02642090 DTMFScanner external Funcion ok DTMF = 0 - other returned values (I don't know which ones): 0x02642748 DTMFScanner external Funcion ok DTMF = 0 - other returned values (I don't know which ones): 0x02643A58 DTMFScanner external Funcion ok DTMF = 0 - other returned values (I don't know which ones): 0x02642860 DTMFScanner external Funcion ok DTMF = 0 - other returned values (I don't know which ones): 0x02642748 DTMFScanner external Funcion ok DTMF = 0 - other returned values (I don't know which ones): 0x02643BE8 Any idea to implement the DTMFScanner.dll? Thankyou very much! Marco DTMF_dialing.ogg bass.dll DTMFScanner.dll Bass.au3 DTMFScannerLibrary.h Unit1.pas DTMFScannerLibrary.pas
  2. Hello. I'm trying to call function "LeCreateProcess" in LoaderDLL.dll but having issues getting any results back. I barely understand C++. I got most values from here https://github.com/xupefei/Locale-Emulator within the https://github.com/xupefei/Locale-Emulator/blob/aa99dec3b25708e676c90acf5fed9beaac319160/LEProc/LoaderWrapper.cs I'm attaching also LocaleEmulator.dll but according to Dependency Walker the function is located in LoaderDLL.dll The goal is to run an application, in this instance, with a Japanese locale. Program itself works fine but in Windows 11 there's no easy way of adding custom options into Context menu where this program would be located if clicked on exe. #include <Date.au3> Local $sProgramPath = "PATH TO ANY EXE FILE" Local $hDLL = DllOpen("PATH TO LOADER.DLL") If @error Then MsgBox(0, "Error", "Failed to open dll") DllClose($hDLL) Exit EndIf Local $SHIFT_JIS = 932 Local $LANG_JAPANESE = 0x411 Local $SHIFTJIS_CHARSET = 128 Local $LEB = DllStructCreate("struct; UINT AnsiCodePage; UINT OemCodePage; UINT LocaleID; UINT DefaultCharset; UINT HookUiLanguageApi; WCHAR DefaultFaceName[64]; PTR Timezone; endstruct") ;Unsure about last two values DllStructSetData($LEB, "AnsiCodePage", $SHIFT_JIS) DllStructSetData($LEB, "OemCodePage", $SHIFT_JIS) DllStructSetData($LEB, "LocaleID", $LANG_JAPANESE) DllStructSetData($LEB, "DefaultCharset", $SHIFTJIS_CHARSET) DllStructSetData($LEB, "HookUiLanguageApi", 0) DllStructSetData($LEB, "DefaultFaceName", "") ;I'm not sure about this part DllStructSetData($LEB, "Timezone", _Date_Time_GetTimeZoneInformation()) ;This seems correct but I don't know if that information is formatted correctly Local $tProcessInfo = DllStructCreate($tagPROCESS_INFORMATION) ;From help file. I don't know if this is enough Local $aResult = DllCall($hDLL, "none", "LeCreateProcess", "struct*", $LEB, "wstr", $sProgramPath, "ptr", Null, "wstr", @WorkingDir, "ptr", Null, "ptr", Null, "struct*", $tProcessInfo, "ptr", Null, "ptr", Null, "ptr", Null, "ptr", Null) If @error Then MsgBox(0, "Error", "Error - " & @Extended) DllClose($hDLL) Exit EndIf DllClose($hDLL) Any help is appreciated! LoaderDll.dll LocaleEmulator.dll
  3. C++ header files are unfamiliar to me, but I'm trying to figure something out. My intention is to automatically extract from these files the necessary information to be able to then use them in the ObjCreateInterface() and/or ObjectFromTag() function. To get started I followed some guidance from this post by @LarsJ : https://www.autoitscript.com/forum/topic/205154-using-objcreateinterface-and-objectfromtag-functions This script is a first draft to try to translate variable types from MSDN types to AutoIt types. A lot of this code could definitely be improved by replacing some parts with more effective regular expressions (if only I could....). For some of the conversions I used a function posted in this post by @wolf9228 from some time ago (https://www.autoitscript.com/forum/topic/113824-windows-data-types/). With that function it is possible to translate the default types, but I see that there are types in the header that are not foreseen in that function. They look like types declared elsewhere in the header itself. also sometimes the type declaration contains 2 strings where the first of the 2 appears to be the type declaration, but sometimes it contains three, where the first of the three strings may be for example 'const' or something different and in that case the declaration of type is the second string. So it would be necessary to find a way to parse that group of strings which is variable. In this draft script I tried in the case of 3 strings not to consider the first one, but surely this method is not infallible and perhaps the possible cases could include even more than 3 strings in the declaration of a type? Is there anyone who can give some suggestions on how to proceed in those cases? To run this script, you also need to save a C++ header file in the same directory. I used the header file related to webview2 WebView2.h which can be found in this post by @LarsJ (https://www.autoitscript.com/forum/topic/205154-using-objcreateinterface-and-objectfromtag-functions) in the file ObjectFromTag.7z inside the 'Includes' folder. The script returns a draft of the intended result where unrecognized types are marked with ?????. The output script is also copied to the clipboard so that it can be easily pasted into the SciTE editor for better analysis. immediately below the translated declarations, the declarations of the original types are also reported, as a reminder. welcome to anyone who is interested in developing this script or has useful suggestions for converting a c++ header to AutoIt. Thank you Header_Parser.au3
  4. welcome I need help dealing with a C++ DLL Specify that I need help with how to use this function struct libusb_device; typedef struct libusb_context libusb_context; ssize_t LIBUSB_CALL libusb_get_device_list(libusb_context *ctx,libusb_device ***list); My problem is how to deal with "libusb_device ***list" my code $libusb_device = DllStructCreate("PTR") Func libusb_init() $Var = DllCall($libusb0, "ptr", "libusb_init",'ptr',$_libusb_device_handle_Ptr) If @error Then Return False Return $Var[1] EndFunc Func libusb_get_device_list() MsgBox(0,VarGetType($_libusb_device_handle_Ptr),$_libusb_device_handle_Ptr) $Var = DllCall($libusb0, "int", "libusb_get_device_list","ptr",$_libusb_device_handle_Ptr,"ptr*",POINTER(POINTER($libusb_device))) $Error = @error If $Error Then Return False MsgBox(0,VarGetType($Var),$Error&@CRLF&$Var) _ArrayDisplay($Var) Return $Var[1] EndFunc Thank you iLibUSB.dll iLibUSB_32.dll libusb.h
  5. Good morning Forums In these days, I am working on a project that involved me to use some Windows APIs to obtain some information about Terminal Servers. I'm doing this using wtsapi32.dll in a VBA Project, but, the lack of knowledge about few things threated in the articles make this quite difficult to implement and understand at the same time. The most difficult thing I'm facing is "translating" C/C++ functions or struct in VBA when pointers are used, or pointers of pointers, and so on. Since VBA seems to not have a pointer type, to make those functions work I need to implement other functions taken from other DLLs, and this confuses me a lot. For example, starting from this code, I splitted all the functions and all the definitions to understand why they are there, and why I need to use them. At the end, I've found out that the code I was going to implement starting from the functions provided in the Microsoft Docs won't be ever be able to work without some supplementary functions which are not mentioned anywhere. So, I was wondering if someone would please point me out to a good and practical exaplanation about pointers (in general) or specifically for VBA, because I need to use them quite often in these days, and I'd like to understand what I am doing. Thanks in advance. Best Regards and Stay at home 🏡
  6. Recently, I am interested to build a windows app to reset Windows login password as a side off project. I am still a newbie in programming so i am not able to build the app from scratch. Is there any open source project i could learn from on this?
  7. Hi guys! I have a problem that i hope you give me an advice to solve it. I have writing this code and it doesn't run cuz its a problem.C2562 'Draw':'void' function returning a vaue.....I dont know what to correct.
  8. for a savvy c++ developer, how hard would it be to compile this into a standalone Win32 console executable? i have almost no experience with c++ (and i have no need for any more, since i have AutoIt for pretty much all my requirements). i can compile a simple "hello world" executable (and even embed the mfc dll for backward compatibility). but i am quite interested with that project. your opinion? P.S. this relates to AutoIt quite simply - once (if and when) i have that project as a standalone executable, i have a GUI made with AutoIt to execute it, then post-process and display the output.
  9. Ciao I would like to control an ATEM Video Mixer from autoit. I downloaded his SDK which is written in c ++ and I found the sequences to interface, but I was not able to convert the script to self. The instructions say to follow this sequence: and to connectTo with C++ is: string address = ""; _BMDSwitcherConnectToFailure failureReason = 0; IBMDSwitcher switcher = null; var discovery = new CBMDSwitcherDiscovery(); discovery.ConnectTo(address, out switcher, out failureReason); From Blackmagic SDK: IBMDSwitcherDiscovery::ConnectTo method The ConnectTo method connects to the specified switcher and returns an IBMDSwitcher object interface for the switcher. Syntax HRESULT ConnectTo (string deviceAddress, IBMDSwitcher** switcherDevice, BMDSwitcherConnectToFailure* failReason); Parameters: deviceAddress in Network hostname or IP address of switcher to connect to. switcherDevice out IBMDSwitcher object interface for the connected switcher. failReason out Reason for connection failure as a BMDSwitcherConnectToFailure value. So, I have I tried these solutions but with non success: $DllName =@ScriptDir&"\BMDSwitcherAPI.dll" $result = DllCall($DllName, "none", "IBMDSwitcherDiscovery::ConnectTo" & @CRLF) ConsoleWrite("DLLCall Result: " & $result & @CRLF) and I have tried also create an Object (That I think is the best way solution): #include <MsgBoxConstants.au3> $oSwitcher=ObjCreate("IBMDSwitcher") If IsObj($oSwitcher) Then MsgBox(64, "", "Object $oSwitcher created successfully") EndIf $oAtem=ObjCreate("IBMDSwitcherDiscovery") If IsObj($oAtem) Then MsgBox(64, "", "Object $oAtem created successfully") EndIf $failureReason =ObjCreate("_BMDSwitcherConnectToFailure") If IsObj($failureReason) Then MsgBox(64, "", "Object $failureReason created successfully") EndIf $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ; Install a custom error handler Global $errore,$oSwitcher1 $oAtem.ConnectTo("",$oSwitcher,$failureReason); ; This is the custom error handler Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) MsgBox(0, "", "We intercepted a COM Error !" & @CRLF & _ "Number is: " & $HexNumber & @CRLF & _ "Windescription is: " & $oMyError.windescription & @CRLF & _ "Source is: " & $oMyError.source & @CRLF & _ "Description is: " & $oMyError.description & @CRLF & _ "Helpfile is: " & $oMyError.helpfile & @CRLF & _ "Helpcontext is: " & $oMyError.helpcontext & @CRLF & _ "Lastdllerror is: " & $oMyError.lastdllerror & @CRLF & _ "Scriptline is: " & $oMyError.scriptline) EndFunc ;==>MyErrFunc But the result is: We intercepted a COM Error ! Number is: 000000A9 Windescription is: Variable must be of type 'Object'. Source is: Description is: Helpfile is: Helpcontext is: Lastdllerror is: 0 Scriptline is: 17 The BMDSwitcherAPI.dll is registered in system. Can someone help me? Grazie Marco
  10. Autoit version: System: Windows 10 Home x64 C++ IDE: Code::Blocks 17.12 When I call the Dll that I wrote it give me how return value -1073741819 and exit value 3221225477, I tried changing variables type but it didn't work. This is the Autoit code: #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_UseX64=n #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** $dll = DllOpen(@ScriptDir & "\Test.dll") DllCall($dll, "NONE", "TestFunction", "STR", "1 string", "STR", "2 string", "STR", "3 string", "INT", 1) ;Here crash and doesn't show the MsgBox MsgBox(0, "", @error) DllClose($dll) This is the main.cpp code: #include <iostream> #include <Windows.h> #include "main.h" using namespace std; extern "C" { DECLDIR void TestFunction(std::string string1, std::string string2, std::string string3, int number1) { std::cout << string1 << std::endl; std::cout << string2 << std::endl; std::cout << string3 << std::endl; std::cout << number1 << std::endl; } } And that is the main.h: #ifndef _DLLTEST_H_ #define _DLLTEST_H_ #define DLL_EXPORT #if defined DLL_EXPORT #define DECLDIR __declspec(dllexport) #else #define DECLDIR __declspec(dllimport) #endif extern "C" { DECLDIR void TestFunction(std::string string1, std::string string2, std::string string3, int number1); } #endif And the values of the variables that write to the SciTe console ae completely different. Here I attach the console output of the SciTe editor: >"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\DragonFighter\Desktop\Dll test.au3" /UserParams +>10:30:08 Starting AutoIt3Wrapper v.17.224.935.0 SciTE v. Keyboard:00000410 OS:WIN_10/ CPU:X64 OS:X64 Environment(Language:0410) CodePage:0 utf8.auto.check:4 +> SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE UserDir => C:\Users\DragonFighter\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper SCITE_USERHOME => C:\Users\DragonFighter\AppData\Local\AutoIt v3\SciTE >Running AU3Check ( from:C:\Program Files (x86)\AutoIt3 input:C:\Users\DragonFighter\Desktop\Dll test.au3 +>10:30:08 AU3Check ended.rc:0 >Running:(\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\DragonFighter\Desktop\Dll test.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop �Á+���Uø‰q�‰A�‹O`ÆEÿ�èèÖÿÿƒÄ €}ÿ!>10:30:10 AutoIt3.exe ended.rc:-1073741819 +>10:30:10 AutoIt3Wrapper Finished. >Exit code: 3221225477 Time: 3.414 Thanks in advance for every reply.
  11. #include <iostream> #include <fstream> #include <string> int main () { std::ifstream is ("image.png", std::ifstream::binary); unsigned char buffer_array[4][4]; if (is) { is.seekg (0, is.end); int length = is.tellg(); is.seekg (0, is.beg); char * buffer = new char [length]; is.read (buffer,length); //Here I get the error unsigned char * buffer_str=buffer; for (int count1=0; count1<4; count1=count1+1) { for (int count2=0; count2<4; count2=count2+1) { //Here I get the others two errors buffer_array[count1][count2]=buffer_str.substr(0, 2); buffer_str.erase(0, 2) }; }; return 0; }; }; My goal is to split the binary buffer of the image.png in an array, I tried using string modifiers but I get two errors: request for member 'erase' in 'buffer_str', which is of non-class type 'unsigned char*' thats what I get when build.
  12. I wanted to start using SDL2 libraries in C++. This is a Hello World project that covers some of the essentials of programming with SDL2. I will use it when I forget how to create an SDL2 project. Loads a scrolling background image for world. Mouse position, left click, and double click example. Hotkeys and cooldown timers to prevent hotkey spam. Plays background music. (ALT + P) Plays sound effects changing sprite type. (numpad: /, *, -, +) Features a Player class for multiplayer. Player collision detection. Uses a Window class from Lazyfoo for maximize button, fullscreen ext.. Built using MSVS 2013 (free). All dlls and libraries included and linked (for MSVS) using relative paths. You can probably run the SDL2_HelloWorld.sln without setting up any libraries. Note SDL_Net is setup but not used. Delta time used to create consistent frame rate across machines. Player animation sprite sheet: Demo: Slimy's First Kiss Download Source and project: http://songersoft.com/programming/sdl2_helloworld/sdl2_helloworld_about.phtml This isn't meant to be amazing. It's just to help get started with SDL2. I will consider any criticism. main.cpp // This example HelloWorld followed this video: // https://www.youtube.com/watch?v=M4Jgz0wEQxY // Turned into this // https://www.youtube.com/watch?v=yRpen8jOa08&list=PL77-op_SRaiEuC0YC43ZAUJJwL_G_C2z8&index=15 // Window class was copied from Lazyfoo // http://lazyfoo.net/tutorials/SDL/35_window_events/index.php #include <iostream> #include <string> #include "SDL.h" #include "SDL_image.h" #include "SDL_ttf.h" #include "SDL_mixer.h" #include "SDL_net.h" #include "Player.h" #include "Window.h" using namespace std; // Prototypes SDL_Texture *LoadTexture(string filepath, SDL_Renderer *renderTarget); void logSDLError(const string); SDL_Rect sdlrect(int, int, int, int); SDL_Surface *OptimizedSurface(string filepath, SDL_Surface *windowSurface); // if(okAlt) either Alt key is pressed OrKeyALT #define okAlt (k[SDL_SCANCODE_RALT] || k[SDL_SCANCODE_LALT]) int main(int argc, char *argv[]) { // Needed for the initialize block Window window; SDL_Renderer *renderTarget = nullptr; // Initialize SDL2 if (SDL_Init(SDL_INIT_EVERYTHING) < 0) { logSDLError("SDL_Init "); } // Initialize SDL_image if (!(IMG_Init(IMG_INIT_PNG) & IMG_INIT_PNG)) { cout << "Could not initialize SDL_image: " << IMG_GetError() << std::endl; SDL_Delay(5500); } // Initialize TTF if (TTF_Init() < 0) cout << "TTF_Init " << TTF_GetError() << endl; //Create window if (!window.init("SDL2 Hello World", 640, 480, "../../Graphics/iconbmp.bmp")) { printf("Window could not be created! SDL Error: %s\n", SDL_GetError()); } else { //Create renderer for window renderTarget = window.createRenderer(); if (renderTarget == NULL) { printf("Renderer could not be created! SDL Error: %s\n", SDL_GetError()); } } // Audio if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 2048) < 0) { cout << "Mix_OpenAudio: " << Mix_GetError() << endl; } // Load sounds: Run chunk if less than 10 sec, music if greater (generally) //Mix_Music *bgm = Mix_LoadMUS("../../Sounds/overworld.mid"); // Can't Pause MIDI Mix_Music *bgm = Mix_LoadMUS("../../Sounds/bensound-goinghigher.mp3"); cout << Mix_GetError() << endl; // Font and text SDL_Texture *text_texture = nullptr; SDL_Color textColor = { 144, 77, 255, 255 }; TTF_Font *font = TTF_OpenFont("../../Graphics/Fonts/VCR_OSD_MONO.ttf", 20); if (font) { SDL_Surface *textSurf = TTF_RenderText_Solid(font, "Hello world", textColor); text_texture = SDL_CreateTextureFromSurface(renderTarget, textSurf); SDL_FreeSurface(textSurf); } else cout << TTF_GetError() << endl; SDL_Rect textRect = { 0, 0, 0, 0 };// Position of text on window // Get the size of the text_texture SDL_QueryTexture(text_texture, NULL, NULL, &textRect.w, &textRect.h); const int playerMax = 8; int players = 2; float prevTime = 0, currentTime = 0, deltaTime = 0; bool fullscreen_toggle = 0; int i = 0, ii = 0; int redraw = 1; bool done = 0; // Load player sprite sheet and background texture SDL_Texture *spritesheet_texture = LoadTexture("../../Graphics/DW3_Char_SpriteSheet.png", renderTarget); SDL_Texture *bg_texture = LoadTexture("../../Graphics/dw3-over.png", renderTarget); int bg_texture_w = 0, bg_texture_h = 0; // Point k to Keyboard state (only needs done here, not in main loop) const Uint8 *k = SDL_GetKeyboardState(NULL); SDL_Event windowEvent; // Stop keys spamming (like music ON / OFF) float key_cooldown_timer_max = 500.0f, key_cooldown_timer = 0; SDL_Rect cameraRect = { 0, 0, window.getWidth(), window.getHeight()}; // Construct default players Player player[playerMax]; // Customize players (texture and position) for (i = 0; i < players; i++)//(sprite texture, position x, position y) player[i].Player_new(spritesheet_texture, window.getWidth() / 2 + i * 16, window.getHeight() / 2); // Get the size of bg_texture SDL_QueryTexture(bg_texture, NULL, NULL, &bg_texture_w, &bg_texture_h); // Main message loop while (!done) { prevTime = currentTime; currentTime = SDL_GetTicks(); deltaTime = (currentTime - prevTime) / 1000.0f; while (SDL_PollEvent(&windowEvent) != 0) { // Check for events if (windowEvent.type == SDL_QUIT) { // Window Exit done = 1; } else if(windowEvent.type == SDL_MOUSEBUTTONDOWN) { // Mouse buttons if (windowEvent.button.clicks == 2) { // Double left click redraw = 1; } else if (windowEvent.button.button == SDL_BUTTON_LEFT) { // Single left click redraw = 1; } // Output mouse position cout << "Mouse: " << windowEvent.button.x << " " << windowEvent.button.y << endl; } }// if(SDL_PollEvent(&windowEvent)) if (okAlt) { // Either ALT key if (k[SDL_SCANCODE_RETURN]) { // ALT + ENTER, toggle fullscreen // Consider matching current window resolution to closest preset array of valid full screen resolutions. fullscreen_toggle = 1; } if (k[SDL_SCANCODE_P]) { if (SDL_GetTicks() - key_cooldown_timer > key_cooldown_timer_max) { // Action cooldown timer is ready. Avoids ON / OFF flicker // Play Music if (!Mix_PlayingMusic()) { cout << "PLAY"; Mix_PlayMusic(bgm, -1); } else if (Mix_PausedMusic()) { cout << "RESUME"; Mix_ResumeMusic(); } else { cout << "PAUSE"; Mix_PauseMusic(); } key_cooldown_timer = SDL_GetTicks(); } }// SDL_SCANCODE_P if (k[SDL_SCANCODE_S]) { // Stop Music Mix_HaltMusic(); } }// okAlt //Handle window events fullscreen_toggle = window.handleEvent(windowEvent, renderTarget, fullscreen_toggle); // Player Update and IntersectsWith for (i = 0; i < players; i++) { player[i].Update(deltaTime, k); for (ii = 0; ii < players; ii++) { if(i != ii)// Not self player[i].IntersectsWith(player[ii]); } } // Camera cameraRect.x = player[0].GetOriginX() - window.getWidth() / 2; cameraRect.y = player[0].GetOriginY() - window.getHeight() / 2; // Normalize if (cameraRect.x < 0) cameraRect.x = 0; if (cameraRect.y < 0) cameraRect.y = 0; if (cameraRect.x + cameraRect.w >= bg_texture_w) cameraRect.x = bg_texture_w - window.getWidth(); if (cameraRect.y + cameraRect.h >= bg_texture_h) cameraRect.y = bg_texture_h - window.getHeight(); redraw = 1; // Don't judge me if (redraw) { // Redraw should definatly pretty much be at the end of loop // Clear window SDL_RenderClear(renderTarget); // Copy camera from bg_texture SDL_RenderCopy(renderTarget, bg_texture, &cameraRect, NULL); // Draw players for (i = 0; i < players; i++) player[i].Draw(renderTarget, cameraRect); // Print text SDL_RenderCopy(renderTarget, text_texture, NULL, &textRect); // Show the rendered content SDL_RenderPresent(renderTarget); redraw = 0; }// if(redraw) }// while(true) // Free windows window.free(); SDL_DestroyTexture(bg_texture); SDL_DestroyTexture(spritesheet_texture); SDL_DestroyTexture(text_texture); TTF_CloseFont(font); // Free Renderers SDL_DestroyRenderer(renderTarget); // Free music Mix_FreeMusic(bgm); // Close systems Mix_Quit(); TTF_Quit(); IMG_Quit(); SDL_Quit(); return EXIT_SUCCESS; }// main() SDL_Texture *LoadTexture(string filepath, SDL_Renderer *renderTarget) { // Create texture SDL_Texture *texture = nullptr; // Load surface SDL_Surface *surface = IMG_Load(filepath.c_str()); if (surface == NULL) { // surface didn't load logSDLError("LoadTexture surface "); } else { SDL_SetColorKey(surface, SDL_TRUE, SDL_MapRGB(surface->format, 0, 0, 0)); texture = SDL_CreateTextureFromSurface(renderTarget, surface); //SDL_SetTextureColorMod(texture, 120, 150, 140); if (texture == NULL) logSDLError("LoadTexture texture "); } SDL_FreeSurface(surface); return texture; } void logSDLError(const string msg){ cout << msg << " Error: " << SDL_GetError() << endl; SDL_Delay(4000); } SDL_Rect sdlrect(int x, int y, int w, int h) { SDL_Rect rect = {x, y, w, h}; return rect; } SDL_Surface *OptimizedSurface(string filepath, SDL_Surface *windowSurface) { SDL_Surface *optimizedSurf = nullptr; SDL_Surface *surface = IMG_Load(filepath.c_str()); if (surface == NULL) { cout << "Error: " << endl; } else { optimizedSurf = SDL_ConvertSurface(surface, windowSurface->format, 0); if (optimizedSurf == NULL) cout << "Error: " << endl; } SDL_FreeSurface(surface); return optimizedSurf; } Player.h #pragma once #include <iostream> #include "SDL.h" #include <String> #include "SDL_mixer.h" using namespace std; enum player_control { ePlayer_control_up, ePlayer_control_down, ePlayer_control_left, ePlayer_control_right, ePlayer_control_type_minus, ePlayer_control_type_plus }; class Player { private: SDL_Rect cropRect; SDL_Texture *texture; int spritesheet_texture_w, spritesheet_texture_h;//size of spritesheet texture bool isActive;//animation timer SDL_Scancode keys[6]; int frame_w, frame_h;//16, 16 float frameTimerMax; float frameTimer;//0..frameTimerMax int frame;//0..1 int frameMax;//2 int way;//0..3 int classType;//0..53 float moveSpeed; float cast_cooldown_max; Mix_Chunk *soundEffect; int originX, originY; int radius; Uint32 key_cooldown_timer; string name; public: void Player_new(SDL_Texture *spritesheet_texture, int x, int y); Player(); ~Player(); void Update(float delta, const Uint8 *keyState); void Draw(SDL_Renderer *renderTarget, SDL_Rect cameraRect); bool IntersectsWith(Player &p); int GetOriginX(); int GetOriginY(); int GetRadius(); SDL_Rect positionRect; }; Player.cpp #pragma once #include "Player.h" #include "SDL_image.h" #include "SDL_mixer.h" #include <iostream> #include <String> #include <cmath> using namespace std; Player::Player() { cropRect = {0, 0, 16, 16}; texture = nullptr; spritesheet_texture_w = spritesheet_texture_h = 0;//size of spritesheet texture isActive = false;//animation timer keys[6]; frame_w = frame_h = 16;//16, 16 frameTimerMax = 0.5f; frameTimer = 0;//0..frameTimerMax frame = 0;//0..1 frameMax = 2;//2 way = 0;//0..3 classType = 0;//0..53 moveSpeed = 200.0f; radius = frame_w / 2; soundEffect = nullptr; key_cooldown_timer = 0; cast_cooldown_max = 190.0f; static int playerNumber = 0; playerNumber++; name = "Player:" + to_string(playerNumber); // Setup keys for player 1 // ** I see the enum didn't exist when this was written ** if (playerNumber == 1) { keys[0] = SDL_SCANCODE_W; keys[1] = SDL_SCANCODE_S; keys[2] = SDL_SCANCODE_A; keys[3] = SDL_SCANCODE_D; keys[4] = SDL_SCANCODE_KP_MINUS; keys[5] = SDL_SCANCODE_KP_PLUS; } else { // Setup keys all other players (not 1) keys[0] = SDL_SCANCODE_UP; keys[1] = SDL_SCANCODE_DOWN; keys[2] = SDL_SCANCODE_LEFT; keys[3] = SDL_SCANCODE_RIGHT; keys[4] = SDL_SCANCODE_KP_DIVIDE; keys[5] = SDL_SCANCODE_KP_MULTIPLY; } }//Player::Player() void Player::Player_new(SDL_Texture *spritesheet_texture, int x, int y) { // This is new player isActive = false; // Read size of spritesheet texture SDL_QueryTexture(spritesheet_texture, NULL, NULL, &spritesheet_texture_w, &spritesheet_texture_h); texture = spritesheet_texture; // spritesheet rect cropRect = { 0, 0, 16, 16 }; // player screen position positionRect = { x, y, 16, 16 }; // Defaults moveSpeed = 200.0f; radius = frame_w / 2; frameTimer = 0; frame = 0; frameMax = 2; way = 0; classType = 0; originX = frame_w / 2; originY = frame_h / 2; soundEffect = Mix_LoadWAV("../../Sounds/whipcrack1.wav"); cout << "Name: " << name << endl; }//Player::Player_new() void Player::Update(float delta, const Uint8 *keyState) { isActive = true; if (keyState[keys[ePlayer_control_up]]) { way = 0; positionRect.y -= moveSpeed * delta; cropRect.x = (way * cropRect.w * frameMax) + (frame * cropRect.w); } if (keyState[keys[ePlayer_control_down]]) { way = 1; positionRect.y += moveSpeed * delta; cropRect.x = (way * cropRect.w * frameMax) + (frame * cropRect.w); } if (keyState[keys[ePlayer_control_left]]) { way = 3; positionRect.x -= moveSpeed * delta; cropRect.x = (way * cropRect.w * frameMax) + (frame * cropRect.w); } if (keyState[keys[ePlayer_control_right]]) { way = 2; positionRect.x += moveSpeed * delta; cropRect.x = (way * cropRect.w * frameMax) + (frame * cropRect.w); } if (keyState[keys[ePlayer_control_type_minus]]) { if (SDL_GetTicks() - key_cooldown_timer > cast_cooldown_max) { key_cooldown_timer = SDL_GetTicks(); Mix_PlayChannel(-1, soundEffect, 0); classType--; if (classType < 0) classType = spritesheet_texture_h / cropRect.h - 1; cropRect.y = classType * cropRect.h; } } if (keyState[keys[ePlayer_control_type_plus]]) { if (SDL_GetTicks() - key_cooldown_timer > cast_cooldown_max) { key_cooldown_timer = SDL_GetTicks(); Mix_PlayChannel(-1, soundEffect, 0); classType++; if (classType >= spritesheet_texture_h / cropRect.h) classType = 0; cropRect.y = classType * cropRect.h; } } if (isActive) { frameTimer += delta; if (frameTimer >= frameTimerMax){ frameTimer = 0; cropRect.x = (way * cropRect.w * frameMax) + (frame * cropRect.w); if (frame >= frameMax - 1) frame = 0; else frame++; } } else { frameTimer = 0; } }//Player::Update() void Player::Draw(SDL_Renderer *renderTarget, SDL_Rect cameraRect) { SDL_Rect drawingRect = { positionRect.x - cameraRect.x, positionRect.y - cameraRect.y, positionRect.w, positionRect.h }; SDL_RenderCopy(renderTarget, texture, &cropRect, &drawingRect); } bool Player::IntersectsWith(Player &p){ if (sqrt(pow(GetOriginX() - p.GetOriginX(), 2) + pow(GetOriginY() - p.GetOriginY(), 2)) >= radius + p.GetRadius()) { SDL_SetTextureColorMod(texture, 255, 255, 255); return false; } SDL_SetTextureColorMod(texture, 255, 0, 0); return true; } Player::~Player() { SDL_DestroyTexture(texture); Mix_FreeChunk(soundEffect); } int Player::GetOriginX() { return positionRect.x + originX; } int Player::GetOriginY() { return positionRect.y + originY; } int Player::GetRadius() { return radius; }
  13. Hello, I have compiled a reference DLL in VS 2015 Community and this DLL works fine with project for which it is used. There is an interface from which u can access functions in DLL. Developers stated that this DLL is almost universal and can be used with any language with minor changes. I am trying to access its function from Autoit script and got an error 3, after calling DLLCall - "function" not found in the DLL file. Please have a quick look, I feel I miss something in C++ library with exporting functions and I do not know what to add as I am new to C++. Thank you. Source files and script also attached. Here is my script. Local $dll = DllOpen("C:\Users\Home\Desktop\dll\user.dll") ConsoleWrite("$dll handle = " & $dll & @CRLF) ;$dll handle = 1 Local $result = DllCall($dll, "double:cdecl", "ProcessQuery", "str", "dll$mynumber") If @error > 0 Then ConsoleWrite("Error: " & @error & @CRLF) ;Error = 3 If IsArray($result) Then ConsoleWrite("Array returned!" & @CRLF & "dll$mynumber: " & result[1]) Else ConsoleWrite("$result is not array. : " & $result & @CRLF) ;$result = 0 EndIf DllClose($dll) And here is dll source. As I understand, function "ProcessQuery" exported with help of DLL_IMPLEMENTS user.h //****************************************************************************** // // This file is part of the OpenHoldem project // Download page: http://code.google.com/p/openholdembot/ // Forums: http://www.maxinmontreal.com/forums/index.php // Licensed under GPL v3: http://www.gnu.org/licenses/gpl.html // //****************************************************************************** // // Purpose: Very simple user-DLL as a starting-point // // DO NOT CHANGE ANYTHING IN THIS FILE! // // This Header defines an interface // Functions and data-types must exactly match. // //****************************************************************************** #ifndef _INC_USER_H #define _INC_USER_H // Import and export directives // for use by this DLL and by OpenHoldem #ifdef USER_DLL #define DLL_IMPLEMENTS extern "C" __declspec(dllexport) #define EXE_IMPLEMENTS extern "C" __declspec(dllimport) #else #define DLL_IMPLEMENTS extern "C" __declspec(dllimport) #define EXE_IMPLEMENTS extern "C" __declspec(dllexport) #endif // Number of saved table-states // This number must not be changed, as we do a "& 0xFF" // at various places to normalize the index. const int kNumberOfHoldemStatesForDLL = 256; // SHoldemePlayer // used for sequence of 256 consequive table-states // !!!! Needs 2 more cards for Omaha, if not entirely removed struct holdem_player { char m_name[16] ; //player name if known double m_balance ; //player balance double m_currentbet ; //player current bet unsigned char m_cards[2] ; //player cards unsigned char m_name_known : 1 ; //0=no 1=yes unsigned char m_balance_known : 1 ; //0=no 1=yes unsigned char m_fillerbits : 6 ; //filler bits unsigned char m_fillerbyte ; //filler bytes }; struct holdem_state { char m_title[64] ; //table title double m_pot[10] ; //total in each pot unsigned char m_cards[5] ; //common cards unsigned char m_is_playing : 1 ; //0=sitting-out, 1=sitting-in unsigned char m_is_posting : 1 ; //0=autopost-off, 1=autopost-on unsigned char m_fillerbits : 6 ; //filler bits unsigned char m_fillerbyte ; //filler byte unsigned char m_dealer_chair ; //0-9 holdem_player m_player[10] ; //player records }; // Functions implemented and exported by the DLL, // imported by OpenHoldem DLL_IMPLEMENTS double __stdcall ProcessQuery(const char* pquery); DLL_IMPLEMENTS void __stdcall DLLOnLoad(); DLL_IMPLEMENTS void __stdcall DLLOnUnLoad(); // Functions implemented and exported by OpenHoldem, // imported by the DLL EXE_IMPLEMENTS double __stdcall GetSymbol(const char* name_of_single_symbol__not_expression); EXE_IMPLEMENTS void* __stdcall GetPrw1326(); EXE_IMPLEMENTS char* __stdcall GetHandnumber(); EXE_IMPLEMENTS void __stdcall ParseHandList(const char* name_of_list, const char* list_body); EXE_IMPLEMENTS char* __stdcall ScrapeTableMapRegion(char* p_region, int& p_returned_lengh); EXE_IMPLEMENTS void __stdcall SendChatMessage(const char *message); EXE_IMPLEMENTS void __stdcall WriteLog(char* format, ...); // Variables exported by OpenHoldem // avoiding the message-mess of WinHoldem, // no longer sending any state-messages // http://www.maxinmontreal.com/forums/viewtopic.php?f=174&t=18642 EXE_IMPLEMENTS extern holdem_state state[kNumberOfHoldemStatesForDLL]; EXE_IMPLEMENTS extern int state_index; #endif // _INC_USER_H user.cpp Here is dll$mynumber parameter. //****************************************************************************** // // This file is part of the OpenHoldem project // Download page: http://code.google.com/p/openholdembot/ // Forums: http://www.maxinmontreal.com/forums/index.php // Licensed under GPL v3: http://www.gnu.org/licenses/gpl.html // //****************************************************************************** // // Purpose: Very simple user-DLL as a starting-point // // Required OpenHoldem version: 7.7.6 // //****************************************************************************** // Needs to be defined here, before #include "user.h" // to generate proper export- and inport-definitions #define USER_DLL // #define OPT_DEMO_OUTPUT if you are a beginner // who wants to see some message-boxes with output of game-states, etc. // It is disabled upon request, // * as it is not really needed // * as some DLL-users don't have MFC (atlstr.h) installed // http://www.maxinmontreal.com/forums/viewtopic.php?f=156&t=16232 #undef OPT_DEMO_OUTPUT #include "user.h" #include <conio.h> #include <windows.h> #ifdef OPT_DEMO_OUTPUT #include <atlstr.h> #endif OPT_DEMO_OUTPUT // Supporting macros #define HIGH_NIBBLE(c) (((c)>>4)&0x0F) #define LOW_NIBBLE(c) ((c)&0x0F) // Card macro #define RANK(c) ( ISKNOWN(c) ? HIGH_NIBBLE(c) : 0 ) #define SUIT(c) ( ISKNOWN(c) ? LOW_NIBBLE(c) : 0 ) #define ISCARDBACK(c) ((c) == CARD_BACK) #define ISUNKNOWN(c) ((c) == CARD_UNDEFINED) #define ISNOCARD(c) ((c) == CARD_NOCARD) #define ISKNOWN(c) (!ISCARDBACK(c) && !ISUNKNOWN(c) && !ISNOCARD(c)) // ProcessQuery() // Handling the lookup of dll$symbols DLL_IMPLEMENTS double __stdcall ProcessQuery(const char* pquery) { if (pquery==NULL) return 0; if (strncmp(pquery,"dll$mynumber",13)==0) { return 12345.67; } return 0; } // OnLoad and OnUnload() // called once and at the beginning of a session // when the DLL gets loaded / unloaded // Do initilization / finalization here. DLL_IMPLEMENTS void __stdcall DLLOnLoad() { #ifdef OPT_DEMO_OUTPUT MessageBox(NULL, "event-load", "MESSAGE", MB_OK); #endif OPT_DEMO_OUTPUT } DLL_IMPLEMENTS void __stdcall DLLOnUnLoad() { #ifdef OPT_DEMO_OUTPUT MessageBox(NULL, "event-unload", "MESSAGE", MB_OK); #endif OPT_DEMO_OUTPUT } // DLL entry point // Technically required, but don't do anything here. // Initializations belong into the OnLoad() function, // where they get executed at run-time. // Doing things here at load-time is a bad idea, // as some functionalitz might not be properly initialized // (including error/handling). BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: #ifdef OPT_DEMO_OUTPUT AllocConsole(); #endif OPT_DEMO_OUTPUT break; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: #ifdef OPT_DEMO_OUTPUT FreeConsole(); #endif OPT_DEMO_OUTPUT break; } return TRUE; } Source.zip DllAccess.au3
  14. Hi, I need the help of some "C++ Pros" of you.... The "WINAPI GetLogicalProcessorInformation" function does not exists in the AutoIt Includes, so I decided to build it on my own ....no success so far. I adapted easy functions, but this one seems to be odd and unfamiliar. I hope somebody can help me.... and after that this function should be added to the Includes (WinAPISys.au3). BOOL WINAPI GetLogicalProcessorInformation( _Out_ PSYSTEM_LOGICAL_PROCESSOR_INFORMATION Buffer, _Inout_ PDWORD ReturnLength ); https://msdn.microsoft.com/en-us/library/windows/desktop/ms683194(v=vs.85).aspx typedef struct _SYSTEM_LOGICAL_PROCESSOR_INFORMATION { ULONG_PTR ProcessorMask; LOGICAL_PROCESSOR_RELATIONSHIP Relationship; union { struct { BYTE Flags; } ProcessorCore; struct { DWORD NodeNumber; } NumaNode; CACHE_DESCRIPTOR Cache; ULONGLONG Reserved[2]; }; } SYSTEM_LOGICAL_PROCESSOR_INFORMATION, *PSYSTEM_LOGICAL_PROCESSOR_INFORMATION; https://msdn.microsoft.com/en-us/library/windows/desktop/ms686694(v=vs.85).aspx
  15. The nice ppl of voidtools created Everything Search Engine ( " Locate files and folders by name instantly. " ) And made a CLI program to search from the command line. They also gave the source code, and reading it, I see the IPC quite familiar. // // // source for CLI.H // Everything IPC test // revision 2: // fixed command line interpreting '-' as a switch inside text. // revision 3: // convert unicode to same code page as console. // revision 4: // removed write console because it has no support for piping. // revision 5: // added ChangeWindowMessageFilterEx (if available) for admin/user support. // compiler options #pragma warning(disable : 4311) // type cast void * to unsigned int #pragma warning(disable : 4312) // type cast unsigned int to void * #pragma warning(disable : 4244) // warning C4244: 'argument' : conversion from 'LONG_PTR' to 'LONG', possible loss of data #pragma warning(disable : 4996) // deprecation #include <windows.h> #include <stdio.h> #include "everything_ipc.h" #define COPYDATA_IPCTEST_QUERYCOMPLETEW 0 #define MSGFLT_RESET 0 #define MSGFLT_ALLOW 1 #define MSGFLT_DISALLOW 2 typedef struct tagCHANGEFILTERSTRUCT { DWORD cbSize; DWORD ExtStatus; } CHANGEFILTERSTRUCT, *PCHANGEFILTERSTRUCT; static void write(wchar_t *text); static void write_DWORD(DWORD value); static int wstring_to_int(const wchar_t *s); int sort = 0; EVERYTHING_IPC_LIST *sort_list; HMODULE user32_hdll = 0; BOOL (WINAPI *pChangeWindowMessageFilterEx)(HWND hWnd,UINT message,DWORD action,PCHANGEFILTERSTRUCT pChangeFilterStruct) = 0; int wstring_length(const wchar_t *s) { const wchar_t *p; p = s; while(*p) { p++; } return (int)(p - s); } // query everything with search string int sendquery(HWND hwnd,DWORD num,WCHAR *search_string,int regex,int match_case,int match_whole_word,int match_path) { EVERYTHING_IPC_QUERY *query; int len; int size; HWND everything_hwnd; COPYDATASTRUCT cds; everything_hwnd = FindWindow(EVERYTHING_IPC_WNDCLASS,0); if (everything_hwnd) { len = wstring_length(search_string); size = sizeof(EVERYTHING_IPC_QUERY) - sizeof(WCHAR) + len*sizeof(WCHAR) + sizeof(WCHAR); query = (EVERYTHING_IPC_QUERY *)HeapAlloc(GetProcessHeap(),0,size); if (query) { query->max_results = num; query->offset = 0; query->reply_copydata_message = COPYDATA_IPCTEST_QUERYCOMPLETEW; query->search_flags = (regex?EVERYTHING_IPC_REGEX:0) | (match_case?EVERYTHING_IPC_MATCHCASE:0) | (match_whole_word?EVERYTHING_IPC_MATCHWHOLEWORD:0) | (match_path?EVERYTHING_IPC_MATCHPATH:0); query->reply_hwnd = hwnd; CopyMemory(query->search_string,search_string,(len+1)*sizeof(WCHAR)); cds.cbData = size; cds.dwData = EVERYTHING_IPC_COPYDATAQUERY; cds.lpData = query; if (SendMessage(everything_hwnd,WM_COPYDATA,(WPARAM)hwnd,(LPARAM)&cds) == TRUE) { HeapFree(GetProcessHeap(),0,query); return 1; } else { write(L"Everything IPC service not running.\n"); } HeapFree(GetProcessHeap(),0,query); } else { write(L"failed to allocate "); write_DWORD(size); write(L" bytes for IPC query.\n"); } } else { // the everything window was not found. // we can optionally RegisterWindowMessage("EVERYTHING_IPC_CREATED") and // wait for Everything to post this message to all top level windows when its up and running. write(L"Everything IPC window not found, IPC unavailable.\n"); } return 0; } int compare_list_items(const void *a,const void *b) { int i; i = wcsicmp(EVERYTHING_IPC_ITEMPATH(sort_list,a),EVERYTHING_IPC_ITEMPATH(sort_list,b)); if (!i) { return wcsicmp(EVERYTHING_IPC_ITEMFILENAME(sort_list,a),EVERYTHING_IPC_ITEMFILENAME(sort_list,b)); } else if (i > 0) { return 1; } else { return -1; } } static void write(wchar_t *text) { DWORD mode; int wlen; DWORD numwritten; HANDLE output_handle; output_handle = GetStdHandle(STD_OUTPUT_HANDLE); wlen = wstring_length(text); if (GetConsoleMode(output_handle,&mode)) { WriteConsoleW(output_handle,text,wlen,&numwritten,0); } else { char *buf; int len; len = WideCharToMultiByte(GetConsoleCP(),0,text,wlen,0,0,0,0); if (len) { buf = HeapAlloc(GetProcessHeap(),0,len); if (buf) { WideCharToMultiByte(GetConsoleCP(),0,text,wlen,buf,len,0,0); WriteFile(output_handle,buf,len,&numwritten,0); HeapFree(GetProcessHeap(),0,buf); } } } } static void write_DWORD(DWORD value) { wchar_t buf[256]; wchar_t *d; d = buf + 256; *--d = 0; if (value) { DWORD i; i = value; while(i) { *--d = '0' + (i % 10); i /= 10; } } else { *--d = '0'; } write(d); } void listresultsW(EVERYTHING_IPC_LIST *list) { DWORD i; if (sort) { sort_list = list; qsort(list->items,list->numitems,sizeof(EVERYTHING_IPC_ITEM),compare_list_items); } for(i=0;i<list->numitems;i++) { if (list->items[i].flags & EVERYTHING_IPC_DRIVE) { write(EVERYTHING_IPC_ITEMFILENAME(list,&list->items[i])); write(L"\r\n"); } else { write(EVERYTHING_IPC_ITEMPATH(list,&list->items[i])); write(L"\\"); write(EVERYTHING_IPC_ITEMFILENAME(list,&list->items[i])); write(L"\r\n"); } } PostQuitMessage(0); } // custom window proc LRESULT __stdcall window_proc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam) { switch(msg) { case WM_COPYDATA: { COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam; switch(cds->dwData) { case COPYDATA_IPCTEST_QUERYCOMPLETEW: listresultsW((EVERYTHING_IPC_LIST *)cds->lpData); return TRUE; } break; } } return DefWindowProc(hwnd,msg,wParam,lParam); } void help(void) { write(L"-r Search the database using a basic POSIX regular expression.\n"); write(L"-i Does a case sensitive search.\n"); write(L"-w Does a whole word search.\n"); write(L"-p Does a full path search.\n"); write(L"-h --help Display this help.\n"); write(L"-n <num> Limit the amount of results shown to <num>.\n"); write(L"-s Sort by full path.\n"); } // main entry int main(int argc,char **argv) { WNDCLASSEX wcex; HWND hwnd; MSG msg; int ret; int q; wchar_t *search; wchar_t *d; wchar_t *e; wchar_t *s; int match_whole_word = 0; int match_path = 0; int regex = 0; int match_case = 0; int wasexename = 0; int matchpath = 0; int i; int wargc; wchar_t **wargv; DWORD num = EVERYTHING_IPC_ALLRESULTS; ZeroMemory(&wcex,sizeof(wcex)); wcex.cbSize = sizeof(wcex); if (!GetClassInfoEx(GetModuleHandle(0),TEXT("IPCTEST"),&wcex)) { ZeroMemory(&wcex,sizeof(wcex)); wcex.cbSize = sizeof(wcex); wcex.hInstance = GetModuleHandle(0); wcex.lpfnWndProc = window_proc; wcex.lpszClassName = TEXT("IPCTEST"); if (!RegisterClassEx(&wcex)) { write(L"failed to register IPCTEST window class\n"); return 1; } } if (!(hwnd = CreateWindow( TEXT("IPCTEST"), TEXT(""), 0, 0,0,0,0, 0,0,GetModuleHandle(0),0))) { write(L"failed to create IPCTEST window\n"); return 1; } // allow the everything window to send a reply. user32_hdll = LoadLibrary(L"user32.dll"); if (user32_hdll) { pChangeWindowMessageFilterEx = (BOOL (WINAPI *)(HWND hWnd,UINT message,DWORD action,PCHANGEFILTERSTRUCT pChangeFilterStruct))GetProcAddress(user32_hdll,"ChangeWindowMessageFilterEx"); if (pChangeWindowMessageFilterEx) { pChangeWindowMessageFilterEx(hwnd,WM_COPYDATA,MSGFLT_ALLOW,0); } } wargv = CommandLineToArgvW(GetCommandLineW(),&wargc); search = HeapAlloc(GetProcessHeap(),0,65536); if (!search) { write(L"failed to allocate "); write_DWORD(65536); write(L" bytes for search buffer.\n"); if (user32_hdll) { FreeLibrary(user32_hdll); } return 1; } d = search; // allow room for null terminator e = search + (65536 / sizeof(wchar_t)) - 1; wargc--; i = 0; for(;;) { if (i >= wargc) break; if (wcsicmp(wargv[i+1],L"-r") == 0) { regex = 1; } else if (wcsicmp(wargv[i+1],L"-i") == 0) { match_case = 1; } else if (wcsicmp(wargv[i+1],L"-w") == 0) { match_whole_word = 1; } else if (wcsicmp(wargv[i+1],L"-p") == 0) { match_path = 1; } else if (wcsicmp(wargv[i+1],L"-s") == 0) { sort = 1; } else if ((wcsicmp(wargv[i+1],L"-n") == 0) && (i + 1 < wargc)) { i++; num = wstring_to_int(wargv[i+1]); } else if (wargv[i+1][0] == '-') { // unknwon command help(); HeapFree(GetProcessHeap(),0,search); if (user32_hdll) { FreeLibrary(user32_hdll); } return 1; } else { // keep quotes ? q = 0; s = wargv[i+1]; while(*s) { if ((*s == ' ') || (*s == '\t') || (*s == '\r') || (*s == '\n')) { q = 1; break; } s++; } if ((d != search) && (d < e)) *d++ = ' '; if (q) { if (d < e) *d++ = '"'; } // copy append to search s = wargv[i+1]; while(*s) { if (d < e) *d++ = *s; s++; } if (q) { if (d < e) *d++ = '"'; } } i++; } // null terminate *d = 0; if (!sendquery(hwnd,num,search,regex,match_case,match_whole_word,match_path)) { // send query reports error HeapFree(GetProcessHeap(),0,search); if (user32_hdll) { FreeLibrary(user32_hdll); } return 1; } HeapFree(GetProcessHeap(),0,search); // message pump loop: // update windows if (PeekMessage(&msg,NULL,0,0,0)) { ret = (int)GetMessage(&msg,0,0,0); if (ret <= 0) goto exit; // let windows handle it. TranslateMessage(&msg); DispatchMessage(&msg); } else { WaitMessage(); } goto loop; exit: if (user32_hdll) { FreeLibrary(user32_hdll); } return 0; } static int wstring_to_int(const wchar_t *s) { const wchar_t *p; int value; p = s; value = 0; while(*p) { if (!((*p >= '0') && (*p <= '9'))) { break; } value *= 10; value += *p - '0'; p++; } return value; } // // // source for everything_ipc.h // Everything IPC #ifndef _EVERYTHING_IPC_H_ #define _EVERYTHING_IPC_H_ // C #ifdef __cplusplus extern "C" { #endif // 1 byte packing for our varible sized structs #pragma pack(push, 1) // WM_USER (send to the taskbar notification window) // SendMessage(FindWindow(EVERYTHING_IPC_WNDCLASS,0),WM_USER,EVERYTHING_IPC_*,lParam) // version format: major.minor.revision.build // example: #define EVERYTHING_IPC_GET_MAJOR_VERSION 0 // int major_version = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_MAJOR_VERSION,0); #define EVERYTHING_IPC_GET_MINOR_VERSION 1 // int minor_version = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_MINOR_VERSION,0); #define EVERYTHING_IPC_GET_REVISION 2 // int revision = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_REVISION,0); #define EVERYTHING_IPC_GET_BUILD_NUMBER 3 // int build = (int)SendMessage(hwnd,WM_USER,EVERYTHING_IPC_GET_BUILD,0); // find the everything window #define EVERYTHING_IPC_WNDCLASS TEXT("EVERYTHING_TASKBAR_NOTIFICATION") // find a everything search window #define EVERYTHING_IPC_SEARCH_WNDCLASS TEXT("EVERYTHING") // this global window message is sent to all top level windows when everything starts. #define EVERYTHING_IPC_CREATED TEXT("EVERYTHING_IPC_CREATED") // search flags for querys #define EVERYTHING_IPC_MATCHCASE 0x00000001 // match case #define EVERYTHING_IPC_MATCHWHOLEWORD 0x00000002 // match whole word #define EVERYTHING_IPC_MATCHPATH 0x00000004 // include paths in search #define EVERYTHING_IPC_REGEX 0x00000008 // enable regex // item flags #define EVERYTHING_IPC_FOLDER 0x00000001 // The item is a folder. (its a file if not set) #define EVERYTHING_IPC_DRIVE 0x00000002 // The folder is a drive. Path will be an empty string. // (will also have the folder bit set) // the WM_COPYDATA message for a query. #define EVERYTHING_IPC_COPYDATAQUERYA 1 #define EVERYTHING_IPC_COPYDATAQUERYW 2 // all results #define EVERYTHING_IPC_ALLRESULTS 0xFFFFFFFF // all results // macro to get the filename of an item #define EVERYTHING_IPC_ITEMFILENAMEA(list,item) (CHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMA *)(item))->filename_offset) #define EVERYTHING_IPC_ITEMFILENAMEW(list,item) (WCHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->filename_offset) // macro to get the path of an item #define EVERYTHING_IPC_ITEMPATHA(list,item) (CHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->path_offset) #define EVERYTHING_IPC_ITEMPATHW(list,item) (WCHAR *)((CHAR *)(list) + ((EVERYTHING_IPC_ITEMW *)(item))->path_offset) // // Varible sized query struct sent to everything. // // sent in the form of a WM_COPYDAYA message with EVERYTHING_IPC_COPYDATAQUERY as the // dwData member in the COPYDATASTRUCT struct. // set the lpData member of the COPYDATASTRUCT struct to point to your EVERYTHING_IPC_QUERY struct. // set the cbData member of the COPYDATASTRUCT struct to the size of the // EVERYTHING_IPC_QUERY struct minus the size of a CHAR plus the length of the search string in bytes plus // one CHAR for the null terminator. // // NOTE: to determine the size of this structure use // ASCII: sizeof(EVERYTHING_IPC_QUERYA) - sizeof(CHAR) + strlen(search_string)*sizeof(CHAR) + sizeof(CHAR) // UNICODE: sizeof(EVERYTHING_IPC_QUERYW) - sizeof(WCHAR) + wcslen(search_string)*sizeof(WCHAR) + sizeof(WCHAR) // // NOTE: Everything will only do one query per window. // Sending another query when a query has not completed // will cancel the old query and start the new one. // // Everything will send the results to the reply_hwnd in the form of a // WM_COPYDAYA message with the dwData value you specify. // // Everything will return TRUE if successful. // returns FALSE if not supported. // // If you query with EVERYTHING_IPC_COPYDATAQUERYW, the results sent from Everything will be Unicode. // typedef struct EVERYTHING_IPC_QUERYW { // the window that will receive the new results. HWND reply_hwnd; // the value to set the dwData member in the COPYDATASTRUCT struct // sent by Everything when the query is complete. ULONG_PTR reply_copydata_message; // search flags (see EVERYTHING_MATCHCASE | EVERYTHING_MATCHWHOLEWORD | EVERYTHING_MATCHPATH) DWORD search_flags; // only return results after 'offset' results (0 to return the first result) // useful for scrollable lists DWORD offset; // the number of results to return // zero to return no results // EVERYTHING_IPC_ALLRESULTS to return ALL results DWORD max_results; // null terminated string. arbitrary sized search_string buffer. WCHAR search_string[1]; }EVERYTHING_IPC_QUERYW; // ASCII version typedef struct EVERYTHING_IPC_QUERYA { // the window that will receive the new results. HWND reply_hwnd; // the value to set the dwData member in the COPYDATASTRUCT struct // sent by Everything when the query is complete. ULONG_PTR reply_copydata_message; // search flags (see EVERYTHING_MATCHCASE | EVERYTHING_MATCHWHOLEWORD | EVERYTHING_MATCHPATH) DWORD search_flags; // only return results after 'offset' results (0 to return the first result) // useful for scrollable lists DWORD offset; // the number of results to return // zero to return no results // EVERYTHING_IPC_ALLRESULTS to return ALL results DWORD max_results; // null terminated string. arbitrary sized search_string buffer. CHAR search_string[1]; }EVERYTHING_IPC_QUERYA; // // Varible sized result list struct received from Everything. // // Sent in the form of a WM_COPYDATA message to the hwnd specifed in the // EVERYTHING_IPC_QUERY struct. // the dwData member of the COPYDATASTRUCT struct will match the sent // reply_copydata_message member in the EVERYTHING_IPC_QUERY struct. // // make a copy of the data before returning. // // return TRUE if you processed the WM_COPYDATA message. // typedef struct EVERYTHING_IPC_ITEMW { // item flags DWORD flags; // The offset of the filename from the beginning of the list structure. // (wchar_t *)((char *)everything_list + everythinglist->name_offset) DWORD filename_offset; // The offset of the filename from the beginning of the list structure. // (wchar_t *)((char *)everything_list + everythinglist->path_offset) DWORD path_offset; }EVERYTHING_IPC_ITEMW; typedef struct EVERYTHING_IPC_ITEMA { // item flags DWORD flags; // The offset of the filename from the beginning of the list structure. // (char *)((char *)everything_list + everythinglist->name_offset) DWORD filename_offset; // The offset of the filename from the beginning of the list structure. // (char *)((char *)everything_list + everythinglist->path_offset) DWORD path_offset; }EVERYTHING_IPC_ITEMA; typedef struct EVERYTHING_IPC_LISTW { // the total number of folders found. DWORD totfolders; // the total number of files found. DWORD totfiles; // totfolders + totfiles DWORD totitems; // the number of folders available. DWORD numfolders; // the number of files available. DWORD numfiles; // the number of items available. DWORD numitems; // index offset of the first result in the item list. DWORD offset; // arbitrary sized item list. // use numitems to determine the actual number of items available. EVERYTHING_IPC_ITEMW items[1]; }EVERYTHING_IPC_LISTW; typedef struct EVERYTHING_IPC_LISTA { // the total number of folders found. DWORD totfolders; // the total number of files found. DWORD totfiles; // totfolders + totfiles DWORD totitems; // the number of folders available. DWORD numfolders; // the number of files available. DWORD numfiles; // the number of items available. DWORD numitems; // index offset of the first result in the item list. DWORD offset; // arbitrary sized item list. // use numitems to determine the actual number of items available. EVERYTHING_IPC_ITEMA items[1]; }EVERYTHING_IPC_LISTA; #ifdef UNICODE #define EVERYTHING_IPC_COPYDATAQUERY EVERYTHING_IPC_COPYDATAQUERYW #define EVERYTHING_IPC_ITEMFILENAME EVERYTHING_IPC_ITEMFILENAMEW #define EVERYTHING_IPC_ITEMPATH EVERYTHING_IPC_ITEMPATHW #define EVERYTHING_IPC_QUERY EVERYTHING_IPC_QUERYW #define EVERYTHING_IPC_ITEM EVERYTHING_IPC_ITEMW #define EVERYTHING_IPC_LIST EVERYTHING_IPC_LISTW #else #define EVERYTHING_IPC_COPYDATAQUERY EVERYTHING_IPC_COPYDATAQUERYA #define EVERYTHING_IPC_ITEMFILENAME EVERYTHING_IPC_ITEMFILENAMEA #define EVERYTHING_IPC_ITEMPATH EVERYTHING_IPC_ITEMPATHA #define EVERYTHING_IPC_QUERY EVERYTHING_IPC_QUERYA #define EVERYTHING_IPC_ITEM EVERYTHING_IPC_ITEMA #define EVERYTHING_IPC_LIST EVERYTHING_IPC_LISTA #endif // restore packing #pragma pack(pop) // end extern C #ifdef __cplusplus } #endif #endif // _EVERYTHING_H_ so, the reason for this posting is: it can be implemented in AutoIt3 I personally can run es.exe and get the results from the command line, that is I, with my knowing, now, some of you can make a beautiful UDF ( and I say some of you, because, I would not know where to start ) I use everything for everything, very handy tool. If you ever get to see it work, you'll see how handy it is, mostly if you have many terabytes of files ( or just plain can't remember where a file is at )
  16. I wrote this a while ago and only recently implemented shading. The current shading algorithm could use some improvements. Most of the source is based from here. The .dll source is also in the archive (made with Visual Studio 2012 Express). 2D Water simulation using a C++ dll.7z If you use a x64 bit OS then: EDIT: Added an example using a .gif file (split into frames).
  17. I think there's only a little difference when you create a GUI program with AutoIt from developing a GUI program by writing it in C++, mostly, if you're including cURL in your project.. Because sometimes, I feel that I can write my AutoIt script in C++ programming language. But of course, using AutoIt language is much easier (artificially).. Any thoughts (in detail) about it? And about their differences?
  18. I'm trying to understand following code which I want to convert to Autoit: RedEyeCorrection VOID Example_RedEyeSetParameters(HDC hdc) { Graphics graphics(hdc); Image myImage(L"RedEyePhoto.jpg"); REAL srcWidth = (REAL)myImage.GetWidth(); REAL srcHeight = (REAL)myImage.GetHeight(); RectF srcRect(0.0f, 0.0f, srcWidth, srcHeight); Matrix myMatrix(1.0f, 0.0f, 0.0f, 1.0f, 300.0f, 20.0f); RECT redAreas[2] = {40, 10, 55, 30, 110, 20, 125, 40}; RedEyeCorrectionParams myRedEyeCorParams; myRedEyeCorParams.numberOfAreas = 2; myRedEyeCorParams.areas = redAreas; RedEyeCorrection myRedEyeCor; myRedEyeCor.SetParameters(&myRedEyeCorParams); // Draw the image with no change. graphics.DrawImage(&myImage, 20.0, 20.0, srcWidth, srcHeight); // Draw the image with the red eye correction. graphics.DrawImage(&myImage, &srcRect, &myMatrix, &myRedEyeCor, NULL, UnitPixel); } I made something like this here Global $tRECT1 = DllStructCreate("long left;long top;long right;long buttom") DllStructSetData($tRECT1, "left", 55) DllStructSetData($tRECT1, "top", 69) DllStructSetData($tRECT1, "right", 68) DllStructSetData($tRECT1, "buttom", 81) Global $pRECT1 = DllStructGetPtr($tRECT1) Global $tRECT2 = DllStructCreate("long left;long top;long right;long buttom") DllStructSetData($tRECT2, "left", 159) DllStructSetData($tRECT2, "top", 68) DllStructSetData($tRECT2, "right", 172) DllStructSetData($tRECT2, "buttom", 81) Global $pRECT2 = DllStructGetPtr($tRECT2) Global Const $tagREDEYECORRECTIONPARAMS = "uint numberOfAreas;int areas[2]" Global $tRedEye = DllStructCreate($tagREDEYECORRECTIONPARAMS) Global Const $pRedEye = DllStructGetPtr($tRedEye) DllStructSetData($tRedEye, "numberOfAreas", 2) DllStructSetData($tRedEye, "areas", $tRECT1, 1) DllStructSetData($tRedEye, "areas", $tRECT2, 2) $hEffect = _GDIPlus_EffectCreate($GDIP_REDEYECORRECTIONEFFECT) ConsoleWrite(_GDIPlus_EffectsSetParameters($hEffect, $pRedEye) & " / " & @error & @LF) but it is not working - return code 8, error code 2. I'm an absolute C++ noob and I hope somebody can help here. Br, UEZ
  19. If stringinstr($text, "substr") on a big text(the one i use) will average about 150-200 milisecs to loop through the text and finally finishing scanning text for string. The following c++ example will average about 15-30 milisecs. #include "stdafx.h" #include <iostream> #include <fstream> #include <string> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { string line; size_t found; ifstream myfile ("C:/Users/xxx/xxx/xxx/x/c++examples/io/iotexst/iotexst/file.xml"); if (myfile.is_open()) { while ( myfile.good() ) { getline (myfile,line); found = line.find("something that cant be found so we put a real test"); if (found!=string::npos) cout << "first 'name' found at: " << int(found) << endl; } myfile.close(); } else cout << "Unable to open file"; return 0; //return 0; } But what is most interesting of all that on the same file readed into string while using if StringRegexp(readed_text, "substr",0) the average time to finish will be 3-8 milisecs! My first guess is that stringregexp is actually that faster because of the way it figures out that the text cant be found by first trying to match the starting chars of the substring.
  20. Hi all, Im building a variant class that I want to make work, but Im running into compiler issues; issues that highlight that I have no idea what is going on under the hood for operators in C++. My class looks something like: class Variant { public: //Constructors Variant(void) : type(VAR_INTTYPE), int64value(0), databuffsize(0), databuff((char*)0) {} Variant(int); Variant(long long); Variant(double); Variant(const char* in); Variant(char* in); Variant(Variant & in);//Copy Constructor ~Variant();//Destructor //Operators Variant& operator= (Variant&); Variant& operator= (Variant); //Other irrelvant code... } And Im trying to do things like: Variant test; int main() { test = Variant(20); //btw, I have no intention of implementing assignment ops for primitive types for various reasons Variant lol(7); lol = test; return 0; } In GCC (mingw) this is throwing errors like: Any ideas what constructors or operators I am missing? I have looked around and cannot find any solution to my problem. Thanks in advance.
  21. For a long time now, I have been curious about the dealing of Interpreters, and compilers, and often, this curiousity manifests into some experimentation. My Interpreter (nicknamed PARADIME) is an attempt at interpreting the autoit syntax, to gain a better understanding of how AutoIT 'ticks' and also to cure my curiousity to see if I can write an interpreter for an existing language. The current (UNFINISHED) result I am quite happy with. A great deal of the syntatical features of autoit are implemented, with most intended to be implemented. The Following functionality operates correctly in my Interpreter: Global Declarations '=' Assignments Function calls (including recursive) Variant Datatype (Implementing Arrays, INT32, INT64, double, string) Operators: + - / * > < <> >= <= = == Singleline IF Multiline IF WHILE statements About 20 macros About 12 Builtin Functions{ ConsoleWrite FileRead FileOpen FileClose MsgBox(Non optional params only) Stringlen StringLeft/Right StringTrimLeft/Right TimerInit (TimerDiff() is bugged, however) } Arrays For example, the following code will execute correctly. $t = 1 $t2 = 2 if $t = $t2 then MsgBox(48, "TEST", "EQUALITY") if $t <> $t2 then MsgBox(48, "TEST", "NOT EQUALITY") Global $mate = 89, $eee, $f = 55, $arraydestroytest[65000] MsgBox(48, "TEST", "This Code is running in Paradime: " & $eee) While $mate < 4000 $arraydestroytest[$mate] = $mate $mate = $mate + 1 $r = "FFFF" & "00043" WEnd MsgBox(48, "TEST", "This Code is running in Paradime: " & $mate & " " & $arraydestroytest[$mate-1]) COnsoleWrite(Stringlen("LOL RECURSION")) ConsoleWrite("Macro Test:" & @LF) ConsoleWrite("Program files: " & @PROGRAMFILESDIR & @LF) ConsoleWrite("Common files: " & @CommonFilesDir & @CR) ConsoleWrite("My Documents: " & @MyDocumentsDir & @CR) ConsoleWrite("AppDataC files: " & @AppDataCommonDir & @CR) ConsoleWrite("DesktopC files: " & @DesktopCommonDir & @CR) ConsoleWrite("DocumentsC files: " & @DocumentsCommonDir & @CR) ConsoleWrite("FavouritesC files: " & @FavoritesCommonDir & @CR) ConsoleWrite("ProgramsC files: " & @ProgramsCommonDir & @CR) ConsoleWrite("StartMC files: " & @StartMenuCommonDir & @CR) ConsoleWrite("Startup files: " & @StartupCommonDir & @CR) ConsoleWrite("AppData files: " & @AppDataDir & @CR) ConsoleWrite("Desktop files: " & @DesktopDir & @CR) ConsoleWrite("Favs files: " & @FavoritesDir & @CR) ConsoleWrite("Program files: " & @ProgramsDir & @CR) ConsoleWrite("Start Menu files: " & @StartMenuDir & @CR) ConsoleWrite("Startup files: " & @StartupDir & @CR) ConsoleWrite(@CRLF & "Computer: " & @ComputerName & @CR) ConsoleWrite("WIN: " & @WindowsDir & @CR) ConsoleWrite("Working: " & @WorkingDir & @CR) ConsoleWrite("System: " & @SystemDir & @CR) ConsoleWrite("IP1: " & @IPAddress1 & @CR) ConsoleWrite("IP2: " & @IPAddress2 & @CR) ConsoleWrite("IP3: " & @IPAddress3 & @CR) ConsoleWrite("IP4: " & @IPAddress4 & @CR) ConsoleWrite("TempDir: " & @TempDir & @CR) ConsoleWrite("Username: " & @UserName & @CR) ConsoleWrite("HomeDrive: " & @HomeDrive & @CR) ConsoleWrite("HomePath: " & @HomePath & @CR) ConsoleWrite("HomeShare: " & @HomeShare & @CR) ConsoleWrite("LogonServer: " & @LogonServer & @CR) ConsoleWrite("LogonDomain: " & @LogonDomain & @CR) ConsoleWrite("LogonDNSDomain: " & @LogonDNSDomain & @CR) Academic Discourse: The biggest thing that surprised me was how well written/optimized AutoIT was (or how inefficient a C++ coder I am, having 6 months of experience ^^') My interpreter runs approximately 5.4X slower than the AutoIT interpreter, dispite the datastructures being similar. My guess is that these speed differences are due to two things: -Pointer passing: nearly everything large in the public autoit source has its pointer passed around as opposed to the datatype. Substantial portions of my code do not pointer-pass, reducing speed. Also, my inexperience/rush in writing this would attenuate this with potentially inferior code (relative to autoIT) -Operator evaluation: I originally thought that AutoIT's decision to treat every operand as a VARIANT class would incur a noticable overhead, so I thought I could sidestep it by using my original TOKEN datastructure from the lexing stage. Now I realise that this overhead is unavoidable, as im still doing typechecking and conversions with the token datatype. The only difference is Jonathon is doing it in a pretty little variant class and my parser_eval.cpp is littered with switch statements for every operand possibility for every operator. (Please dont look at the source, you will cry). PARADIME Implements, from scratch, -Custom Lexer/tokeniser -Stateful Recursive Decent Parser -Shunting yard algorithm for expression evaluation -implements std::map for Variable and builtinfunction pointer lookup -implements std::vector for token storage. Parser Evidently, I have attempted to deviate from Jonathons chosen parsing approach to test the validity of other algorithms, and initial results indicate that my parsing model is applicable. Both of our interpreters use the recursive decent model for traversing nested structures. Paradime has various parsing states transparent to parsing of the tokens themselves. The two main states are EXEC and IGNORE, where EXEC, executes the code up to the corresponding end of the code block (ENDIF, WEND etc), whereas IGNORE 'ignores' the contained code. I did not quite understand how Jon traversed nested structures, so I cannot comment further on his methods here. Handling of Expressions is done entirely different on the two interpreters. Jonathon uses a LALR Shift/Reduce Algorithm, where as I use dijkastras shunting yard algorithm. Thus far, both approaches seem entirely applicable. Variant Storage: Done the same on both interpreters. Array handling code is practically copied, It was better than anything I could ever make. Lookup Speed: One other thing I noticed is that Macros and Builtin functions have no optimal lookup table (in the public autoIT source). Perhaps, to improve speed, these things could be stored in a red/black binary tree to increase efficiency? Conclusion: All in all, the parsing and interpreting backbone is a magnificent piece of work, and all my attempts to replicate it and deconstruct (from the publicsource) it have only increased my sense of awe. I express my most sincere thanks to the autoit developers for such, and I hope that development of AutoIT never stops. One day, when I get out of highschool I would like to develop autoIT, who knows. Paradime Sourcecode: As previously mentioned, the vast majority of the sourcecode is created from scratch. However, the There was no point re-inventing the wheel when implementing some macros and some builtins, and the code for array handling in variants, and one or two syntatical expressions. These elements of the sourcecode are clearly labelled at the top and have the GNU license attached (Code from before Autoit went to closedsource). Credit is clearly given. Please dont look at it. It is poorly written, undercommented, and due to my bad choice to use the token structure as the operand structure, a good deal of parsing logic is littered in hundreds of lines of switch statements. (eww) http://code.google.com/p/paradime-interpreter/source/browse/#hg%2FParadime%2Fcore Please, dont judge me. SciTE integration: Thanks to LaCastiglione: command.38.*.au3="C:Paradime.exe" "$(FilePath)" command.name.38.*.au3=Paradime command.save.before.38.*.au3=1 command.shortcut.38.*.au3=Ctrl+F7Drop Paradime.exe into your C: drive. Future of Paradime: I will implement NOT, AND, OR, FOR-NEXT, SWITCH-CASE-ENDSWITCH, and user defined functions. Then I will deviate from autoit, exploring new, custom language constructs, but thats another academic project entirely. -hyperzap
  22. Hi all, I am presently creating a program in C++, and part of this program uses the WINAPI QueryPerformanceCounter() function to work out the time taken for certain events. The issue I am having is when I convert the double that my calculation gives me into a string, using sprintf(tempbuff, "%.15g", tok->fValue); When in the 'Debug' solution Config, it works perfectly well, producing numbers like 1.8736523754e+006 However, when in the release solution Config, it will produce something completely wrong: 1873652.3754... What is causing this? How can I fix the problem? What is the difference between the two configs anyway? Thankyou in advance.
  • Create New...