Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/13/2012 in all areas

  1. BugFix version - 27 Dec 23 Fixed: No default value set for the MaxWidth parameter - took 12 years for someone to notice it! New UDF and new examples below and in zip. I just realised that although I have posted versions of this UDF many times in Help topics, I had never actually posted a "final" version here in Example scripts - better late than never, I suppose! StringSize takes a text string and calculates the size of label required to hold it as well as formatting the string to fit. Now AutoIt will, of course, size a label automatically to fit a text string, but it will not format the string in any way - what you use as the string is what you get in the label. If you do set any label sizes the text will be wrapped, but you can only determine the correct size of the label by trial and error. StringSize will, however, reformat the string to fit in a given width and tell you the required height so that you can read it all - whatever the font type or size - and you do not have to do the formatting beforehand. Here is a simple example to show what I mean (you need the UDF in the same folder for all the examples): And here is an example showing how StringSize can deal with different fonts and text sizes: You can see that the GUI is perfectly sized each time and that the button is always the right size and in the right place. StringSize returns an array which contains the formatted text to display and the size of the label needed to display it. All you need to do is to use the array elements when you create your label. Try changing the values in $aFont and $aSize if you want to try you own favourites - but beware, StringSize will return an error if you make the size so large that it cannot fit a word into the label width. NEW A more complex example showing how formatted and unformatted text can be sized correctly. The width of GUI holding the unformatted text varies randomly in width (the current value is displayed at top right): NEW And a final example showing how you can get your text in the largest possible font to fit in a given space: Finally here is the UDF itself: And all 5 files in zip format: StringSize.zip I hope you find this useful - I certainly do. M23
    1 point
  2. SkellySoul

    Editable Label

    Hello It has been quite awhile since I posted but thought I would share an interesting script that I am using in one of my projects. This script allows a user to quickly edit a label control and and relock it. #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> Global $Data, $Label GUICreate("Example", 500, 500) $Data = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480) $State = GUICtrlCreateButton("Lock", 0, 480, 500, 20) GUISetState(@SW_SHOW) $Set = 0 While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $State If $Set = 0 Then $Label = GUICtrlCreateLabel(GUICtrlRead($Data), 0, 0, 500, 480) GUICtrlSetState($Label, $GUI_HIDE) GUICtrlDelete($Data) GUICtrlSetState($Label, $GUI_SHOW) GUICtrlSetData($State, "Unlock") $Set = 1 ElseIf $Set = 1 Then $Data = GUICtrlCreateEdit(GUICtrlRead($Label), 0, 0, 500, 480) GUICtrlSetState($Data, $GUI_HIDE) GUICtrlDelete($Label) GUICtrlSetState($Data, $GUI_SHOW) GUICtrlSetData($State, "Lock") $Set = 0 Else ; _Error() Exit EndIf EndSwitch WEnd
    1 point
  3. Hi, I'm trying to make autoit login to vbulletin automatically with my username and password. I'm able to get the site loaded, after that what do I need to do to get the program to fill in the username and password for vbulletin and click the submit button? Or is there a premade function or script site out there where I can grab the code already? Here is the code from the HTML page for the login form on the submit page: <!-- login form --> <form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)"> <script type="text/javascript" src="clientscript/vbulletin_md5.js?v=367"></script> <table cellpadding="0" cellspacing="3" border="0"> <tr> <td class="smallfont"><label for="navbar_username">User Name</label></td> <td><input type="text" class="bginput" style="font-size: 11px" name="vb_login_username" id="navbar_username" size="10" accesskey="u" tabindex="101" value="User Name" onfocus="if (this.value == 'User Name') this.value = '';" /></td> <td class="smallfont" colspan="2" nowrap="nowrap"><label for="cb_cookieuser_navbar"><input type="checkbox" name="cookieuser" value="1" tabindex="103" id="cb_cookieuser_navbar" accesskey="c" />Remember Me?</label></td> </tr> <tr> <td class="smallfont"><label for="navbar_password">Password</label></td> <td><input type="password" class="bginput" style="font-size: 11px" name="vb_login_password" id="navbar_password" size="10" tabindex="102" /></td> <td><input type="submit" class="button" value="Log in" tabindex="104" title="Enter your username and password in the boxes provided to login, or click the 'register' button to create a profile for yourself." accesskey="s" /></td> </tr> </table> <input type="hidden" name="s" value="" /> <input type="hidden" name="do" value="login" /> <input type="hidden" name="vb_login_md5password" /> <input type="hidden" name="vb_login_md5password_utf" /> </form> <!-- / login form -->
    1 point
  4. UEZ

    Editable Label

    Here another approach: #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> Global $Data, $Label, $sData, $iExStyle, $iStyle, $hGUI, $hData, $State, $Set $hGUI = GUICreate("Example", 500, 500) $Data = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480) $hData = GUICtrlGetHandle($Data) $State = GUICtrlCreateButton("Lock", 0, 480, 500, 20) GUISetState(@SW_SHOW) $iStyle = _WinAPI_GetWindowLong($hData, $GWL_STYLE ) $iExStyle = _WinAPI_GetWindowLong($hData, $GWL_EXSTYLE) $Set = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $State If $Set = 0 Then _WinAPI_SetWindowLong($hData, $GWL_STYLE , BitXOR($iStyle, 0x3118C0)) ;this is unfortunately not working properly thus the GUIRegisterMsg() below GUICtrlSetData($State, "Unlock") _WinAPI_RedrawWindow($hGUI) $sData = GUICtrlRead($Data) GUIRegisterMsg($WM_COMMAND, '_WM_COMMAND') $Set = 1 ElseIf $Set = 1 Then _WinAPI_SetWindowLong($hData, $GWL_STYLE , $iStyle) GUICtrlSetData($State, "Lock") _WinAPI_RedrawWindow($hGUI) GUIRegisterMsg($WM_COMMAND, '') $Set = 0 Else ; _Error() Exit EndIf EndSwitch WEnd Func _WM_COMMAND($hWnd, $Msg, $wParam, $lParam) Switch BitAND($wParam, 0x0000FFFF) Case $Data GUICtrlSetData($Data, $sData) EndSwitch Return "GUI_RUNDEFMSG" EndFunc Or even easier: #include <WindowsConstants.au3> #include <Constants.au3> #include <EditConstants.au3> #include <WinAPI.au3> #include <GUIConstantsEx.au3> Global $Data, $Label, $hGUI, $hData, $State, $Set $hGUI = GUICreate("Example", 500, 500) $Data = GUICtrlCreateEdit("Write something in here and hit lock.", 0, 0, 500, 480) $State = GUICtrlCreateButton("Lock", 0, 480, 500, 20) GUISetState(@SW_SHOW) $Set = 0 While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $State If $Set = 0 Then GUICtrlSetState($Data, $GUI_DISABLE) GUICtrlSetData($State, "Unlock") $Set = 1 ElseIf $Set = 1 Then GUICtrlSetState($Data, $GUI_ENABLE) GUICtrlSetData($State, "Lock") $Set = 0 Else ; _Error() Exit EndIf EndSwitch WEnd Br, UEZ
    1 point
  5. JScript

    Editable Label

    In the UDF format to make life easier for noobs ... Regards, João Carlos.
    1 point
  6. MrCreatoR

    Editable Label

    I thought it would be something like this: #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Misc.au3> #include <WinAPI.au3> $hGUI = GUICreate("Example", 500, 500) $iLabel = GUICtrlCreateLabel("Some data, right click to show the menu.", 20, 20, 460, 40) $iMenu = GUICtrlCreateContextMenu($iLabel) $iRename_MItem = GUICtrlCreateMenuItem("Rename", $iMenu) GUISetState(@SW_SHOW) While 1 $iMsg = GUIGetMsg() Switch $iMsg Case $GUI_EVENT_CLOSE Exit Case $iRename_MItem GUICtrlSetState($iLabel, $GUI_HIDE) $aCtrlPos = ControlGetPos($hGUI, '', $iLabel) $iEdit = GUICtrlCreateEdit(GUICtrlRead($iLabel), $aCtrlPos[0], $aCtrlPos[1], $aCtrlPos[2]+5, $aCtrlPos[3]+5, BitOR($ES_WANTRETURN, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL)) $hEdit = GUICtrlGetHandle($iEdit) While 1 Sleep(10) $tPoint = _WinAPI_GetMousePos() If _WinAPI_WindowFromPoint($tPoint) <> $hEdit And (_IsPressed('01') Or _IsPressed('1B')) Then ExitLoop EndIf WEnd GUICtrlSetData($iLabel, GUICtrlRead($iEdit)) GUICtrlDelete($iEdit) GUICtrlSetState($iLabel, $GUI_SHOW) EndSwitch WEnd
    1 point
  7. JScript

    Editable Label

    My version: Regards, João Carlos.
    1 point
  8. water

    Understanding Arrays

    Depends on how the array was created. It's often referred to as "zero-based" or "one-based". Means the data starts in row 0 or row 1. If it starts in row 1 then row 0 contains the number of rows. If it is a two dimensional array then $array[0][0] contains the number of rows and $array[0][1] contains the number of columns. Check function StringSplit as an example. You can decide if the function returns a zero- or one-based array.
    1 point
  9. Assuming the link is a simple text link... _IELinkGetCollection() to get the link object then the .href property to get the URL. There's an example in the Help File for this function. Otherwise, do you have the HTML source of that page?
    1 point
  10. Spiff59

    Understanding Arrays

    Looking at it one way, the number of dimensions is almost meaningless. It's just another way of labelling the same variables or "mailboxes" that you're creating. $aArray[24] is the same thing as $aArray[3][8] (3 x 8 = 24) which is the same thing as $aArray[3][2][4] (3 x 2 x 4 = 24). They are all just a table of 24 variables. If your 3-story apartment building has 24 units and you just want to store all the apartment numbers then use $aArray[24] (apt#). If you want to organize them by floor you could create the same 24 boxes but reference them as $aArray[3][8] (floor/apt#) If you had a reason to keep the apartments on the north side of the building separate from those on the south side, then you could setup your 24 mailboxes as $aArray[3][2][4] (floor/north-south/apt#) When you reference the 17th element of the 1-dimension array; $aArray[17], it is the same thing internally as referencing element $aArray[2][0][1] of the 3-dimension array (2 x 8 + 0 x 4 + 1 x 1 = 17) Hope I haven't made things worse Edit: You could simulate any number of dimensions using a 1-dimension array and a few lines of code. This is, at least conceptually, the same thing that goes on internally when you decide to split your array into different dimensions: Global $aApartments[24] = ["1A","1B","1C","1D","1E","1F","1G","1H","2A","2B","2C","2D","2E","2F","2G","2H","3A","3B","3C","3D","3E","3F","3G","3H"] MsgBox(0, "1-Dimension", Dimension_Simulator("24", "17")) ; get element [17] of $aArray[24] MsgBox(0, "2-Dimension", Dimension_Simulator("3*8", "2|1")) ; get element [2][1] of $aArray[3][8] MsgBox(0, "3-Dimension", Dimension_Simulator("3*2*4", "2|0|1")) ; get element [2][0][1] of $aArray[3][2][4] Func Dimension_Simulator($structure, $element) Local $aStructure = StringSplit($structure, "*") Local $iSize = Execute($structure) ; total elements Local $aElement = StringSplit($element, "|") Local $iTarget For $x = 1 to $aElement[0] ; calculate element offset $iTarget += $aElement[$x] * ($iSize / $aStructure[$x]) $iSize /= $aStructure[$x] Next Return $aApartments[$iTarget] EndFunc
    1 point
  11. Global Const $tagWTS_SESSION_INFO = 'dword SessionId;ptr WinStationName;uint State' $Ret = DllCall('wtsapi32.dll', 'int', 'WTSEnumerateSessionsW', 'ptr', 0, 'dword', 0, 'dword', 1, 'ptr*', 0, 'dword*', 0) $Offset = 0 For $i = 1 To $Ret[5] $tInfo = DllStructCreate($tagWTS_SESSION_INFO, $Ret[4] + $Offset) $Offset += DllStructGetSize($tInfo) ConsoleWrite('SessionId: ' & DllStructGetData($tInfo, 'SessionId') & @CR) ConsoleWrite('WinStationName: ' & DllStructGetData(DllStructCreate('wchar[1024]', DllStructGetData($tInfo, 'WinStationName')), 1) & @CR) ConsoleWrite('State: ' & DllStructGetData($tInfo, 'State') & @CR) ConsoleWrite('--------------' & @CR) Next DllCall('wtsapi32.dll', 'none', 'WTSFreeMemory', 'ptr', $Ret[4]) Of course, you need to check for errors but you can do it yourself.
    1 point
×
×
  • Create New...