Nevercom Posted May 30, 2009 Share Posted May 30, 2009 Hi Folks ! I did some scripting in AutoIt and now i wish to transfer it to C++ I hope that some of Experienced guys here that do now about C++ help me about it. Here's my codes (Parts that i wish to transfer to Cpp): Local $PrevClip = ClipGet() Send('^c') $Data = ClipGet() $Data = StringReplace($Data, "'", "\'") $script = "SelText$ = '" & $Data & "'" & @CRLF & 'RunScript("GetData")' ClipPut($PrevClip) Thanks in Advance, Nevercom [left] [/left] Link to comment Share on other sites More sharing options...
Valuater Posted May 30, 2009 Share Posted May 30, 2009 Did that work in Autoit??Appears incorrect to me.... SelText$ $Data = "test" MsgBox(4096, "", "SelText$ = '" & $Data & "'" & @CRLF & 'RunScript("GetData")') Link to comment Share on other sites More sharing options...
Nevercom Posted May 30, 2009 Author Share Posted May 30, 2009 (edited) The code works in AutoIt, Here is the full code: #include <MMBLib.au3> if @Compiled AND $CmdLine[0] == 0 then MsgBox(16,"Error","Missing CMDLine parameters!") Exit endif if @Compiled then $title = $CmdLine[1] Else Exit endif if $CmdLine[2] == 'GetText' Then _GetText() Else Exit EndIf Func _GetText() Local $PrevClip = ClipGet() Send('^c') $Data = ClipGet() $Data = StringReplace($Data, "'", "\'") $script = "SelText$ = '" & $Data & "'" & @CRLF & 'RunScript("GetData")' SendScriptMMB($title,$script) ClipPut($PrevClip) Exit EndFunc I just mentioned the parts that i wish to convert BTW, Seltext$ with $ at the end, is a String variable in MMB, this code sends clipboard contents to MMB(MultiMedia Builder) Thanks Edited May 30, 2009 by Nevercom [left] [/left] Link to comment Share on other sites More sharing options...
Authenticity Posted May 31, 2009 Share Posted May 31, 2009 (edited) expandcollapse popup#include <Memory.au3> Global Const $CF_TEXT = 1 Global $tszBuff Global $hMem, $pMem If _IsClipboardFormatAvailable($CF_TEXT) Then If _OpenClipboard(0) Then $hMem = _GetClipboardData($CF_TEXT) $pMem = _MemGlobalLock($hMem) $tszBuff = DllStructCreate('char[' & _MemGlobalSize($hMem) & ']', $pMem) ConsoleWrite(DllStructGetData($tszBuff, 1) & @LF) _MemGlobalUnlock($hMem) _CloseClipboard() EndIf Else MsgBox(0x20, 'Info', 'No data string is available on the clipboard') EndIf Exit Func _IsClipboardFormatAvailable($iFormat) Local $aRet $aRet = DllCall('user32.dll', 'int', 'IsClipboardFormatAvailable', 'uint', $iFormat) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Func _OpenClipboard($hWnd) Local $aRet $aRet = DllCall('user32.dll', 'int', 'OpenClipboard', 'hwnd', $hWnd) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Func _CloseClipboard() Local $aRet $aRet = DllCall('user32.dll', 'int', 'CloseClipboard') If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFunc Func _GetClipboardData($iFormat) Local $aRet $aRet = DllCall('user32.dll', 'hwnd', 'GetClipboardData', 'uint', $iFormat) If @error Then Return SetError(1, 0, 0) Return $aRet[0] EndFuncI guess it's now clearer how to convert it, though, only CF_TEXT is assumed. The Send() part is using SendInput().Edit: ReferenceEdit2: Corrected script. Edited May 31, 2009 by Authenticity Link to comment Share on other sites More sharing options...
Nevercom Posted May 31, 2009 Author Share Posted May 31, 2009 Thanks Authenticity, But i'm afraid it makes me more confused.I'm really not an AutoIt Scripter nor C++ Programmer, I used AutoIt to make an application to enrich the application i made using MMB, Here (and you helped me there too, I owe you a Thanks, thank you very much)Now i accidentally found a way to make DLLs that works with MMB instead of using AutoIt (Because its much more faster), I don't know C++ but compiling a PlugIn SDK is not that hard.Actually i asked this question in C++ Related forums before, but got no responses, so i thought that its because they are not familiar with AutoIt, then i asked here, that maybe Someone that knows C++ and is familiar with AutoIt could help me.thank you really much, maybe its not fair to ask someone to do programming for you, but asking my question here is my last chance.Thanks for all your efforts guys [left] [/left] Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted May 31, 2009 Moderators Share Posted May 31, 2009 IMHO, it's not really a fare question. You're not "asking" anyone to "help", you're asking someone to do the actual translation. My suggestion is if you want to use another language, to sit down and learn it rather than clicking a few buttons that compile someones pre-made code. This way you actually understand what is happening. If you don't have the patience nor the want to for that, then you probably need to stick with what you know, and deal with the speed issues in other ways (like properly writing the code helps a ton). Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Roman9 Posted May 31, 2009 Share Posted May 31, 2009 You can try looking at the autoit source for specific things. Link to comment Share on other sites More sharing options...
monoceres Posted May 31, 2009 Share Posted May 31, 2009 Well I'm not going to translate that for you, however I will point you in the right directions.For the clipboard functions see: http://msdn.microsoft.com/en-us/library/ms674556(VS.85).aspxSend can be done with the SendInput function.The string operations is preferable done with std::string, for info see: http://www.cppreference.com/wiki/string/startRunning the script is done with ShellExecute() Broken link? PM me and I'll send you the file! Link to comment Share on other sites More sharing options...
Nevercom Posted May 31, 2009 Author Share Posted May 31, 2009 No, I was not expecting you to translate it for me completely, to just wait here and BOOM !! Done !No, I already read that MSDN reference about clipboard, but i didn't know to use which one of them and How ? i don't know about data types and the function parameters, i think you misunderstood me or perhaps i wasn't clear.My suggestion is if you want to use another language, to sit down and learn it rather than clicking a few buttons that compile someones pre-made code. This way you actually understand what is happening."I don't know C++ but compiling a PlugIn SDK is not that hard." actually needs a Wink smiley, i didn't mean that i just want the codes to be able to just click on compile button, I said that, to explain that however i'm not a C++ programmer, but it would be able to just learn about a few codes and use just them to make my work better (just in this case), rather than spending more than a year to be a fair programmer to be able to do this all by my own.I just said that i'm not a Pro or even a medium in programming, so i need someone to explain things for me, not to just show me the functions without any help on how to use themAnd as i said i asked my question in some Cpp related forums but i even didn't get any responses, so its very kind of you that helping me by Answering me !Thanks monoceres, as i said before i do not expect you or any others to do translation for me,Anyway, the links helped a lot, but any tips how to use them ?Thank you all you guys and please accept my apologies for bothering (However i didn't mean that). [left] [/left] Link to comment Share on other sites More sharing options...
Pain Posted May 31, 2009 Share Posted May 31, 2009 Perhaps you can use AutoItX instead, it has both AU3_ClipGet, AU3_ClipPut and AU3_Send. Link to comment Share on other sites More sharing options...
Nevercom Posted May 31, 2009 Author Share Posted May 31, 2009 Perhaps you can use AutoItX instead, it has both AU3_ClipGet, AU3_ClipPut and AU3_Send.Yes, thank you, but what about "SendScriptMMB($title,$script)", it uses "_SendMessage($hwnd,$WM_RUNSCRIPTCODE,$RUNSCRIPTCODE_LOUD,$pMemory)", i could do that already in C++, but dont know if its possible via AutoItX ? [left] [/left] Link to comment Share on other sites More sharing options...
Pain Posted May 31, 2009 Share Posted May 31, 2009 _SendMessage isn't in AutoitX, but it's not any problem if you are going to use C++ anyways.http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspx Link to comment Share on other sites More sharing options...
Nevercom Posted June 1, 2009 Author Share Posted June 1, 2009 _SendMessage isn't in AutoitX, but it's not any problem if you are going to use C++ anyways.http://msdn.microsoft.com/en-us/library/ms644950(VS.85).aspxThank you, yes as i said i have no problem sending the message,let me ask my question better, First we need to Send a Keystroke to the active window, Using SendInput(), i've looked at MSDN, but i did not found out how to use it, its a bit complicated for me !Then we need to make sure that clipboard contains the data in our specific format (In this case CF_TEXT, IsClipboardFormatAvailable), then if yes, we need to Open clipboard for further actions (if opened return value is nonzero), then we need to get clipboard Data(GetClipboardData), return value is handle to clipboard object in specified formatNow what should i do to the Handle returned by this function ????And for SetClipboardData Function, second parameter is a Handle, then handle to what ? what should i do to put the data into the clipboard(In this case i need to put the clipboard's data that clipboard contained before calling SendInput() back to the clipboard)Thanks in advance,Neverom [left] [/left] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now