
likehu
Members-
Posts
4 -
Joined
-
Last visited
Everything posted by likehu
-
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
-
Unknown window appears during script run
likehu replied to likehu's topic in AutoIt General Help and Support
Yes, agree but i can't find anything about this window. Here is my image finder script. All other files (bmp icons ant ini file with coordinates) in the zip file in attachment. So I have started script in the SciTE or with EXE and after 5-10 mins that window blinks on desktop and dissappears. And script freezes. Just to explain shortly what this script does. There are 6 different icons and 4 big main areas on desktop and script try to find each icon on specific area inside every big main area. All this done in For..Next loop. Please help. #pragma compile(Console, False) #pragma compile(x64, True) #pragma compile(Compatibility, Win10) #pragma compile(Stripper, True) AutoItSetOption("GuiOnEventMode", 1) #Region Variables ;~ Const $bDebug = True Const $bDebug = False Const $cMatchLinePercentage = 0.99 ;Minimum matching, put on 1 if exact matching is needed on all lines ;~ Constants for type of picture matching Const $c24RGBFullMatch = 1 ;Load as 24 bits and full match Const $c24RGBPartialMatch = 2 ;Load as 24 bits and partial match Const $c16RGBFullMatch = 3 ;Load as 16 bits and full match Const $c16RGBPartialMatch = 4 ;Load as 16 bits and partial match ;~ array with BMP coords for every room Global $aBMPCoords[7][21][2] Global $cLB ;search area coord for left begin Global $cLE ;search area coord for left end Global $cTB ;search area coord for top begin Global $cTE ;search area coord for top end Global $fBMPSample Global $bSearchResult Global $Form1_1, $btnStart, $btnStop, $btnExit, $startFlag #EndRegion Variables #Region Includes #include <GDIPlus.au3> #include <ScreenCapture.au3> #include <string.au3> #include <Array.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <bmpsearch.au3> #EndRegion Includes #Region ### START Koda GUI section ### Form= $Form1_1 = GUICreate("Jonny", 194, 314, -510, 11) GUISetOnEvent($GUI_EVENT_CLOSE, "_exit") $lblt1 = GUICtrlCreateLabel("Table 1", 24, 16, 40, 17) $lblt2 = GUICtrlCreateLabel("Table 2", 128, 16, 40, 17) $lblt3 = GUICtrlCreateLabel("Table 3", 24, 104, 40, 17) $lblt4 = GUICtrlCreateLabel("Table 4", 128, 104, 40, 17) $lblr1 = GUICtrlCreateLabel("", 4, 40, 84, 20, $WS_BORDER) $lblr2 = GUICtrlCreateLabel("", 100, 40, 84, 20, $WS_BORDER) $lblr3 = GUICtrlCreateLabel("", 4, 128, 84, 20, $WS_BORDER) $lblr4 = GUICtrlCreateLabel("", 100, 128, 84, 20, $WS_BORDER) $btnStart = GUICtrlCreateButton("Start", 16, 272, 75, 25) GUICtrlSetOnEvent(-1, "start") $btnStop = GUICtrlCreateButton("Stop", 16, 240, 75, 25) GUICtrlSetOnEvent(-1, "stop") $btnExit = GUICtrlCreateButton("Exit", 104, 272, 75, 25) GUICtrlSetOnEvent(-1, "_exit") $dmyInterrupt = GUICtrlCreateDummy() GUICtrlSetOnEvent($dmyInterrupt, "interrupt") GUIRegisterMsg($WM_COMMAND, "interrupt") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### Main() Func Main() f_SearchBMPArray() While 1 Sleep(500) WEnd EndFunc ;==>Main Func start() $startFlag = True GUICtrlSetState($btnStart, $GUI_DISABLE) While $startFlag f_ReadTables() Sleep(500) WEnd Return EndFunc ;==>start Func f_ReadTables() $start = TimerInit() For $t = 1 To 4 ;check each of the 4 big main areas Local $Counter = 0, $LabelPoinet For $i = 1 To 6 ;insert needed coordinates for each icon depends of the number of big main area Switch $t Case 1 $cLB = Number($aBMPCoords[$i][5][1]) $cLE = Number($aBMPCoords[$i][6][1]) $cTB = Number($aBMPCoords[$i][7][1]) $cTE = Number($aBMPCoords[$i][8][1]) $LabelPoinet = $lblr1 Case 2 $cLB = Number($aBMPCoords[$i][9][1]) $cLE = Number($aBMPCoords[$i][10][1]) $cTB = Number($aBMPCoords[$i][11][1]) $cTE = Number($aBMPCoords[$i][12][1]) $LabelPoinet = $lblr2 Case 3 $cLB = Number($aBMPCoords[$i][13][1]) $cLE = Number($aBMPCoords[$i][14][1]) $cTB = Number($aBMPCoords[$i][15][1]) $cTE = Number($aBMPCoords[$i][16][1]) $LabelPoinet = $lblr3 Case 4 $cLB = Number($aBMPCoords[$i][17][1]) $cLE = Number($aBMPCoords[$i][18][1]) $cTB = Number($aBMPCoords[$i][19][1]) $cTE = Number($aBMPCoords[$i][20][1]) $LabelPoinet = $lblr4 Case Else ExitLoop EndSwitch $fBMPSample = @ScriptDir & $aBMPCoords[$i][3][1] f_Shots($aBMPCoords[$i][1][1], $fBMPSample, $cLB, $cLE, $cTB, $cTE) If $bSearchResult = False Then $Counter = $Counter + 1 Else $Counter = 0 GUICtrlSetData($LabelPoinet, $aBMPCoords[$i][1][1]) ExitLoop EndIf Next If $Counter = 6 Then GUICtrlSetData($LabelPoinet, '') EndIf Next EndFunc ;==>f_ReadTables Func f_Shots($RoomName, $SearchBMP, $cLB, $cTB, $cLE, $cTE) _GDIPlus_Startup() $hBMP = _ScreenCapture_Capture('', $cLB, $cTB, $cLE, $cTE, False) $bSearchResult = findBMP($hBMP, $SearchBMP, $c16RGBPartialMatch) ;Find needed image _GDIPlus_Shutdown() EndFunc ;==>f_Shots Func f_SearchBMPArray() ;create array with bmp paths and coordinates Local $aSectionNames = IniReadSectionNames(@ScriptDir & "\BMPCoord.ini") For $i = 1 To $aSectionNames[0] $aBMPCoords[$i][0][0] = $aSectionNames[$i] Local $aSectionValues = IniReadSection(@ScriptDir & "\BMPCoord.ini", $aSectionNames[$i]) For $k = 1 To $aSectionValues[0][0] $aBMPCoords[$i][$k][0] = $aSectionValues[$k][0] $aBMPCoords[$i][$k][1] = $aSectionValues[$k][1] Next Next EndFunc ;==>f_SearchBMPArray Func stop() $startFlag = False GUICtrlSetState($btnStart, $GUI_ENABLE) Return EndFunc ;==>stop Func interrupt($hWnd, $Msg, $wParam, $lParam) If (BitAND($wParam, 0x0000FFFF) = $btnStop) Or (BitAND($wParam, 0x0000FFFF) = $btnExit) Then $startFlag = False EndIf Return $GUI_RUNDEFMSG EndFunc ;==>interrupt Func _exit() Exit EndFunc ;==>_exit imagefinder.zip -
Hello I have wrote a script which capture 4 different regions on the screen then try to find a specific image in these regions and in case of success changes label text in my GUI. For screen scraping and image comparison script uses _ScreenCapture and FindBMP function. I put it in a loop with 1 second break. And all works great while after a couple of minutes hidden window appears and my script freezes. No text, no messages, no titles. When I try to close this window from windows taskbar it blinks on the center of the screen and hides again. Only “End Task” from task manages can close this window and script. The situation is the same when run it form SciTE or as EXE file. I also tried 2 different versions of Autoit, newest and previous. I can’t understand the cause of the problem. Is it a FindBMP function error or some overflow? Strange that it appears in a couple of minutes after totally normal work (images in the regions found and label changes continuously). I also tried to stop and start scanning every 1 min with help of buttons in GUI and nothing helps. Hidden window appears in 5-10 mins. Please advice from what steps I have to start to remove this window. Do I need to upload all script here?
-
Hello, I am trying to make it work nowadays and stuck as it usually happens with newbie. I have created the 123 MB HandRanks.dat file (VS2008 c++ express edition needed). The PluginOpen/PluginClose functions is not supported anymore so I have replaced it with DLLOpen/DllClose in RandomHandGenerator.au3 from "Poker Hand evaluator plugin" Geir1983. Also I have replaced ;line 17 $dat = LoadHRDat() ;line38 $Analysis = AnalyzeHand($myHand[0], $myHand[1], $myHand[2], $myHand[3], $myHand[4], $myHand[5], $myHand[6])with $dat = DllCall($handEval, Int, 'LoadHRDat') $Analysis = DllCall($handEval, int, 'AnalyzeHand', int, $myHand[0], int, $myHand[1], int, $myHand[2], int, $myHand[3], int, $myHand[4], int, $myHand[5], int, $myHand[6]) and after this script starts but after clicking "Deal new hand" stops with error Starting file RandomHandGenerator.au3... "D:\Downloads\PokerEval\PokerEval\RandomHandGenerator.au3" (50) : ==> Variable subscript badly formatted.: $k = $k + $Category[$j] $k = $k + $Category[^ ERRORReturn type "int" in DllCall was choosed randomly as script starts with it and dont start with "string" type for example. Maybe I am wrong here. After this I have tried to change ;line 42 For $j = 8 to $HandCategory-1 step -1 $k = $k + $Category[$j] Next ;line 49 MsgBox(0,"1", $HandString & @CRLF &"Type of Hand:"&$HandRanksArray[$position][0] &@CRLF& "Best 5 Card Hand:"& $HandRanksArray[$position][2] &@CRLF& "Generated and evaluated Hand in :" & $dif & " milliseconds." & @CRLF & "Hand Strength:" & Round(100*($HandRankWithinCategory/($Category[$HandCategory-1]))) & "%")to For $j = 8 To $HandCategory Step -1 $k = $k + $Category[$j] Next MsgBox(0, "1", $HandString & @CRLF & "Type of Hand:" & $HandRanksArray[$position-1][0] & @CRLF & "Best 5 Card Hand:" & $HandRanksArray[$position-1][2] & @CRLF & "Generated and evaluated Hand in :" & $dif & " milliseconds." & @CRLF & "Hand Strength:" & Round(100 * ($HandRankWithinCategory / ($Category[$HandCategory]))) & "%") and script always show the same evaluation result but random 7 cards were generated. It always show: type of hand: High Card best 5 card hand: 75432 Hand strength: 0% Please help to make it work. :) RandomHandGenerator.au3