Jump to content

RosarioC

Members
  • Posts

    18
  • Joined

  • Last visited

RosarioC's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. I've been trying to make a DirectX wrapper to be used with AutoIt or make a wrapper for a graphics engine/physics/what ever, but the functions don't work and i tried to use the plugin SDK didn't go so well.....So here's what i did: #include <d3d9.h> #pragma comment(lib,"d3d9.lib") LPDIRECT3D9 g_pD3D = NULL; LPDIRECT3DDEVICE9 g_pD3DDevice = NULL; HRESULT InitialiseD3D(HWND hWnd) { // First of all, create the main D3D object. If it is created successfully // we should get a pointer to an IDirect3D8 interface. g_pD3D = Direct3DCreate9(D3D_SDK_VERSION); if(g_pD3D == NULL) { return E_FAIL; } //Get the current display mode D3DDISPLAYMODE d3ddm; if(FAILED(g_pD3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &d3ddm))) { return E_FAIL; } // Create a structure to hold the settings for our device D3DPRESENT_PARAMETERS d3dpp; ZeroMemory(&d3dpp, sizeof(d3dpp)); // Fill the structure: Program shall be windowed, // back buffer format matches current display mode d3dpp.Windowed = TRUE; d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dpp.BackBufferFormat = d3ddm.Format; //Create a Direct3D device. if(FAILED(g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &g_pD3DDevice))) { return E_FAIL; } return S_OK; } void Render() { if(g_pD3DDevice == NULL) { return; } // Clear the backbuffer to blue g_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 255), 1.0f, 0); // Begin the scene g_pD3DDevice->BeginScene(); // Fill in here the rendering of other objects // End the scene g_pD3DDevice->EndScene(); // Fill back and front buffers so that back buffer will be visible on screen g_pD3DDevice->Present(NULL, NULL, NULL, NULL); } void CleanUp() { if(g_pD3DDevice != NULL) { g_pD3DDevice->Release(); g_pD3DDevice = NULL; } if(g_pD3D != NULL) { g_pD3D->Release(); g_pD3D = NULL; } } void MainLoop() { // Enter the main loop MSG msg; BOOL bMessage; PeekMessage(&msg, NULL, 0U, 0U, PM_NOREMOVE); while(msg.message != WM_QUIT) { bMessage = PeekMessage(&msg, NULL, 0U, 0U, PM_REMOVE); if(bMessage) { // Process message TranslateMessage(&msg); DispatchMessage(&msg); } else { Render(); // No message to process -> render the scene } }// while } // The windows message handler LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch(msg) { case WM_DESTROY: PostQuitMessage(0); return 0; break; case WM_KEYUP: switch (wParam) { case VK_ESCAPE: // Escape key pressed -> exit DestroyWindow(hWnd); return 0; break; } break; }// switch return DefWindowProc(hWnd, msg, wParam, lParam); } // Application main entry point INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT) { //Register the window class WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "DirectX Project", NULL }; RegisterClassEx(&wc); // Create the application's main window HWND hWnd = CreateWindow("DirectX Project", "Code::Blocks Template", WS_OVERLAPPEDWINDOW, 50, 50, 500, 500, GetDesktopWindow(), NULL, wc.hInstance, NULL); // Initialize Direct3D if(SUCCEEDED(InitialiseD3D(hWnd))) { // Show window ShowWindow(hWnd, SW_SHOWDEFAULT); UpdateWindow(hWnd); //Start game running: Enter the game loop MainLoop(); } CleanUp(); UnregisterClass("DirectX Project", wc.hInstance); return 0; } then when i tried to load it in AutoIt, they didn't load, well, some did, others didn't work. then i tried this: #include "main.h" //Define the functions. AU3_PLUGIN_FUNC g_pFuncs[] = { // {"_PointerTest", 0, 0}, {"Direct3D9DebugConsole", 0 , 0}, {"_CreateDirect3D9", 3, 4}, {"BeginSceneRender", 0, 0}, {"EndSceneRender", 0, 0}, }; AU3_PLUGINAPI int AU3_GetPluginDetails(int *n_AU3_NumFuncs, AU3_PLUGIN_FUNC **p_AU3_Func) { /* Pass back the number of functions that this DLL supports */ *n_AU3_NumFuncs = sizeof(g_pFuncs) / sizeof(AU3_PLUGIN_FUNC); /* Pack back the address of the global function table */ *p_AU3_Func = g_pFuncs; return AU3_PLUGIN_OK; } AU3_PLUGIN_DEFINE(Direct3D9DebugConsole) { AU3_PLUGIN_VAR *pDllResult; pDllResult = AU3_AllocVar(); //Allocate Memory for this var. HRESULT CoInitEx; //HResult to init COM bool Debugger; //Debugger variable SHELLEXECUTEINFO pDebuggerInfo; //Get the information for the debugger. //Initialize COM CoInitEx = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if(CoInitEx) { // HWND pOwner = AU3_GethWnd(pDllResult); pDebuggerInfo.cbSize = sizeof(SHELLEXECUTEINFO); //pDebuggerInfo.hwnd = pOwner; pDebuggerInfo.lpVerb = "open"; pDebuggerInfo.lpFile = "Direcr3D9 Debug Console.exe"; pDebuggerInfo.nShow = SW_SHOW; // pDebuggerInfo.lpIDList = PCIDLIST_ABSOLUTE; Debugger = ShellExecuteEx(&pDebuggerInfo); if(Debugger) { //return A-OK; return 1; } else { MessageBoxA(0,"Could not load/read the file","Please try again",MB_OK); return 0; } return 1; } else { MessageBoxA(0,"Could not initialize COM","Error",MB_OK); return 0; } *p_AU3_Result = pDllResult; *n_AU3_ErrorCode = GetLastError(); *n_AU3_ExtCode = 0; return AU3_PLUGIN_OK; } IDirect3D9* g_pDirect3D9 = NULL; IDirect3DDevice9* g_pDirect3DDevice9 = NULL; DLL_EXPORT int CreateDirect3D9(HWND hWnd, UINT width, UINT height) { g_pDirect3D9 = Direct3DCreate9(D3D_SDK_VERSION); if(FAILED(g_pDirect3D9)) { OutputDebugStr("Direct3D 9 couldn't be created."); } D3DPRESENT_PARAMETERS g_pD3DPresentParams; ZeroMemory(&g_pD3DPresentParams,sizeof(g_pD3DPresentParams)); g_pD3DPresentParams.Windowed = true; g_pD3DPresentParams.SwapEffect = D3DSWAPEFFECT_DISCARD; g_pD3DPresentParams.BackBufferFormat = D3DFMT_UNKNOWN; g_pD3DPresentParams.BackBufferWidth = width; g_pD3DPresentParams.BackBufferHeight = height; g_pD3DPresentParams.hDeviceWindow = hWnd; HRESULT D3DDevCreated = g_pDirect3D9->CreateDevice( D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_HARDWARE_VERTEXPROCESSING, &g_pD3DPresentParams, &g_pDirect3DDevice9); if(FAILED(D3DDevCreated)) { char Buffer[1000]; const char* DXErrorString = DXGetErrorStringA(D3DDevCreated); const char* DXErrorDesc = DXGetErrorDescriptionA(D3DDevCreated); sprintf(Buffer,"Error ceating device: %s : Error Description: %s",DXErrorString,DXErrorDesc); MessageBoxA(0, (LPCSTR)Buffer,(LPCSTR)Buffer,MB_OK); } if(g_pDirect3DDevice9 == NULL) { return 0; } return 1; } DLL_EXPORT int RenderSceneBegin() { if(g_pDirect3DDevice9) { if(FAILED(g_pDirect3DDevice9->Clear( 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0,0,255), 1.0f, 0 ))) { return 0; } else { if(FAILED(g_pDirect3DDevice9->BeginScene())) { MessageBoxA(0,"Failed to begin scene","Sorry",MB_OK); } else { MessageBoxA(0,"D3D Scene active","COOL",MB_OK); } } } return 1; } DLL_EXPORT int RenderSceneEnd() { g_pDirect3DDevice9->EndScene(); g_pDirect3DDevice9->Present(NULL,NULL,NULL,NULL); return 1; } DLL_EXPORT int ShutdownD3D9() { if(g_pDirect3D9 != NULL) g_pDirect3D9->Release(); if(g_pDirect3DDevice9 != NULL) g_pDirect3DDevice9->Release(); return 1; } BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) { switch (fdwReason) { case DLL_PROCESS_ATTACH: // attach to process // return FALSE to fail DLL load break; case DLL_PROCESS_DETACH: // detach from process break; case DLL_THREAD_ATTACH: // attach to thread break; case DLL_THREAD_DETACH: // detach from thread break; } return TRUE; // succesful } So yea, hopefully someone can put me on the right track, imagine how easily an editor can be made with AutoIt, plus wrapped libs. :-D
  2. YES!!! that is exactly what i was after! thanks. i've been trying to do that my self. also, is there a way to click on the TrayTip icon when it's visible>? you know lkie sometimes the tip shows up and only disappears when u click on it, opening a dialog? Thanks again, Sorry that i couldn't explain my self better...
  3. Sorry. Also i looked through the examples and tried to see what i was doing wrong and even these applications that have been tested and passed tests sday the file handle isn't valid yet they still do what they are suppose to
  4. i've beeu using the debug console the builtin one> seems like all the handles for the files are returning invalid even though it clearly loads the file. AutoIt:3.3.6.0/X64 (Os:WIN_7/X64 Language:0409 Keyboard:00000409 Cpu:X64) C:\Users\RO\Pictures\Untitled12.jpg : The handle is invalid. What do you make of it?
  5. Hello, i'm back, don't worry i was coding in AutoIt, was just trying to teach my self with out sounding like an annoying noob like i did that first time, but this time i seem to be stuck on 2 things i'm trying to do in my scripts. been trying everything i can think of to get this to work so hopefully you can help me out, i gotta say i love this scripting lanquage!! anyways, here is my script. Encryption.au3: #include <ComboConstants.au3> #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <TreeViewConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> #include <GuiComboBox.au3> #include <WinAPI.au3> #include <GuiTreeView.au3> #include <Debug.au3> ; These is the include files we need for this script to do what we want. #Region ### START Koda GUI section ### Form=c:\users\ro\documents\autoitscripts\encryption\archive.kxf $Archive = GUICreate("Archive Format v1.0", 579, 386, 198, 144) GUISetIcon("C:\Program Files\WinRAR\WinRAR.exe", -1) $Group1 = GUICtrlCreateGroup("Custom Archive Format", 8, 8, 561, 369) $Pic1 = GUICtrlCreatePic("C:\Users\RO\Documents\AutoITscripts\Encryption\Images\Marcus.gif", 16, 32, 293, 241) $Button1 = GUICtrlCreateButton("Add Files to Archive (.arch)", 360, 296, 161, 25) $Browse = GUICtrlCreateButton("....", 528, 296, 33, 25) ;$FileView = _GUICtrlTreeView_Create($Archive, 344, 32, 209, 241, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_EDITLABELS, $TVS_NOTOOLTIPS, $TVS_CHECKBOXES, $TVS_TRACKSELECT, $TVS_INFOTIP, $TVS_FULLROWSELECT, $TVS_NONEVENHEIGHT, $WS_BORDER)) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) ;$File = CreateArchFile() Global $DefaultFileName = "Untitled" Global $File = 1 Global $ArraySize = 10000000 Dim $FileFormat Global $ComboBox2 Global $CurSel, $hImage, $iImage $TreeParent = _GUICtrlTreeView_Create($Archive, 344, 32, 209, 241, BitOR($GUI_SS_DEFAULT_TREEVIEW, $TVS_EDITLABELS, $TVS_NOTOOLTIPS, $TVS_CHECKBOXES, $TVS_TRACKSELECT, $TVS_INFOTIP, $TVS_FULLROWSELECT, $TVS_NONEVENHEIGHT, $WS_BORDER)) _DebugSetup("TreeView", True) While 1 #cs _GUICtrlComboBox_BeginUpdate($ComboBox2) _GUICtrlComboBox_DeleteString($ComboBox2,0) _GUICtrlComboBox_DeleteString($ComboBox2,1) $CurSel = _GUICtrlComboBox_GetCurSel($ComboBox2) _GUICtrlComboBox_EndUpdate($ComboBox2) MsgBox(0,"selected:" , "" & $CurSel) #ce $nMsg = GUIGetMsg() Select Case $nMsg = $GUI_EVENT_CLOSE Exit Case $nMsg = $Browse $FileFormat = FileOpenDialog("Browse for files to encode", @WorkingDir, "Any File (*.*)", 4) For $x In $FileFormat $File = FileOpen($FileFormat, 0) Next _GUICtrlTreeView_BeginUpdate($TreeParent) For $x In $FileFormat ;$iImage = Random(0, 5, 1) $hItem = _GUICtrlTreeView_Add($TreeParent, 0, StringFormat("[%02d] New Item", $x)) ;$iImage, $iImage) For $y In $FileFormat ;$iImage = Random(0, 5, 1) _GUICtrlTreeView_AddChild($TreeParent, $hItem, StringFormat("[%02d] New Child", $y)); $iImage, $iImage) Next Next _GUICtrlTreeView_EndUpdate($TreeParent) _DebugOut("What??", True) EndSelect WEnd The output the consolse gives me: C:\Users\<user>\Documents\AutoITscripts\Encryption\Encrypt.au3 (77) : ==> Variable must be of type "Object".: For $x In $FileFormat hope you can set me straight by the way, how would you check for just a certain type of format? like say i just wanted to add images to a certain treeview parents, would i have to check all the files even made in one huge code block? or is there a way to get the index of the combo box for the FileOpen? (Tried to usr AutoIt window tool to get info from it, nothing. like you know what i mean by checking the extension? i would figure an array in the FileOpen function but i'm not sure i think i tried it and it didn't work.
  6. oh......sorry, i thought i heard that u could use that in case you wanted to change the file extension,.....my bad, don't mean to seem like i'm expecting all the work from you guys...
  7. but how would it know what mode the file is in? doesn't FileOpen set the mode? i think i saw a FileSetMode once in the help files.......seems to be gone.
  8. Hello, Now i'm sure you've heard these questions A MILLION TIMES, but i have tried to find somethingon it, even tried to look at the examples, not really getting it.....:-p. anyways, i have a file i created, i wrote text to it and it worked then i tried to write another text to it, nothing.......here it is: Begining of the file creation: $FileName = "\DataBase\Database.ext" $File = FileOpen($FileName,2) if $File then MsgBox(0,"File created" ,"QIGGADY!!") else MsgBox(0,"File not created","Error code: " & @error) endif the writing process: if FileExists($FileName) then $Write = FileWriteLine($FileName,"text") $Line2 = FileWriteLine($FileName,"text2") FileFlush($File) if $Line2 = 1 then MsgBox(0,"Line 2 written","QIGGIDY!!!") FileClose($fileName) endif if $Write = 1 then MsgBox(0,"This was a triumph, i'm making a note here; huge success","Data Written") else FileClose($fileName) MsgBox(0,"Can't write to file","" &$Write) endif else MsgBox(0,"File not found","" & $FileName) endif Chances are? i'm doing something horribly wrong which doesn't surprise me :-P
  9. the timer was just a test, it's not meant to be in it yet Oh, how would i move the cursor from one controlk to another after enter is pressed? can't seem to find anything on it.
  10. .......sorry :-P Ok, appointments.au3 file (main file): #include "Includes/actual_app.au3" While 1 $T = _Timer_Init() $Elapsed = (_Timer_Init()-$T)/1000 $nMsg = GUIGetMsg() #cs select loop for controls #ce Select Case $nMsg =$GUI_EVENT_CLOSE Exit Case $nMsg = $DoctorName $name = ReadFromCTRL($DoctorName) $start = StringLen($name) $limit = StringLen("Dr. Julian Ivo Robotnick, M.G.") MsgBox(0,"name", "Value = " & $name) ;if $name > "" then $state = GUICtrlGetState($address) if $state = $GUI_DISABLE then GUICtrlSetState($address,$GUI_ENABLE) endif ;else MsgBox(0,"","Limit: " & $limit) ;endif Case $nMsg = $address $addre = ReadFromCTRL($address) $limit = 40 if $addre >= $len then GUICtrlSetLimit($address,$limit) addDatatoCTRL($address,"") ;GUICtrlSetState($Date,$GUI_ENABLE) endif Case $nMsg = $Calander GUICtrlSetState($Month_Date, $GUI_SHOW) GUICtrlSetState($Create,$GUI_ENABLE) Case $nMsg = $Create Example($address) Endselect ;Select loop for menu items. select case $nMsg = $New MsgBox(0,"Opening.....","please wait") endselect WEnd Func Example($n) $msg = GUIGetMsg() $state = GUICtrlGetState($n) MsgBox(0, "state", " state: " & $state ) EndFunc ;==>Example CTRLS.au3 file: #include <ButtonConstants.au3> #include <DateTimeConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <GUIListBox.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Timers.au3> MsgBox(0,"Welcome to Appointment v1.0","have fun"); #Region ### START Koda GUI section ### Form=C:\Users\RO\Documents\AutoITscripts\Appointments\appointments.kxf $appointment = GUICreate("Appoitnment reminder v1.0", 841, 301, 190, 120) $File = GUICtrlCreateMenu("File") $New = GUICtrlCreateMenuItem("New...CTRL+N"&@TAB&"Ctrl+N", $File) $Open = GUICtrlCreateMenuItem("Open CTRL+O"&@TAB&"Ctrl+O", $File) $Save = GUICtrlCreateMenuItem("Save CTRL+S"&@TAB&"Ctrl+S", $File) $Exit = GUICtrlCreateMenuItem("Exit", $File) $appointmentsCTRL = GUICtrlCreateGroup("Appointments Edit", 16, 40, 553, 241) $DoctorName = GUICtrlCreateInput("", 104, 72, 169, 21) GUICtrlSetCursor (-1, 5) $address = GUICtrlCreateInput("", 104, 106, 169, 21) GUICTRLSetState($address,$GUI_DISABLE) GUICtrlSetCursor (-1, 5) $DoctorNam = GUICtrlCreateLabel(" Doctor's name", 24, 72, 75, 17) $addres = GUICtrlCreateLabel(" Address", 42, 104, 45, 17) GUICtrlSetCursor (-1, 5) $Month_Date = GUICtrlCreateMonthCal("2010/04/06", 328, 72, 229, 164) GUICtrlSetState($Month_Date, $GUI_HIDE) $DateOFAppointment = GUICtrlCreateLabel(" D.O.A", 48, 136, 42, 17) $Calander = GUICtrlCreateButton("", 280, 136, 32, 32, $BS_BITMAP) GUICtrlSetImage(-1, "C:\Users\RO\Documents\AutoITscripts\Appointments\Images\Button images\Calendar.bmp", -1) $DOA2 = GUICtrlCreateGroup("Date of Appoint", 96, 130, 169, 57) $Date = GUICtrlCreateInput("", 112, 160, 145, 21) GUICtrlSetState($Date,$GUI_DISABLE) $Create = GUICtrlCreateButton("Create Appointment", 96, 232, 105, 25) GUICtrlSetState($Create,$GUI_DISABLE) $Doc_word_count = GUICtrlCreateInput("", 280, 72, 40, 24) GUICtrlSetState($Doc_word_count,$GUI_DISABLE) $addressWcount = GUICtrlCreateInput("", 280, 104, 40, 24) GUICtrlSetState($addressWcount,$GUI_DISABLE) $Data = GUICtrlCreateList("", 600, 56, 225, 214) GUICtrlSetData($Data, "") GUICtrlSetCursor ($Data, 0) GUICtrlSetState($Data,$GUI_DISABLE) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### and the actual_app.au3: #include "CTRLS.au3" func addDatatoCTRL($Ctrl ,$Data) local $i = GUICtrlSetData($Ctrl,$data) return $i; endfunc func ReadFromCTRL($Ctrl) local $i = GUICtrlRead($Ctrl,$Data) return $i endfunc that's everything.
  11. Sorry, anyways, here it is: $name = ReadFromCTRL($DoctorName) $start = StringLen($name) $limit = StringLen("Dr. Julian Ivo Robotnick, M.G.") MsgBox(0,"name", "Value = " & $name) ;if $name > "" then $state = GUICtrlGetState($address) if $state = $GUI_DISABLE then GUICtrlSetState($address,$GUI_ENABLE) endif ;else MsgBox(0,"","Limit: " & $limit) ;endif also, i tried this function in the help files to get the state of a ctrl and got this: state: 144 here's the code if you need it. Func Example($n) $msg = GUIGetMsg() MsgBox(0, "state", " state: " & GUICtrlGetState($n)) EndFunc ;==>Example i can't find the 144 constant any where, unless it's in some other file.
  12. As you can see, it does return the value read from the control, so i don't know, any thoughts?
  13. well, i guess but i tried this $limit = StringLen("string") then checked if $name is > $limit, then run the code. Here it is: $name = ReadFromCTRL($DoctorName) $limit = StringLen("Dr. Julian Ivo Robotnick, M.G.") if $name < $limit then GUICtrlSetLimit($DoctorName,$limit) Send("{ENTER}") if GUICtrlGetState($address) = $GUI_DISABLE then GUICtrlSetState($address,$GUI_ENABLE) endif else MsgBox(0,"","Limit: " & $limit) endif this is what i tried before, at first it worked, sorta, now? the address input doesn't enable
  14. I'll admit when i'm beat :-) I've trying to do something like this: $var = GUICtrlRead($CtrlID) $var2 = 40 if $var > $var2 then MsgBox(0,"","") endif seems ok right? well this is how i'm setting it up: $name = ReadFromCTRL($DoctorName) $limit = "Dr. Julian Ivo Robotnick, M.G." MsgBox(0,"Length","Lenth: " & $limit) if $name == $limit then GUICtrlSetLimit($DoctorName,$limit) ;MsgBox(0,"Name too long","Name too long"); addDatatoCTRL($DoctorName,"") Send("{ENTER}") ;if GUICtrlGetState($address) = $GUI_DISABLE then GUICtrlSetState($address,$GUI_ENABLE) ;endif else MsgBox(0,"","") endif if you create two input controls, $DoctorName and $address and run this section in the $msng = $DoctorName you'll see that it just doesn't work, also i want to be able to save the value of the input controls so that i could write that info to a file/list. appreciate it :-D
×
×
  • Create New...