Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 02/19/2014 in all areas

  1. Melba23

    Tab BG Colour

    cookiemonster, This script colours tabs quite nicely: #include <GuiConstantsEx.au3> #include <GuiTab.au3> #include <StaticConstants.au3> ; Tab colours Global $aTabColours[4] = [0xFFC0C0, 0xC0FFC0, 0xC0C0FF, 0xC0C0C0] ; Create GUI Global $hGUI = GUICreate ("Test", 400,300) GUISetBkColor (0) ; Create label to cover tab "tab" Global $hColourTab = GUICtrlCreateLabel("", 0, 0, 1, 1, BitOR($SS_NOTIFY, $SS_CENTER, $SS_SUNKEN)) ; Create tab Global $hTab = GUICtrlCreateTab(5, 5,390, 290) Global $hTab_Handle = GUICtrlGetHandle($hTab) ; Create tab items and colour them For $i = 0 To 3 GUICtrlCreateTabItem ("Tab item - " & $i) _GUICtrlTab_SetBkColor($hGUI, $hTab, $aTabColours[$i]) GUICtrlCreateTabItem ("") Next _GUICtrlTab_SetCurSel($hTab_Handle,0) _GUICtrlTab_SetCurFocus($hTab_Handle,0) TabEvent() GUISetState () While 1 Switch GUIGetMsg () Case $GUI_EVENT_CLOSE Exit Case $hTab TabEvent() EndSwitch WEnd Func TabEvent() ; Set values Local $iTab_X = 5, $iTab_Y = 5, $iTab_Margin = 1 ; Get index of current tab Local $iTab_Index = GUICtrlRead($hTab) ; Get coordinates of TabItem Local $aTab_Coord = _GUICtrlTab_GetItemRect($hTab_Handle, $iTab_Index) ; Get text of TabItem Local $sTab_Text = _GUICtrlTab_GetItemText($hTab_Handle, $iTab_Index) ; Place label GUICtrlSetPos($hColourTab, $iTab_X + $aTab_Coord[0] + $iTab_Margin, $iTab_Y + $aTab_Coord[1] + $iTab_Margin, $aTab_Coord[2] - $aTab_Coord[0] - ($iTab_Margin * 2), $aTab_Coord[3] - $aTab_Coord[1] - ($iTab_Margin * 2) + 5) ; Set text GUICtrlSetData($hColourTab, $sTab_Text) ; Set colour GUICtrlsetBkColor ($hColourTab,$aTabColours[$iTab_Index] ) ; Set focus _GUICtrlTab_SetCurFocus($hTab_Handle,$iTab_Index) EndFunc Func _GUICtrlTab_SetBkColor($hWnd, $hSysTab32, $sBkColor) ; Get tab position Local $aTabPos = ControlGetPos($hWnd, "", $hSysTab32) ; Get size of user area Local $aTab_Rect = _GUICtrlTab_GetItemRect($hSysTab32, -1) ; Create label GUICtrlCreateLabel("", $aTabPos[0] + 2, $aTabPos[1] + $aTab_Rect[3] + 4, $aTabPos[2] - 6, $aTabPos[3] - $aTab_Rect[3] - 7) ; Colour label GUICtrlSetBkColor(-1, $sBkColor) ; Disable label GUICtrlSetState(-1, $GUI_DISABLE) EndFunc ;==>_GUICtrlTab_SetBkColor Any use? M23
    2 points
  2. So I think it's time to publish this little tutorial I have made on using DllCall() and DllStructs. It's not near completion but I think it's a good start at least This tutorial is mostly aimed for people who have never used DllCall() before or have very limited knowledge about it. In the future I will update it with more advanced topics so more advanced users can make use of it too. Well here goes. Dealing_with_Dll.pdf Previous downloads: 31 Suggestions, language corrections and errors in the tutorial is of course welcome.
    1 point
  3. Factfinder

    RegEx lazy quantifier

    The script I suggested is not a workaround. It is the correct script. Your script doesn't work because ? applies forward to string coming after href=" up to the first ">Yarp. So if you had a second ">Yarp in the string the ? would make it match only up to the first ">Yarp. As DXRW4E mentioned, your script start at the first href=" and ends at the first ">Yarp because ? doesn't work backwards. To eliminate all the href=" in the string except the one preceding ">Yarp you should use the script I suggested.
    1 point
  4. DXRW4E

    RegEx lazy quantifier

    yes right, but the '">Yarp' is already the first Match, so everything is ok try #include <Array.au3> Local $sString = '<TD colSpan=4><SPAN style="FONT-VARIANT: small-caps">Sub-Categories: [<A href="Categories.aspx?id=2b249c75-f666-424e-b555-bf9ee8f34152">Yarp</A>] ' $sString &= '[<A href="Categories.aspx?id=584378e4-917a-4fce-a6ff-e75fb966e36f">Nay</A>] [<A href="Categories.aspx?id=042394b4-1c0e-42d9-a9ba-bca9ea1394b1">Nada</A>] ' $sString &= '[<A href="Categories.aspx?id=8d72025e-a23a-4c81-8174-d3fc4e1eb469">Yarp</A>] ' Local $aTemp = StringRegExp($sString, 'href="(.*?)">Yarp', 3) _ArrayDisplay($aTemp) or tell RegExp to find the last 'href=' #include <Array.au3> Local $sString = '<TD colSpan=4><SPAN style="FONT-VARIANT: small-caps">Sub-Categories: [<A href="Categories.aspx?id=2b249c75-f666-424e-b555-bf9ee8f34152">Nope</A>] ' $sString &= '[<A href="Categories.aspx?id=584378e4-917a-4fce-a6ff-e75fb966e36f">Nay</A>] [<A href="Categories.aspx?id=042394b4-1c0e-42d9-a9ba-bca9ea1394b1">Nada</A>] ' $sString &= '[<A href="Categories.aspx?id=8d72025e-a23a-4c81-8174-d3fc4e1eb469">Yarp</A>] ' Local $aTemp = StringRegExp($sString, '.*href="(.*?)">Yarp', 3) _ArrayDisplay($aTemp) Ciao.
    1 point
  5. Factfinder

    RegEx lazy quantifier

    Your original script would work with a little change, instaed of (.*?) use ([^>]*?) like this: $sString = '<TD colSpan=4><SPAN style="FONT-VARIANT: small-caps">Sub-Categories: [<A href="Categories.aspx?id=2b249c75-f666-424e-b555-bf9ee8f34152">Nope</A>] [<A href="Categories.aspx?id=584378e4-917a-4fce-a6ff-e75fb966e36f">Nay</A>] [<A href="Categories.aspx?id=042394b4-1c0e-42d9-a9ba-bca9ea1394b1">Nada</A>] [<A href="Categories.aspx?id=8d72025e-a23a-4c81-8174-d3fc4e1eb469">Yarp</A>] ' $aTemp = StringRegExp($sString, 'href="([^>]*?)">Yarp', 1) If IsArray($aTemp) Then MsgBox(0, "", $aTemp[0])
    1 point
  6. DXRW4E

    RegEx lazy quantifier

    wat works OK, is the pattern who is not OK, not the RegExp #include <Array.au3> Local $sString = '<TD colSpan=4><SPAN style="FONT-VARIANT: small-caps">Sub-Categories: [<A href="Categories.aspx?id=2b249c75-f666-424e-b555-bf9ee8f34152">Nope</A>] ' $sString &= '[<A href="Categories.aspx?id=584378e4-917a-4fce-a6ff-e75fb966e36f">Nay</A>] [<A href="Categories.aspx?id=042394b4-1c0e-42d9-a9ba-bca9ea1394b1">Nada</A>] ' $sString &= '[<A href="Categories.aspx?id=8d72025e-a23a-4c81-8174-d3fc4e1eb469">Yarp</A>] ' Local $aTemp = StringRegExp($sString, 'href="(.*?)">Yarp', 3) _ArrayDisplay($aTemp) so check href=" '<TD colSpan=4><SPAN style="FONT-VARIANT: small-caps">Sub-Categories: [<A href=" and stops until ">Yarp Ciao.
    1 point
  7. DXRW4E

    RegEx lazy quantifier

    #include <Array.au3> Local $sString = '<TD colSpan=4><SPAN style="FONT-VARIANT: small-caps">Sub-Categories: [<A href="Categories.aspx?id=2b249c75-f666-424e-b555-bf9ee8f34152">Nope</A>] ' $sString &= '[<A href="Categories.aspx?id=584378e4-917a-4fce-a6ff-e75fb966e36f">Nay</A>] [<A href="Categories.aspx?id=042394b4-1c0e-42d9-a9ba-bca9ea1394b1">Nada</A>] ' $sString &= '[<A href="Categories.aspx?id=8d72025e-a23a-4c81-8174-d3fc4e1eb469">Yarp</A>] ' Local $aTemp = StringRegExp($sString, 'href="([^"\r\n]*)">Yarp', 3) _ArrayDisplay($aTemp) ;or $aTemp = StringRegExp($sString, 'href="?([^"\r\n\>\<]*)"?>Yarp', 3) _ArrayDisplay($aTemp) Ciao.
    1 point
  8. DW1, This works for me: Local $sString = '<TD colSpan=4><SPAN style="FONT-VARIANT: small-caps">Sub-Categories: [<A href="Categories.aspx?id=2b249c75-f666-424e-b555-bf9ee8f34152">Nope</A>][<A href="Categories.aspx?id=584378e4-917a-4fce-a6ff-e75fb966e36f">Nay</A>] [<A href="Categories.aspx?id=042394b4-1c0e-42d9-a9ba-bca9ea1394b1">Nada</A>] [<A href="Categories.aspx?id=8d72025e-a23a-4c81-8174-d3fc4e1eb469">Yarp</A>]' Local $sExtract = StringRegExpReplace($sString, '.*href="(.*)">Yarp.*', "$1") ConsoleWrite($sExtract & " - Extracted" & @CRLF) ConsoleWrite("Categories.aspx?id=8d72025e-a23a-4c81-8174-d3fc4e1eb469 - Required" & @CRLF) M23
    1 point
  9. czardas - that worked perfectly! Thanks to everyone that looked at this.
    1 point
  10. Just load the Internet Explorer COM component directly in C# and use the methods on it. Add a reference to the project, switch to the COM tab, and add InternetExplorer. I don't remember the name of the classes you'll need but you can use the Class Explorer view to find the classes loaded.
    1 point
  11. how about this: #include <GUIConstantsEx.au3> #include <GuiEdit.au3> Example() Func Example() Local $file, $btn, $msg, $focus="", $last = "" $g = GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $i1 = GUICtrlCreateInput("", 10, 5, 300, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $i2 = GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState() $s1 = "Edit1" $s2 = "Edit2" $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() $focus = String(ControlGetFocus($g)) Switch $focus Case $s1 If $focus <> $last Then $last = $focus ControlFocus($g, "", $i1) ConsoleWrite( GUICtrlRead($i1) & @CRLF) _GUICtrlEdit_SetSel($i1, 0, StringLen(GUICtrlRead($i1))) EndIf Case $s2 If $focus <> $last Then $last = $focus ControlFocus($g, "", $i2) ConsoleWrite( GUICtrlRead($i2) & @CRLF) _GUICtrlEdit_SetSel($i2, 0, StringLen(GUICtrlRead($i2))) EndIf EndSwitch Select Case $msg = $btn ConsoleWrite( GUICtrlRead($i2) & @CRLF) ControlFocus($g, "", $i2) _GUICtrlEdit_SetSel($i2, 0, StringLen(GUICtrlRead($i2))) EndSelect WEnd EndFunc ;==>Example Simplified: #include <GUIConstantsEx.au3> #include <GuiEdit.au3> Example() Func Example() Local $file, $btn, $msg, $focus="", $last = "" $g = GUICreate(" My GUI input acceptfile", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018); WS_EX_ACCEPTFILES $i1 = GUICtrlCreateInput("", 10, 5, 300, 20) GUICtrlSetState(-1, $GUI_DROPACCEPTED) $i2 = GUICtrlCreateInput("", 10, 35, 300, 20) ; will not accept drag&drop files $btn = GUICtrlCreateButton("Ok", 40, 75, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() $focus = String(ControlGetFocus($g)) If StringInStr($focus,"Edit") And $focus <> $last Then $last = $focus $h = ControlGetHandle($g, "",$focus) _GUICtrlEdit_SetSel($h, 0, StringLen(ControlGetText($g,"",$h))) EndIf WEnd EndFunc ;==>Example
    1 point
  12. Equality of strings will check for the pointers being equal. What you actually want with C strings (character arrays) when checking for null or empty is this. if (!param || !*param) This will check to see if the pointer is null, and if it isn't, checks to see if the first character pointed to is null. If it's supposed to be a path, you should probably validate it using this http://msdn.microsoft.com/en-us/library/windows/desktop/bb773584%28v=vs.85%29.aspx
    1 point
  13. Just keep it simple: (AutoIt 3.3.10.0+) $sky = InputBox("Sky status", "Play around with values like blue, falling, green.", "falling") MsgBox(0, "Test 1", "Sky is " & ($sky = "falling" ? "" : "not ") & "falling") MsgBox(0, "Test 2", "Sky is " & (($sky = "blue" Or $sky = "falling") ? "" : "not ") & "blue or falling") MsgBox(0, "Test 3", "Sky is " & (($sky <> "blue" And $sky <> "falling") ? "not " : "") & "blue or falling")
    1 point
×
×
  • Create New...