longtex Posted June 25, 2008 Share Posted June 25, 2008 Here's a simple EULA script - displays an RTF file, gets Agree/Disagree, and if agreed, executes whatever else you want. expandcollapse popup; Hacked from the guicctrlreateedit example by longtex 20080625 ; Needs: MSCOMCT2.OCX in system32 but it's probably already there ; longtex sez: not if you're running XP Pro... #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <EditConstants.au3> #include <StaticConstants.au3> Opt('MustDeclareVars', 1) xp27_eula() func xp27_eula () Global $oMyError Local $oRP, $iagree, $noagree, $GUIActiveX, $msg local $snert, $agreed local $eula_title, $noagmsg, $eula_ok_proc, $eula_rtf_file $eula_title = "Library User Agreement" $noagmsg = "In order to prevent terrorists from hurting us because they hate our freedoms, it is necessary that we give up some or all of our freedoms. You don't agree, so you can't use this computer. Under the terms of the various provisions of the various Patriot Acts, you are or may be a terrorist. Please don an orange jumpsuit, place a bag over your head, and report to the nearest Homeland Sekkkurity Detention Center immediately. Failure to comply may result in loss of all remaining freedoms, including Life, Liberty, and the Pursuit of Happiness." $eula_rtf_file = "C:\scans\libula.rtf" $eula_ok_proc = "Notepad.exe c:\dipdipdip.txt" $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $oRP = ObjCreate("RICHTEXT.RichtextCtrl.1") GUICreate($eula_title, 600,400, -1, -1, BitOR($ES_READONLY,$WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN,$ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) $iagree = GUICtrlCreateButton('I Submit', 405, 377, 70, 20) $noagree = GUICtrlCreateButton('No Way!!', 475, 377, 70, 20) $GUIActiveX = GUICtrlCreateObj($oRP, 10, 10, 550, 300) GUICtrlSetPos($GUIActiveX, 10, 10, 300, 590) $agreed = 0 With $oRP; Object tag pool $snert = .deftextrtf() $oRP.LoadFile($eula_rtf_file) $orp.refresh() EndWith GUISetState();Show GUI While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $iagree $agreed = 1 ExitLoop Case $msg = $noagree $agreed = 0; ;msgbox(0,"Can't do it","In order to prevent terrorists from hurting us because they hate our freedoms, it is necessary that we give up some or all of our freedoms. You don't agree, so you can't use this computer. Under the terms of the various provisions of the various Patriot Acts, you are or may be a terrorist. Please don an orange jumpsuit, place a bag over your head, and report to the nearest Homeland Sekkkurity Detention Center immediately. Failure to comply may result in loss of all remaining freedoms, including Life, Liberty, and the Pursuit of Happiness.") ExitLoop EndSelect WEnd GUIDelete() if $agreed > 0 Then msgbox(0,"","I swear to fricken God I'm gonna run something for ya"&@CRLF&@CRLF&"probly gonna be '"&$eula_ok_proc&"'") run($eula_ok_proc) Else msgbox(0,"Failure to Submit",$noagmsg) EndIf EndFunc Func MyErrFunc() MsgBox(0, "AutoItCOM Test", "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ , 5) ; Will automatically continue after 5 seconds Local $err = $oMyError.number If $err = 0 Then $err = -1 SetError($err) ; to check for after this function returns EndFunc ;==>MyErrFunc Nobody needs a job. Not much, anyway. Before you need a job, there's a lot of other stuff you need. More or less in order of how badly you need them: AIR, WATER, FOOD, SHELTER, CLOTHING, COMPANIONSHIP, and ACTIVITY. You've been led to believe you need money to "pay" someone else to provide those for you - all but AIR, so far. How long is it going to be before you have to "pay" for AIR, too? Link to comment Share on other sites More sharing options...
WeMartiansAreFriendly Posted June 25, 2008 Share Posted June 25, 2008 (edited) Hi, I get the following ErrorMSCOMCT2.OCX does exist and it is indeed registered. :/[edit]You should "always" declare Global variables outside of functions.. Global $oMyErrorAlso after you create the object you should check if it exist, since you registered the error handler just exit the scriptIf Not IsObj($oRP) Then Exit ;exit after object failed Edited June 25, 2008 by mrRevoked Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet() Link to comment Share on other sites More sharing options...
longtex Posted June 26, 2008 Author Share Posted June 26, 2008 Hi, I get the following Error MSCOMCT2.OCX does exist and it is indeed registered. :/ [edit] You should "always" declare Global variables outside of functions.. Global $oMyError Also after you create the object you should check if it exist, since you registered the error handler just exit the script If Not IsObj($oRP) Then Exit ;exit after object failed I've not seen that url anywhere. After I got the ocx registered, there was another error, about it being not licensed. I fixed that with a link found heret: http://www.access-programmers.co.uk/forums...5803#post275803 I take your point about the global - I was just trying to give a working example of the function after getting it working as a standalone. As you no doubt read, it was created from the example in the help file, and in returning it to a function I didn't move the global, that's all. Unfortunately, in order to test it thoroughly, I have to make it fail, and it doesn't fail on my computers (now). I'll be testing it at the library, but it's slightly inconvenient, as we're in a small, remote town, and our library is open from 1000 to 1730 only... Do you have any idea where that url came from? As far as checking the object - sure, you're right... but it depends on what you're using it for... in the particular context (it's a EULA), we can't simply QUIT... need to know WHY it fails, and hopefully be able to take some sort of remedial actions and try repeatedly until - having tried everything we know about - we finally have to give up and report failure. I've been flogging away at this for quite a bit, so I've probably lost sight of some of the things I had to do to make it work. The app for which I developed it is explained in some detail in the two or three threads leading up to this one. I'd love to list them for you right here, right now, but I've got an appointment in a few minutes, so I have to post this and go... you might try searching for "longtex" - there's one thread in example scripts regarding Word Automation (last page) and another in ActiveX... Nobody needs a job. Not much, anyway. Before you need a job, there's a lot of other stuff you need. More or less in order of how badly you need them: AIR, WATER, FOOD, SHELTER, CLOTHING, COMPANIONSHIP, and ACTIVITY. You've been led to believe you need money to "pay" someone else to provide those for you - all but AIR, so far. How long is it going to be before you have to "pay" for AIR, too? Link to comment Share on other sites More sharing options...
dhart Posted August 18, 2009 Share Posted August 18, 2009 (edited) EDIT: sorry didn't see the message about this not being a support forum Edited August 18, 2009 by dhart 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