Leaderboard
Popular Content
Showing content with the highest reputation on 03/15/2013 in all areas
-
aleksa, Found it - but it is probably too complex for your needs, so I suggest using a MenuItem as I suggested above: #include <GUIConstantsEx.au3> #Include <GuiMenu.au3> $hGUI = GUICreate("Test", 500, 500) $mFilemenu = GUICtrlCreateMenu("File") $mExititem = GUICtrlCreateMenuItem("Exit", $mFilemenu) $mSpecialitem = GUICtrlCreateMenu("Special") $mHelpmenu = GUICtrlCreateMenu("?") $mAboutitem = GUICtrlCreateMenuItem("About", $mHelpmenu) GUISetState() $hMenu = _GUICtrlMenu_GetMenu($hGUI) $iCount = _GUICtrlMenu_GetItemCount($hMenu) - 1 GUIRegisterMsg(0x0211,"_WM_ENTERMENULOOP") ; WM_ENTERMENULOOP While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $mExititem Exit Case $mAboutitem MsgBox(0, "Solved", "That was hard work!") EndSwitch WEnd Func _WM_ENTERMENULOOP($hWnd, $iMsg, $wParam, $lParam) For $i = 0 To $iCount Local $tRect = _GUICtrlMenu_GetItemRectEx($hGUI, $hMenu, $i) Local $aMousePos = MouseGetPos() Local $aRes = DllCall("User32.dll", "int", "PtInRect", "ptr", DllStructGetPtr($tRect), "int", $aMousePos[0], "int", $aMousePos[1]) If Not @error And $aRes[0] Then ConsoleWrite("You clicked: " & _GUICtrlMenu_GetItemText($hMenu, $i) & @CRLF) ExitLoop EndIf Next EndFuncNote that clicking a menu is a modal operation - so you will need to click again to reactivate the script after having clicked a menu with no items. M231 point
-
aleksa, You need a MenuItem in the menu: #include <GUIConstantsEx.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 221, 173, 192, 114) $Menu = GUICtrlCreateMenu("Exit") $mExit = GUICtrlCreateMenuItem("Exit", $Menu) ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE, $mExit ; Note multiple controls <<<<<<<<<<<<<<<<<<< Exit EndSwitch WEnd Somewhere I once did manage to get a menu to fire directly - I will see if I can find it. M231 point
-
You are not using a MenuItem so GUIGetMsg doesn't get nothing. Create a menu item and all will work good: #include <GUIConstantsEx.au3> #region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 221, 173, 192, 114) $Menu = GUICtrlCreateMenu("File") $Menu_Exit = GUICtrlCreateMenuItem("Exit", $Menu) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Menu_Exit Exit EndSwitch WEnd Hi!1 point
-
Hum...so why do they translate terms in your language ? Extract from : http://www.youtube.com/t/terms?gl=NL 9. Content van YouTube op de Website 9.1 Met uitzondering van de door u geplaatste Content behoort alle overige Content binnen de Dienst, met inbegrip van doch niet beperkt tot tekst, software, scripts, grafische onderdelen, foto's, geluid, muziek, video's en interactieve opties op de Website, in eigendom of krachtens licentie toe aan YouTube. Alle auteursrechten, merkrechten en overige intellectuele-eigendomsrechten op Content die niet door u is geplaatst behoren toe aan YouTube dan wel aan haar licentiegevers. De in de Content van YouTube voorkomende handels- en/of dienstmerken van derden betreffen de handels- en/of dienstmerken van hun respectievelijke eigenaren. Dergelijke Content mag - zonder de voorafgaande schriftelijke instemming van YouTube dan wel, indien van toepassing, haar licentiegevers - voor welk ander doel dan ook niet worden gedownload, gekopieerd, verveelvoudigd, verspreid, verzonden, uitgezonden, vertoond, verkocht, in licentie worden gegeven of anderszins worden geƫxploiteerd. YouTube behoudt zich alle rechten voor die niet uitdrukkelijk met betrekking tot hun Content zijn verleend.1 point
-
Inserting string into the beginning
Xandy reacted to RoderickRM for a topic
Forgot about _StringReverse. That's working fine I really appreciate your help.1 point -
Help with POSTing image to imgur [winhttp]
jaberwacky reacted to trancexx for a topic
There are no forms there, the output you get from form filling function is correct. What you should do if you want to use _WinHttpSimpleFormFill() is to create form for your self. Like this: #include "WinHTTP.au3" $sFile = @ScriptDir & "\testimage.jpg" $sForm = _ '<form action="http://imgur.com/api/upload.xml" method="post" enctype="multipart/form-data">' & _ ' <input type="file" name="image" />' & _ ' <input name="key">' & _ '</form>' ; Initialize and get session handle $hOpen = _WinHttpOpen() ; Form is string initially $hForm = $sForm ; Fill form on this page $sRead = _WinHttpSimpleFormFill($hForm, $hOpen, Default, "name:image", $sFile, "name:key", "b3625162d3418ac51a9ee805b1840452") ; Close connection handle _WinHttpCloseHandle($hForm) ; Close session handle _WinHttpCloseHandle($hOpen) ; See what's returned If $sRead Then ConsoleWrite($sRead & @CRLF) That script will upload testimage.jpg and will print to console all the info you would need.1 point -
I've posted what I believe is a correct version in the thread mentionned. It needs the beta for Null support BTW.1 point
-
In case anyone else ends up in this thread looking for a method to determine the variable type: the _VarDump method should not be used, use VarGetType() instead. See for a discussion on this topic.1 point
-
Script Only Works the Second Time It's Run
Tripredacus reacted to GIS007 for a topic
What about just using ping? It appears that the connection to the network drive is getting dropped, perhaps that is why the first attempt fails but the second one, which hits the network after the connection has been refreshed, works? So, if I just ping that server won't that refresh the connection? I inserted a "ping( <network IP>)" statement and ran it, & it appears to work, but won't be able to say for sure until the jobs run tonight. Am I on the right track at all?1 point -
Maybe not exactly what you're looking for, but a hell of a lot faster ... function originally posted by trancexx Edit: Looking at the function CryptBinaryToString the output can tweaked to look more like your original one by using different dwFlags (only that there are two spaces right in the middle)... *test*test*, example #4 replaces those manually to mimic your example exactly... and , for me it's even faster than example #3 because parsing that data to the edit controls takes less time. #include <EditConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $sFile, $hFile, $iSize, $sData, $tData, $iRead $sFile = @WindowsDir & '\regedit.exe' $iSize = FileGetSize($sFile) $tData = DllStructCreate('byte[' & $iSize & ']') $hFile = _WinAPI_CreateFile($sFile, 2, 2, 2) _WinAPI_ReadFile($hFile, DllStructGetPtr($tData), $iSize, $iRead) _WinAPI_CloseHandle($hFile) MsgBox(0, '', Hex(DllStructGetData($tData, 1, 1), 2) & Hex(DllStructGetData($tData, 1, 2), 2) & ' (' & Chr(DllStructGetData($tData, 1, 1)) & Chr(DllStructGetData($tData, 1, 2)) & ') - signature for EXE fies.') $sData = '' $timer = TimerInit() For $i = 1 To $iSize $sData &= Hex(DllStructGetData($tData, 1, $i), 2) If Mod($i, 16) = 0 Then $sData &= @CRLF Else $sData &= ' ' EndIf Next $sData = StringTrimRight($sData, 2) GUICreate('1) DllStructGetData()', 422, 526) $Edit = GUICtrlCreateEdit('', 10, 10, 402, 506, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetFont(-1, 8.5, 400, 0, 'Courier') GUICtrlSetData($Edit, $sData) GUISetState() ConsoleWrite("1) " & TimerDiff($timer) & @CRLF) $timer = TimerInit() $sData = _HexEncode(DllStructGetData($tData, 1)) GUICreate('2) CryptBinaryToString - 0x0000000b', 422, 526) $Edit2 = GUICtrlCreateEdit('', 10, 10, 402, 506, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetFont(-1, 8.5, 400, 0, 'Courier') GUICtrlSetData($Edit2, $sData) GUISetState() ConsoleWrite("2) " & TimerDiff($timer) & @CRLF) $timer = TimerInit() $sData = _HexEncode(DllStructGetData($tData, 1), 0x00000004) GUICreate('3) CryptBinaryToString - 0x00000004', 422, 526) $Edit3 = GUICtrlCreateEdit('', 10, 10, 402, 506, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetFont(-1, 8.5, 400, 0, 'Courier') GUICtrlSetData($Edit3, $sData) GUISetState() ConsoleWrite("3) " & TimerDiff($timer) & @CRLF) $timer = TimerInit() $sData = _HexEncode(DllStructGetData($tData, 1), 0x00000004) GUICreate('4) CryptBinaryToString - 0x00000004 + StringReplace()', 422, 526) $Edit4 = GUICtrlCreateEdit('', 10, 10, 402, 506, BitOR($ES_READONLY, $WS_VSCROLL, $WS_HSCROLL)) GUICtrlSetFont(-1, 8.5, 400, 0, 'Courier') GUICtrlSetData($Edit4, StringReplace($sData, " ", " ", 0, 2)) GUISetState() ConsoleWrite("4) " & TimerDiff($timer) & @CRLF) Do Until GUIGetMsg() = -3 Func _HexEncode($bInput, $iFlags = 0x0000000b) ; CryptBinaryToString function (Windows) ; http://msdn.microsoft.com/en-us/library/windows/desktop/aa379887%28v=vs.85%29.aspx Local $tInput = DllStructCreate("byte[" & BinaryLen($bInput) & "]") DllStructSetData($tInput, 1, $bInput) Local $a_iCall = DllCall("crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($tInput), _ "dword", DllStructGetSize($tInput), _ "dword", $iFlags, _ "ptr", 0, _ "dword*", 0) If @error Or Not $a_iCall[0] Then Return SetError(1, 0, "") EndIf Local $iSize = $a_iCall[5] Local $tOut = DllStructCreate("char[" & $iSize & "]") $a_iCall = DllCall("crypt32.dll", "int", "CryptBinaryToString", _ "ptr", DllStructGetPtr($tInput), _ "dword", DllStructGetSize($tInput), _ "dword", $iFlags, _ "ptr", DllStructGetPtr($tOut), _ "dword*", $iSize) If @error Or Not $a_iCall[0] Then Return SetError(2, 0, "") EndIf Return SetError(0, 0, DllStructGetData($tOut, 1)) EndFunc ;==>_HexEncode1 point
-
Now finally ... The full Decode with step-wise explanation. Check the code. #region -Pattern Decode ;([^#?]+) (capturing group) consisting of "non-(question-mark and hash)" characters (greedy) | Capturing Match : http://www.example.com/path/index.php ;(.*) (capturing group)Logic: We know that this is either a Hash or a Question-mark, so lets match everything till the end. We know that "." will not match any line-feed character | Capturing Match : ?toto#fragment #endregion #include <Array.au3> $a = StringRegExp("http://www.example.com/path/index.php?toto#fragment", "/([^/]*$)[#?]", 1) ;This won't work... _ArrayDisplay( $a ) #region -Full Decode of Engine- ;======= First Attempt =========== ; Search for "/" ;Fail at 1 - "h", at 2 - "t", at 3 - "t", at 4 - "p", goes till 6 ;======= Sixth Attempt =========== ;Match found "/" at 6 ; Search for "[^/]*" greedily i.e. match everything which satisfies the pattern ;Fail 7 - "/". Match Fails here. ;........Again Start ;======= Seventh Attempt =========== ; Search for "/" ;Match Found at 7 - "/" ; Search for "[^/]*" greedily i.e. match everything which satisfies the pattern ;Match found at 8,9,10,11.....22.Char 22 is "m" hence this pattern has consumed "www.example.com". After "m", the 23rd character is a slash "/" which doesn't satisfy the pattern. Hence the engine moves to the next pattern sequence. ; Search for $ (ie End Of File). This is an assertion(a different case). This doesn't match/consume characters nor do it capture them. ;Fail at 23 which is "/" and not EOF. Match Fails here. ;........Again Start ;======= Eighth Attempt =========== ;same goes as seventh attempt. This is just from 23rd char "/" to 28th char "/" which is again another slash but not a EOF character. ;........Again Start ;======= Nineth Attempt =========== ; Search for "/" ;Match Found at 28 - "/" ; Search for "[^/]*" greedily i.e. match everything which satisfies the pattern ;Match found at 29,30,31.....51.Char 51 is "t" hence this pattern has consumed "index.php?toto#fragment". After "t", the EOF is reached. The Engine stops here. ; Search for $ (ie End Of File). This is an assertion(a different case). This doesn't match/consume characters nor do it capture them. ;After 51st char the EOF is reached hence the assertion is fulfilled ; Search for "[#?]" ie either "#" or "?" ;Now every character is consumed, nothing left to start again or back-trace. ;========== All the Attempts have been made. A match satisfing the complete pattern sequence was not found. The Engine quits here with an error ========================= #endregion -Full Decode of Engine- ;Now try with this pattern and you would get everything if you understood. ;......... "/([^/]*$)" ............Hope now you understand. Thumbs up if helped. Regards1 point
-
@FireFox, Read the PCRE documentation pointed to in my .sig1 point
-
Is AutoIT perfect?
BinaryBrother reacted to czardas for a topic
At risk to myself, I feel the need to say something more on this. Things started to get messy when Valik departed. Despite his swearing, which didn't always go down too well with everyone, he was the only person around here who knew how to run a tight ship. It took me a while, but I eventually started to like the guy. I'm guilty of having said nothing about this until now. Why - because I did not want to upset any of the other devs. Now we seem to be floating aimlessly on an ocean with no rudder or stars to guide us. I also love AutoIt and I would like to see this ship back on course and moving again. There's been so much hard work put into this language and community. Please somebody do something.1 point -
Is AutoIT perfect?
BinaryBrother reacted to JohnOne for a topic
We get it! you're using your reverse psychology powers to kickstart the bosses to release a new version of autoit. Who's a clever boy.1 point -
the active window must be one of your application So, just create a 1x1-GUI and delete it again Func _TrackPopupMenu($hMenu, $iFlags, $iX, $iY, $hWnd) Local $GUI = GUICreate("",1,1,$iX,$iY,$WS_POPUP,$WS_EX_TOOLWINDOW) GUISetState() Local $ret = DllCall("User32.dll", "int", "TrackPopupMenuEx", _ "hwnd", $hMenu, _ "int", $iFlags, _ "int", $iX, _ "int", $iY, _ "hwnd", $hWnd, _ "ptr", 0) GUIDelete($GUI) Return $ret[0] EndFunc1 point