Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 01/03/2013 in Posts

  1. While running executable modules are locked in a manner that you can't edit them. Accessible for reading, but not for writing. This means that in order to modify them you must wait till they are done, start a new process to do a modifications and do what ever you want (if you have enough rights). Ability to do that without additional module (take this conditionally) improves security of an application and makes it more portable. For example, script in this post deletes itself (compiled or not) after it's done. Script from few posts down (link) adds files dropped on executable to its resource section. Another example would be to add/update configuration data of the module that is stored within it (attached or as a resource), or to add a sort of hash check with ability to update it. How to do it? The idea is this (it's actually very obvious): - make a new process that will wait for the main process to exit and then do desired modifications on the main module. AutoIt's executables are specific. When you run AutoIt, it will look for the script to interpret and if it finds is it will try to run it, and if not it will exit. Built-in feature of every AutoIt executable is /AutoIt3ExecuteScript command line switch. It tells interpreter to interpret a script of our desire. I will use that. Another key moment is creating another process. Writing to hard drive is out of the question (because of the lack of coolness and new problems that could arrive upon that). Solution is much more advanced. I already explained the procedure before (link). It's running executables from memory. I will, in script that follows, start another process (of my wish) and rewrite its memory space in order for it to act as another interpreter. Another AutoIt interpreter. That new interpreter will execute the same script as the original one, but (and here is the catch) under changed circumstances. Script is written to initially check for the count of a specific Semaphore object. In case it exists it will execute part of the script that actually does the destruction. Semaphores are used widely before, there is nothing new to say about them. Not to quibble more, here's the script: SelfDestruct.au3 edit: New intro. It was pointed out to me from the different directions that the old one was kind of shitty.
    1 point
  2. Here's a snippet that demonstrates how to use the _GUIToolTip_xxx UDF functions, it's only a brief demo showing some of the techniques to use them. There are no examples in the help file that show how to create them, display them, or use them in general, so I had to figure this out by grabbing snippets here and there from around the internet and seeing how they work. There are several UDFs that utilize the tooltip UDF with explanations on how to use them with the controls that they are made for, for example the ListView and Tabs UDFs have functions that allow you to create tooltips for those controls, but not any general purpose examples are around the forum. It took me a while to find out how to get these to work but once I got the basics down they weren't hard to use at all. This script shows you how to create the tooltip, and how you can color them once they're created. It's heavily commented so it should be easy to follow. Take note of the comment after the _GUIToolTip_SetTipTextColor function, it's important to realize how to color the text correctly. #include <GUIConstantsEx.au3> #include <GUIToolTip.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $MESSAGE = "The following buttons have been clicked" Local $add, $clear, $close, $msg, $mylist Local $hGUI = GUICreate("My GUI list") Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON) ; create a balloon style tooltip control ; turn off visual style for the tooltip otherwise color settings won't work DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hToolTip, "wstr", 0, "wstr", 0) ; if you remove the previous line the tooltip displays normally, but you can't color it $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $hAdd = GUICtrlGetHandle($add) ; we need handles of the controls to use them with the tooltips $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $hClear = GUICtrlGetHandle($clear) $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) Local $hMylist = GUICtrlGetHandle($mylist) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) Local $hClose = GUICtrlGetHandle($close) GUISetState() ; the last number (9) in the below functions indicates that the $iID parameter is a handle to the control and not an identifier of the tooltip ; as well as subclassing the tooltip control _GUIToolTip_AddTool($hToolTip, 0, "Add something to the list", $hAdd, 0, 0, 0, 0, 9) ; this sets a tooltip to the add button _GUIToolTip_AddTool($hToolTip, 0, "This is the close button", $hClose, 0, 0, 0, 0, 9) ; this sets a tooltip to the close button _GUIToolTip_AddTool($hToolTip, 0, "This is the ListBox", $hMylist, 0, 0, 0, 0, 9) ; this sets a tooltip to the list control _GUIToolTip_AddTool($hToolTip, 0, "Clear the list box", $hClear, 0, 0, 0, 0, 9) ; this sets a tooltip to the clear button _GUIToolTip_AddTool($hToolTip, 0, "This is a tooltip for the whole GUI", $hGUI, 0, 0, 0, 0, 9) ; this sets a tooltip to the GUI, and not any control _GUIToolTip_SetTipBkColor($hToolTip, "0xA6EEA4") ; RGB value of the color for the background of the tooltip _GUIToolTip_SetTipTextColor($hToolTip, "0x6835EE") ; ColorRef value (BGR instead of RGB) for the text color of the tooltip While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $add GUICtrlSetData($mylist, "You clicked button No1|") Case $msg = $clear GUICtrlSetData($mylist, "") Case $msg = $close MsgBox(0, "", "the closing button has been clicked", 2) Exit EndSelect WEnd EndFunc ;==>Example
    1 point
  3. nitekram

    work with cmd

    http://autoit.de/index.php?page=Thread&threadID=9272 edit added second link, though not able to read it at work
    1 point
  4. Here's the same script with multiline tooltip text. #include <GUIConstantsEx.au3> #include <GUIToolTip.au3> Opt('MustDeclareVars', 1) Example() Func Example() Local $MESSAGE = "The following buttons have been clicked" Local $add, $clear, $close, $msg, $mylist Local $hGUI = GUICreate("My GUI list") Local $hToolTip = _GUIToolTip_Create($hGUI, $TTS_BALLOON) ; create a balloon style tooltip control ; turn off visual style for the tooltip otherwise color settings won't work DllCall("UxTheme.dll", "int", "SetWindowTheme", "hwnd", $hToolTip, "wstr", 0, "wstr", 0) ; if you remove the previous line the tooltip displays normally, but you can't color it ; This line will allow the tooltip to show multiple lines. If the line is too long to fit, it will be ; wrapped to the next line. If you add @CRLF to the tip text without this line, it will only display the firstline ; of text. _GUIToolTip_SetMaxTipWidth($hToolTip, 1000) ;;1000 is only proforma, you can set it longer or shorter $add = GUICtrlCreateButton("Add", 64, 32, 75, 25) Local $hAdd = GUICtrlGetHandle($add) ; we need handles of the controls to use them with the tooltips $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25) Local $hClear = GUICtrlGetHandle($clear) $mylist = GUICtrlCreateList("buttons that have been clicked", 176, 32, 121, 97) Local $hMylist = GUICtrlGetHandle($mylist) $close = GUICtrlCreateButton("my closing button", 64, 160, 175, 25) Local $hClose = GUICtrlGetHandle($close) GUISetState() ; the last number (9) in the below functions indicates that the $iID parameter is a handle to the control and not an identifier of the tooltip ; as well as subclassing the tooltip control _GUIToolTip_AddTool($hToolTip, 0, "Add something to the list" & @CRLF & "Click this button", $hAdd, 0, 0, 0, 0, 9) ; this sets a tooltip to the add button _GUIToolTip_AddTool($hToolTip, 0, "This is the close button", $hClose, 0, 0, 0, 0, 9) ; this sets a tooltip to the close button _GUIToolTip_AddTool($hToolTip, 0, "This is the ListBox", $hMylist, 0, 0, 0, 0, 9) ; this sets a tooltip to the list control _GUIToolTip_AddTool($hToolTip, 0, "Clear the list box", $hClear, 0, 0, 0, 0, 9) ; this sets a tooltip to the clear button _GUIToolTip_AddTool($hToolTip, 0, "This is a tooltip " & @CRLF & "for the whole GUI", $hGUI, 0, 0, 0, 0, 9) ; this sets a tooltip to the GUI, and not any control _GUIToolTip_SetTipBkColor($hToolTip, "0xA6EEA4") ; RGB value of the color for the background of the tooltip _GUIToolTip_SetTipTextColor($hToolTip, "0x6835EE") ; ColorRef value (BGR instead of RGB) for the text color of the tooltip While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $add GUICtrlSetData($mylist, "You clicked button No1|") Case $msg = $clear GUICtrlSetData($mylist, "") Case $msg = $close MsgBox(0, "", "the closing button has been clicked", 2) Exit EndSelect WEnd EndFunc ;==>Example You have to add _GUIToolTip_SetMaxTipWidth to get it to display multiline text, don't ask me why, but that's how it works.
    1 point
  5. Here a little example: #include <date.au3> #include <DateTimeConstants.au3> #include <GUIConstantsEx.au3> Opt('GUIOnEventMode', 1) Global $sTitel = 'Nearest Sunday' Local $hMainGui = GUICreate($sTitel, 400, 280, 140, 150) GUISetOnEvent($GUI_EVENT_CLOSE, '_MyExit') Global $idMnuHELP = GUICtrlCreateMenu("?", -1, 1) GUICtrlCreateMenuItem("Autor: autoBert", $idMnuHELP) GUICtrlCreateMenuItem("e&xit", $idMnuHELP) GUICtrlSetOnEvent(-1, '_MyExit') Local $idEdtDATE = GUICtrlCreateDate("01.01.2009", 20, 10, 150, 25, $DTS_UPDOWN) Local $DTM_SETFORMAT_ = 0x1032 Local $style = "dd.MM.yyyy" GUICtrlSendMsg($idEdtDATE, $DTM_SETFORMAT_, 0, $style) GUICtrlSetFont(-1, 12) GUICtrlCreateButton('&Check nearest Sunday', 220, 10, 150, 25) GUICtrlSetOnEvent(-1, '_CheckDate') Local $idLblRESULT = GUICtrlCreateLabel("", 12, 50, 200,25) GUICtrlCreateButton('e&xit', 220, 115, 150, 25) GUICtrlSetOnEvent(-1, '_MyExit') GUISetState() While 1 Sleep(120) WEnd Func _MyExit() GUIDelete($hMainGui) Exit EndFunc ;==>_MyExit Func _CheckDate() Local $sCheckDate = GUICtrlRead($idEdtDATE), $sMsg Local $iDay = StringLeft($sCheckDate,2) Local $iMonth = StringMid($sCheckDate,4,2) Local $iYear = StringRight($sCheckDate,4) ConsoleWrite($sCheckDate&@CRLF) Local $iDayOfWeek = _DateToDayOfWeekISO($iYear,$iMonth,$iDay) Switch $iDayOfWeek Case 7 ;<= $sMsg = "Lol, today is a sunday!" case 1,2,3 $sMsg = "The nearest sunday is " & _DateAdd("D",$iDayOfWeek*-1,$iYear&"/"&$iMonth&"/"&$iDay) Case Else $sMsg = "The nearest sunday is " & _DateAdd("D",7-$iDayOfWeek,$iYear&"/"&$iMonth&"/"&$iDay) EndSwitch GUICtrlSetData($idLblRESULT, $sMsg) GUISetState() EndFunc ;==>_CallEaster Edit: Script correctedt, thanks to Malkey
    1 point
  6. chakka, This will get you started ; get closest Sunday from whatever date this is run #include <date.au3> if @wday <= 4 then local $Sunday = _dateadd('D',-(7-@wday),_NowCalcDate()) ConsoleWrite($Sunday & @LF) Else local $Sunday = _dateadd('D',(7-@wday)+1,_NowCalcDate()) ConsoleWrite($Sunday & @LF) endif kylomas
    1 point
  7. Googling offers As for WindowInfo, it is useful mostly for elements having their own handles. To manipulate with HTMLayout, you can use the above udf or work with dll directly
    1 point
  8. The AutoIt Window Info tool is not well suited for this task. You should look at the functions in the help file beggining with the prefix _IE. For example _IEAction(). I haven't used them extensively, so I don't exactly know what they all do.
    1 point
  9. Well what I say isn't gospel and I'm sure I'm wrong on many occasion. I love discussions of this nature, because sooner or later when I do learn C/C++ it should be easier than going in head first.
    1 point
  10. Execute the command and fetch the result, I think like this: _MySQL_Real_Query _MySQL_Store_Result $result = _MySQL_Fetch_Row_StringArray $count = $result[0] _MySQL_Free_Result
    1 point
  11. trancexx

    ResHacker project

    Thanks If I add full path then it won't fit there. Main problem is (would be) caused by some big bitmap resource because it is drawn in its full size and if I move "Save Selected" button to the right to make space for file name + path then that button would be covered by mentioned huge bitmap. Full path is there as a tip on the filename label. But I could change window title. Will add Expand / Collapse option in Wiew menu (to be). edit: Nice avatar
    1 point
  12. Skrip

    ResHacker project

    Where...? I have to judge for myself.
    1 point
×
×
  • Create New...