Jump to content

dabus

Active Members
  • Posts

    398
  • Joined

  • Last visited

Everything posted by dabus

  1. Use Eval and strip the $ from the key of your ini-section. Eval=Return the value of the variable defined by an string. GUICtrlSetTip(Eval($arrTemp[$i][0]),$arrTemp[$i][1]) And your script does not work since $Button1 is a variable and not a fixed string. Since you read out ini-sections as a sting, autoit cannot handle this. With eval, you translate that sting into the current value of the variable, which is the ControlID that is returned by GuiCtrlCreateXYZ here.
  2. Hi folks. Haven't been around asking much in the past time since there were no issues or at least none that couldn't be fixed with the help of previous topics, but I didn't find any for this one: Test 1: If I create a listview and use _GUICtrlListView_BeginUpdate, everything is ok. Test 2: If I use a tab, the screen still flickers. Test 3: If I prevent to repaint, the flickering goes away but progress gets lost I mean, sure it does. I just wanted to show that I know that one, but that's not working 100% . I just moved the progress-bar into a child-window in my real project that overlays the window, so there is a workaround and no need to rush anything. But I still thought I post it as something to chew on. (I also tested the beta) So why does the tab cause this problem? And is there a way to keep the window from flickering without moving into a child-window? #include <GuiListView.au3> Test(1) Test(2) Test(3) Func Test($Run) $g_UI=GUICreate('Sample:'&$Run, 200, 200) $g_UI_Interact1=GUICtrlCreateProgress(0, 0, 200, 20) If $Run <> 1 Then GUICtrlCreateTab(10, 10, 180, 180) $tab0 = GUICtrlCreateTabItem("tab0") EndIf $g_UI_Interact2=GUICtrlCreateListView('1|2|3|4', 10, 20, 180, 180) $g_UI_Handle=GUICtrlGetHandle($g_UI_Interact2) If $Run <> 1 Then GUICtrlCreateTabItem("") GUISetState() Sleep(2000) _GUICtrlListView_BeginUpdate($g_UI_Handle) If $Run=3 Then GUISetState(@SW_LOCK) For $s=1 to 3000 GUICtrlSetData($g_UI_Interact1, $s*100/3000); set the progress GUICtrlCreateListViewItem('1|2|3|4', $g_UI_Interact2) Next If $Run=3 Then GUISetState(@SW_UnLOCK) _GUICtrlListView_EndUpdate($g_UI_Handle) Sleep(2000) GUIDelete($g_UI) EndFunc
  3. Hey, the guru is here. Ok, just used the option on $hRequest and it worked. Damn.
  4. Uh, yes, it's not a support forum. But I'll post my question here hoping someone can give me a helping hand. The tcp-solution gives me more info then the one using winhttp. What parameters should I set to get these? It seems im blindfolded. Edit: Uh, the 302 output is a redirect, so I need to enable that... Maybe you can tell me how I should adjust the call. So, here is the code: ; ========================================== ; TCP-solution (done by MrCreatoR) ; ========================================== Global $g_HTTPUserAgent = 'AutoIt3/'&@AutoItVersion, $g_Limit_TimeOut = 5000 Global $g_HTTP_TCP_Def_Port = 80, $g_HTTP_TCP_Port = $g_HTTP_TCP_Def_Port, $g_LAST_SOCKET = -1 $Site = 'kerzenburg.baldurs-gate.eu' $Page = 'downloads.php?do=downloadlatest&id=3' MsgBox ( 0, 'Header', __HTTPGetResponse($Site, '/'&$Page, "HEAD")) Func __HTTPClose($Socket = -1) TCPCloseSocket($Socket) TCPShutdown() Return 1 EndFunc ;==>__HTTPClose Func __HTTPConnect($Host) TCPStartup() Local $Name_To_IP = TCPNameToIP($Host) Local $Socket = TCPConnect($Name_To_IP, $g_HTTP_TCP_Port) If $Socket = -1 Then TCPCloseSocket($Socket) Return SetError(1, 0, "") EndIf $g_LAST_SOCKET = $Socket Return $Socket EndFunc ;==>__HTTPConnect Func __HTTPGet($Host, $Page, $Socket, $sRequest = "GET", $sReferrer = "") Local $Command = $sRequest & " " & $Page & " HTTP/1.1" & @CRLF $Command &= "Host: " & $Host & @CRLF $Command &= "User-Agent: " & $g_HTTPUserAgent & @CRLF $Command &= "Referer: " & $sReferrer & @CRLF $Command &= "Connection: close" & @CRLF & @CRLF Local $BytesSent = TCPSend($Socket, $Command) If $BytesSent = 0 Then Return SetError(1, @error, 0) Return $BytesSent EndFunc ;==>__HTTPGet Func __HTTPGetResponse($Host, $Page, $sRequest = "GET", $sReferrer = "") Local $Socket = __HTTPConnect($Host) If @error Then Return SetError(1, 0, "") __HTTPGet($Host, $Page, $Socket, $sRequest, $sReferrer) If @error Then __HTTPClose($Socket) Return SetError(2, 0, "") EndIf Local $Recv = "", $CurrentRecv Local $iTimer = TimerInit() While 1 $CurrentRecv = TCPRecv($Socket, 100) If @error <> 0 Then ExitLoop If $CurrentRecv <> "" Then $Recv &= $CurrentRecv If TimerDiff($iTimer) >= $g_Limit_TimeOut Then $g_Limit_TimeOutOver = True ExitLoop EndIf WEnd __HTTPClose($Socket) Return $Recv EndFunc ;==>__HTTPGetResponse ; ========================================== ; WinHTTP-solution (done by trancexx) ; ========================================== #include 'winhttp.au3' $Site = 'kerzenburg.baldurs-gate.eu' $Page = 'downloads.php?do=downloadlatest&id=3' $hOpen = _WinHttpOpen() _WinHttpSetOption($hOpen, $WINHTTP_OPTION_ENABLE_FEATURE, $WINHTTP_OPTION_REDIRECT_POLICY_ALWAYS) $hConnect = _WinHttpConnect($hOpen, $Site) $hRequest = _WinHttpOpenRequest($hConnect, "GET", $Page) _WinHttpSendRequest($hRequest) _WinHttpReceiveResponse($hRequest) If _WinHttpQueryDataAvailable($hRequest) Then MsgBox(0, 'Header', _WinHttpQueryHeaders($hRequest)) _WinHttpCloseHandle($hRequest) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hOpen)
  5. I first have to say that I really like the udf and use it in one project. It uses different colored boxes for different types of information. So I just thought I'd add a few own images. My mac-like checkboxes are these: At first, it was successful. I used SetItemState($hWnd, $hItem, $nState) with $nState = image-number. But after adding 4 colored groups of 3 new images, the next one just starts from the beginning. So my pink and ongoing images are not used. Example: If you edit the udf, line 99-101, it should show the pink images... but it does not. Replace 14 with 11 and you see yellow boxes. (I know that this is not good, just for a quick "proof".) SetItemState($hWnd, $hItem, $nState+14) CheckChildItems($hWnd, $hItem, $nState+14) CheckParents($hWnd, $hItem, $nState+14) I tried change the grow-parameter, but it had no visible effect. So, is there a limit, or am I wrong? Is it my fault? Do I need to tweak something? I really would like to add these. Edit: Reduced them, but I'm curious what would be the cause. Edit: Ok, a friendly guy found it. So I really hit a limit here.
  6. Ah, ok, I get it. You "shorten" the functions to setting variables and use them to call the real (bigger) ones. Although this "stretches" the code a little bit compared to a simple GuiGetMsg-Loop. Hmm, I think I'll give it a try, if it's not working, I'll switch back to loops again. Thanks for your support. Edit: After some thinking, I edited your example to ; mainloop While 1 Sleep(1000) If $ExecuteNow <> '' Then Call($ExecuteNow) WEnd ; trigger Func Stop() If $ExecuteNow = '' Then $ExecuteNow = 'RealStop' EndFunc ;==>Stop ; real called function Func RealStop() $ExecuteNow='' While $Keep = 0 Sleep(10) WEnd EndFunc ;==>RealStop I think that's a good solution that I will use for my script.
  7. Could you give an example? Here's what I mean. This does not work, since the continue-button does not responde: AutoItSetOption('GUIOnEventMode', 1) Global $Keep=1 GUICreate('sample', 200, 100) $Open=GUICtrlCreateButton('Stop', 10, 10, 100, 20) GUICtrlSetOnEvent(-1, 'Stop') $Close=GUICtrlCreateButton('Continue', 10, 50, 100, 20) GUICtrlSetOnEvent(-1, 'Continue') GUISetState() while 1 Sleep(1000) ConsoleWrite($Keep & @CRLF) WEnd Func Stop() While $Keep Sleep(10) WEnd EndFunc Func Continue() $Keep = 0 EndFuncoÝ÷ Ù8b±Ú³ +»­¶¶­ßÛ,Â+)àmëpyéíè.Ê'qêm³ù¨uëºÚ"µÍ]]Ò]Ù]Ü[Û ÌÎNÑÕRSÛ][[ÙIÌÎNËJBÛØ[ ÌÍÒÙYLBÕRPÜX]J ÌÎNÜØ[IÌÎNËL BÌÍÓÜ[QÕRPÝÜX]P]Û ÌÎNÔÝÜ ÌÎNËLLL BÕRPÝÙ]Û][ LK ÌÎNÔÝÜ ÌÎNÊBÌÍÐÛÜÙOQÕRPÝÜX]P]Û ÌÎNÐÛÛ[YIÌÎNËL LL BÕRPÝÙ]Û][ LK ÌÎNÐÛÛ[YIÌÎNÊBÕRTÙ]Ý]J BÚ[HBTÛY L BPÛÛÛÛUÜ]J ÌÍÒÙY [ÈÔBÑ[B[ÈÝÜ BP]]Ò]Ù]Ü[Û ÌÎNÑÕRSÛ][[ÙIÌÎNË BUÚ[H ÌÍÒÙYBIÌÍÓÙÏQÕRQÙ]ÙÊ BBRY ÌÍÓÙÈH ÌÍÐÛÜÙH[ ÌÍÒÙYHBTÛY L BUÑ[B[[ÂB[ÈÛÛ[YJ BIÌÍÒÙYH[[
  8. Hi there, I must admit that I did not use OnEvent mode that much. I obviously use it in a script that does something to catch events during that time. Since I thought I might switch everything to OnEvent, I was in the process of changing the whole script, adding new tabs, changing here and there and stumbled about the fact that new events are "ignored" until a function that was triggered by another event is done. Because I need to keep the OnEvent on the "doing something"-part, I wonder if it would be possible to reset the OnEvent-Mode so that it is free/available for new events... I tried to switch it off and on again, but that did not work. Best regards dabus
  9. smashly: That's exactly what I was searching for. rasim: If you look at my example, you can see that I want to display a hint that is diffrent from the text. So I put these stuff into an array. Since the ControlID is a number, the corresponding values are found directly without a search. I currently store 12 values in this array. I don't want them to be displayed in the text of the TreeViewItem, but I need them for popups and other purposes later. So basicly, I just use the ID to find the items text, setup, type, ... to this item. KaFu: This does not seem to work on TreeViewItems. Thank you all for your time you spend to help me.
  10. I don't create them with _GUICtrlTreeView_* but with internal functions. ; creation $trees[$s][0] = GUICtrlCreateTreeViewItem($Setup[$s][1], $streeview) ; putting stuff into an array $MsgTrans[$trees[$s][0]][0] = $Setup[$s][0]; current setup $MsgTrans[$trees[$s][0]][1] = $TAG; tag $MsgTrans[$trees[$s][0]][2] = '-'; tag as no component ;... and so on ; later I get a click and I know what's going on $sMsg=GuiReadMsg() ConsoleWrite('Setup ' & $MsgTrans[$sMsg][0] & ' was seleced' & @CRLF) So there is a direct connection between the ControlID and the related informations in the $MsgTrans array. If I hover over an item, I currently only know a way to get the handle. That's why I store HWNDs in MsgTrans and loop through to find the information. If it would be possible to convert them, the app would run faster since no search was needed. Well in this case, getting the ControlID somehow would be enough.
  11. Yeah, this sounds a little strange. The reason is that I am creating a bigger script. The main area consists of a treeview. Some items have additional informations. These are stored in an array that is build at the startup of the application. It looks like this: ID Text Info HWND 1...A................0x1234 2...B................0x1235 3...C...... FOO...0x1236 So when I am above the the first two items, nothing happens. When I am above the third treeviewitem, it is selected and a popup shows FOO. I currently do this by an idea that Siao came up with: Func _TreeItemFromPoint($a) Local $tMPos = _WinAPI_GetMousePos(True, $a) Return _GUICtrlTreeView_HitTestItem($a, DllStructGetData($tMPos, 1), DllStructGetData($tMPos, 2)) EndFunc ;==>_TreeItemFromPoint This gives me the handle. To get the info, I loop through the stored HWNDs in the array. If Info is not "" then the popup appears. This works,but I would like to know if there is a better way to do this. (I'm sure there is ) I only want to switch the selection when a new info is shown to have a hint/connection that this info belongs to the selected/focused item. So Focusing and doing GUICtrlRead on the treeview is out. Any thoughts? Thx in advance.
  12. I just managed to do it by myself. All I needed to do was to use another global var and I'm set. .. If $WinResized Then $WinResized=False $Pos = WinGetPos($sGui) If $Pos[2]< 750 Then _GuiMove($sGui, "", $Pos[0], $Pos[1], 750, $Pos[3]) EndIf Func _GuiMove($a, $b, $c, $d, $e, $f) WinMove($a, $b, $c, $d, $e, $f) $WinResized = True EndFunc Func _WM_ON_SIZE() ConsoleWrite('-'&$WinResized&@CRLF) $WinResized=True Return $GUI_RUNDEFMSG EndFunc -- Edit -- @Zedna: Thank you. That's much better.
  13. Hi there, I got a similar problem: In the main part of the script, I place some pics on the GUI to have a light theme. This works as expected. After some thoughts, I got rid of the fixed windowsize and use GuiCtrlSetResize to move the pics as desired. Cool and slick. I also wanted to avoid my gui to be to small or too big. So I used the great example Siao gave and added some WinMove-functions. This works for itself, but the movement seems not to be recogniced by GuiCtrlSetResize. Is it possible to give GuiCtrlSetResize a signal to start updating the theme? Or will I have to have a list of pics and move them around "manually"? Any ideas? .. GuiCreate('Bla', 200, 200) GuiCtrlCreatePic('SomePic.bmp', 180, 0, 20, 20, $WS_DISABLED); upper right corner GUICtrlSetResizing(-1, 4+32+256+512) .. .. Func _WM_ON_SIZE() $Pos = WinGetPos($sGui) If $Pos[2]< 750 Then WinMove($sGui, "", $Pos[0], $Pos[1], 750, $Pos[3]) If $ExtGui And $Pos[3]< 450 Then WinMove($sGui, "", $Pos[0], $Pos[1], $Pos[2], 450) If Not $ExtGui And $Pos[3]< 175 Then WinMove($sGui, "", $Pos[0], $Pos[1], $Pos[2], 175) If $Pos[2]> 1600 Then WinMove($sGui, "", $Pos[0], $Pos[1], 1600, $Pos[3]) If $Pos[3]> 1200 Then WinMove($sGui, "", $Pos[0], $Pos[1], $Pos[2], 1200) Return $GUI_RUNDEFMSG EndFunc
  14. Bump. Nobody with simillar problems?!?
  15. Hi there, I want to have some sort of tail in a GUI. To accomplish this, I have created a little script. Here's a quick and dirty conversion of it. Note that you will have to press exit to close the app. SpecialEvents don't seem to work, but I don't care. As mentioned, this is a small part of another project. You may also replace the /c with a /k switch to work with cmd via the input-box. ; *** Start added by AutoIt3Wrapper *** #include <Constants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> ; *** End added by AutoIt3Wrapper *** Global $tLog=@ScriptDir&'\log.txt', $POpen=1, $tLine='', $tOutput='', $Stream Global $pGui, $pButton1, $pButton2, $pButton3, $pEdit1, $pProgress1, $pInput1, $pLabel1, $pLabel2 _Process_Gui() _Process_Run(@ComSpec & ' /c dir '&@SystemDir, @ScriptDir) While $POpen Sleep(100) WEnd ; --------------------------------------------------------------------------------------------- ; Create a small gui that will be used to monitor the progess ; --------------------------------------------------------------------------------------------- Func _Process_Gui($a=0) AutoItSetOption('GUIOnEventMode', 1) $pGui = GUICreate('Test', 550, 410, 100) GUISetFont(8, 400, 0, "MS Sans Serif") GUICtrlSetOnEvent ($GUI_EVENT_CLOSE, '_Process_OnEvent') GUICtrlSetOnEvent ($GUI_EVENT_MINIMIZE, '_Process_OnEvent') GUICtrlSetOnEvent ($GUI_EVENT_RESTORE, '_Process_OnEvent') $pLabel1 = GUICtrlCreateLabel('Watch this', 35, 35, 380, 20) $pProgress1 = GUICtrlCreateProgress(35, 55, 480, 20) $pLabel2 = GUICtrlCreateLabel('', 35, 85, 380, 20) If $a=0 Then $pEdit1 = GUICtrlCreateEdit('', 35, 115, 480, 210, $ES_READONLY+$WS_HSCROLL) Else $pEdit1 = GUICtrlCreateEdit('', 35, 115, 480, 210, $ES_READONLY+$WS_HSCROLL+$WS_VSCROLL+$ES_AUTOVSCROLL) EndIf $pInput1 = GUICtrlCreateInput('', 35, 340, 154, 20) $pButton1 = GUICtrlCreateButton('Write STDIn', 198, 340, 154, 20) GUICtrlSetOnEvent ($pButton1, '_Process_OnEvent') $pButton2 = GUICtrlCreateButton('Log', 361, 340, 154, 20) GUICtrlSetOnEvent ($pButton2, '_Process_OnEvent') $pButton3 = GUICtrlCreateButton('Exit', 35, 370, 480, 20) GUICtrlSetOnEvent ($pButton3, '_Process_OnEvent') GUISetState(@SW_SHOW) EndFunc ; --------------------------------------------------------------------------------------------- ; On-Event functions for the _Process_Gui ; --------------------------------------------------------------------------------------------- Func _Process_OnEvent() Switch @GUI_CtrlId Case $GUI_EVENT_MINIMIZE GUISetState(@SW_MINIMIZE, $pGui) Case $GUI_EVENT_RESTORE GUISetState(@SW_RESTORE, $pGui) Case $GUI_EVENT_CLOSE Exit Case $pButton1 StdinWrite($Stream, GUICtrlRead($pInput1)&@CRLF) If @error = -1 Then $tOutput = $tOutput & @CRLF & 'That did not work.' $tOutput = StringRight($tOutput, StringLen($tOutput) - StringInStr($tOutput, @LF, 0, -14)) ControlSetText($pGui, '', $pEdit1, $tOutput) EndIf Case $pButton2; open log ShellExecute($tLog) Case $pButton3 $POpen=0 GUICtrlSetData($pLabel1, 'Please wait for the process to exit...'); set hint GUICtrlSetColor($pLabel1, '0xff0000'); paint the text red GUICtrlSetState($pInput1, $GUI_DISABLE) GUICtrlSetState($pButton1, $GUI_DISABLE) GUICtrlSetState($pButton2, $GUI_DISABLE) GUICtrlSetState($pButton3, $GUI_DISABLE) AutoItSetOption('GUIOnEventMode', 0) EndSwitch EndFunc ; --------------------------------------------------------------------------------------------- ; The Adlib_Function that is called by _Process_Run to write monitored output to log and update edit-control ; --------------------------------------------------------------------------------------------- Func _Process_AL_Run() ;$tLine = _Trans_Dos2Ascii($tLine) FileWrite($tLog, $tLine); write the log $tOutput = $tOutput & $tLine; append the new text $tOutput = StringRight($tOutput, StringLen($tOutput) - StringInStr($tOutput, @LF, 0, -14)); just get the last 14 lines ControlSetText($pGui, '', $pEdit1, $tOutput); set the text $tLine=''; reset the new input EndFunc ;==>_Process_AL_Run ; --------------------------------------------------------------------------------------------- ; Run a process and moitor it by using AdLib (here _Process_AL_Run ) ; --------------------------------------------------------------------------------------------- Func _Process_Run($a, $B); $a=program, $b=directory ;_PrintDebug('+' & @ScriptLineNumber & ' Calling _Process_Run') $stream = Run($a, $b, @SW_HIDE, $STDIN_CHILD + $STDERR_CHILD + $STDOUT_CHILD); run hidden with stdout/err-read If Not @error Then AdlibEnable ("_Process_AL_Run", 750) While 1 $line = StdoutRead($Stream); capture while getting stream If @error Then ExitLoop If $line Then $tLine = $tLine & $Line; capture while getting stream $line = StderrRead($Stream) If @error Then ExitLoop If $line Then $tLine = $tLine & $Line; capture while getting stream Sleep(10) WEnd AdlibDisable() _Process_AL_Run(); write the last additions Else $tOutput = $tOutput & @CRLF & 'Could not run command.' & @CRLF $tOutput = StringRight($tOutput, StringLen($tOutput) - StringInStr($tOutput, @LF, 0, -14)) ControlSetText($pGui, '', $pEdit1, $tOutput) EndIf EndFunc Exit As you can see, I added a sleep to avoid a big cpu-usage. The other thing I use is a temporary variable to store the output and update the edit-control later (to avoid flickering and high cpu-usage). When using 7zip, I rarely don't get the last output 7zip creates / send to stdout. Seems to be 1 % of my attemps. Do I have another option than reducing the sleep to avoid that? The workaround I tried to use was some sort of tail.udf that read created log-files, but the size via FileGetSize of the log was not updated properly. I posted that here I could watch the update with a regular tail, so the filesize had to increase, but it wouldn't do so instantly, but a few seconds later. The result was that the gui was not updated and it looked like the application hang. The last time I played with tail was with AutoIt 3.2.10 on a XP SP2 installation. Someone told me that the the filegetsize-"call" he saw in an old opensource-code may be a little bit buggy. -- No offense here! I don't even know if AutoIt uses these calls in later versions nor if is really true. -- Do you know if there is another option to get the filesize with a dll-call or something? I'd be happy if you could give me an advice. Best Regards Dabus
  16. OK, here's the sample code. 'TailRW.au3' Dim $tSize=0, $tOutput='', $tFile = @ScriptDir&'\wget.log' $hFile = _APIFileOpen($tFile) While ProcessExists('wget.exe') $nSize = FileGetSize($tFile) ConsoleWrite($nSize&@CR) If $nSize <> $tSize Then If $tSize > $nSize Then $tSize = 0 _APIFileSetPos($hFile, $tSize) $Tmp = _APIFileRead($hFile, $nSize - $tSize) If @error <> 0 Then $tOutput = $tOutput & $Tmp $tOutput = StringRight($tOutput, StringLen($tOutput) - StringInStr($tOutput, @LF, 0, -10)) GUICtrlSetData($Edit1, $tOutput) $tSize = $nSize EndIf EndIf Sleep(1000) WEnd _APIFileClose($hFile) While wget is working and logging, the size of the logfile is checked. Very often, the changes of the filesize are not recognized and it keeps telling the old filesize. About 5-20 (?) seconds the filesize is constant, although I can see that the file is changing if I use a tail executable to monitor it. So there has to be a change, since each letters must eat up one byte. I also tried another diskspace-utiliy named du and parsed the output, put surprise, surprise, it did not work either. So it seems to be a general issue. I use WinXP Pro with the latest updates and AutoIt 3.2.10. The install is a few days old. That's all. I even uninstalled avira to see if the guard-software was blocking the script, but that's not the case. Does anyone have an idea what could cause that problem? It seems kind of fishy. It does work correctly if use stderrread on wget and I might/will use it, but this kind of bugs me. Best regards Dabus
  17. Try tee, that should generate a logfile from the output of a "dos"program...
  18. Well, here is the code I ripped out of MrCreators GUI, so all credit goes to him. I just removed all the gui-stuff and added some feedback. And I accept a " ' " in my filename, since I got some in the files that I need. I hope I did not make a lot of mistakes, I tested it with 260 files and it works just as I needed. So maybe I did just right. It works fine, although it's a little bit "more" code, but I think I got something worth in return. And I can verify it works under wine. Bonus. Global $HTTPUserAgent = "Opera/9.27 (Windows NT 5.1; U; en)" Global $Limit_TimeOut = 10000 Global $HTTP_TCP_Def_Port = 80 Global $HTTP_TCP_Port = $HTTP_TCP_Def_Port Global $LAST_SOCKET = -1 $check=Check_URL_Size_Proc('http://www.autoitscript.com/cgi-bin/getfile.pl?autoit3/autoit-v3-setup.exe') If $check[0]<>0 Then ConsoleWrite('!Error='&$check[0]&@CR) If $check[0]=0 Then ConsoleWrite('Size By='&$check[1]&@CR) ConsoleWrite('Size MB='&$check[2]&@CR) ConsoleWrite('Filename='&$check[3]&@CR) ConsoleWrite('Resonse Time='&$check[4]&@CR) ConsoleWrite('Resume='&$check[5]&@CR) ConsoleWrite('Real URL='&$check[6]&@CR) EndIf Func Check_URL_Size_Proc($Read_URL_Input) Local $RetString[7] Local $Check_Response = Response_Parser($Read_URL_Input) $GET_RESPONSE = $Check_Response[0] Local $Response_Time = $Check_Response[1] Local $sHost = $Check_Response[2] Local $sPage = $Check_Response[3] If $Check_Response[4] Then $RetString[0]=$Check_Response[4] Return $RetString EndIf If StringInStr($GET_RESPONSE, "HTTP/1.1 206 Partial Content") Or _ StringInStr($GET_RESPONSE, "Accept-Ranges:") Then $RetString[5]=1 ; Resume supported Local $FileName = StringRegExpReplace(_HexURLToString($sPage), "^.*/|[\?&;=\^%@#!/;<>].*$", "") If $FileName = "" Then $FileName = "N/A" If StringInStr($GET_RESPONSE, 'filename="') Then $FileName = StringStripWS(_GetMidleString($GET_RESPONSE, 'filename="', '"'), 3) Local $FileSize_Bytes = Number(_GetMidleString($GET_RESPONSE, "Content-Length: ", "(\n|$)")) If $FileSize_Bytes = 0 And StringInStr($GET_RESPONSE, "Location: ") Then $FileSize_Bytes = InetGetSize(StringStripWS(_GetMidleString($GET_RESPONSE, "Location: ", "(\n|$)"), 3)) EndIf Local $FileSize_MBytes = Round($FileSize_Bytes / (1024*1024), 2) $RetString[1]=$FileSize_Bytes $RetString[2]=$FileSize_MBytes $RetString[3]=$FileName $RetString[4]=$Response_Time $RetString[6]=$Check_Response[5]; real url Return $RetString EndFunc ;==>Check_URL_Size_Proc Func Response_Parser($sURL) Local $sURI_Referrer = StringRegExpReplace($sURL, "/[^/]*$", "") Local $sNewLocation = $sURL Local $aHostPage = _GetHostAndPage($sURL) Local $iTimer = TimerInit() Local $iLocationCount = 0 Local $iCheckErr = 0 Local $Response_Time = 0 Local $Check_Response = "" If StringLeft($sURL, 3) = "ftp" Then Local $FileSize_Bytes = InetGetSize($sURL) If $FileSize_Bytes > 0 Then $Error = 0 $Check_Response &= @CRLF & "Content-Length: " & $FileSize_Bytes Else $Error = 1 EndIf Local $aRet[6] = [$Check_Response, TimerDiff($iTimer), $aHostPage[0], $aHostPage[1], $Error, $sURL] Return $aRet EndIf $Check_Response = _HTTPGetResponse($aHostPage[0], $aHostPage[1], "HEAD", $sURI_Referrer) $iCheckErr = @error If StringRegExp($Check_Response, "(?i)Content-Type:(.*?)html") Then $Check_Response = _HTTPGetResponse($aHostPage[0], $aHostPage[1], "GET", $sURI_Referrer) $iCheckErr = @error EndIf If StringInStr($Check_Response, @CRLF & @CRLF) Then Local $sMetaRedirect_URL = "" If StringRegExp($Check_Response, '(?i)(?s).*<meta.*="Refresh" content="\d+; URL=.*"') Then $sMetaRedirect_URL = StringRegExpReplace($Check_Response, _ '(?i)(?s).*<meta.*?="Refresh" content="\d+; URL=(.*)".*', '\1') If $sMetaRedirect_URL <> "" And $sMetaRedirect_URL <> $Check_Response Then $aHostPage = _GetHostAndPage($sMetaRedirect_URL) $Check_Response = _HTTPGetResponse($aHostPage[0], $aHostPage[1], "HEAD", $sURI_Referrer) EndIf EndIf $Check_Response = StringRegExpReplace($Check_Response, "(?i)(?s)" & @CRLF & @CRLF & ".*$", "") EndIf For $i = 1 To 2 If StringInStr($Check_Response, "Location:") Then Local $sNewLocation = StringStripWS(_GetMidleString($Check_Response, "Location: ", "(\n|$)"), 3) If $sNewLocation <> "" Then $sNewLocation = StringReplace($sNewLocation, " ", "%20") If StringLeft($sNewLocation, 1) = "/" Then $sNewLocation = $aHostPage[0] & $sNewLocation $aHostPage = _GetHostAndPage($sNewLocation) If StringRegExp($aHostPage[0], ":\d+$") Then $HTTP_TCP_Port = Number(StringRegExpReplace($aHostPage[0], ".*?:", "")) $aHostPage[0] = StringLeft($aHostPage[0], StringInStr($aHostPage[0], ":")-1) EndIf $Check_Response_Tmp = _HTTPGetResponse($aHostPage[0], $aHostPage[1], "HEAD", $sURI_Referrer) $iCheckErr = @error If StringLeft($Check_Response_Tmp, 6) <> "<html>" And Not $iCheckErr Then $Check_Response = $Check_Response_Tmp EndIf EndIf Next $HTTP_TCP_Port = $HTTP_TCP_Def_Port $Response_Time = TimerDiff($iTimer) If StringInStr($Check_Response, @CRLF & @CRLF) Then _ $Check_Response = StringRegExpReplace($Check_Response, "(?i)(?s)" & @CRLF & @CRLF & ".*", "") If StringRegExp($Check_Response, "(?i)HTTP/[0-9.]+ [0-9]+ (OK|Found)") Then $Error=0 Else If StringInStr($Check_Response, "400 Bad Request") Then $Error='Bad Request' ElseIf StringInStr($Check_Response, "403 Forbidden") Then $Error='Forbidden' ElseIf StringInStr($Check_Response, "404 Not Found") Then $Error='Not Found' ElseIf $iCheckErr Then $Error='No Connection to the Server' Else $Error='Can not find Server' EndIf EndIf $Check_Response = StringStripWS($Check_Response, 3) $aHostPage[0] = StringStripWS($aHostPage[0], 3) $aHostPage[1] = StringStripWS($aHostPage[1], 3) Local $aRet[6] = [$Check_Response, $Response_Time, $aHostPage[0], $aHostPage[1], $Error, $sNewLocation] Return $aRet EndFunc ;==>Response_Parser Func _GetHostAndPage($sURL) Local $aHostPage[2] $aHostPage[0] = StringRegExpReplace($sURL, "\A.*?//", "") $aHostPage[0] = _GetMidleString($aHostPage[0], "\A", "/|.*") $aHostPage[0] = StringRegExpReplace($aHostPage[0], "/+$", "") $aHostPage[1] = _GetMidleString($sURL, $aHostPage[0], "$") If StringLeft($aHostPage[1], 1) <> "/" Then $aHostPage[1] = "/" & $aHostPage[1] $aHostPage[0] = StringStripWS($aHostPage[0], 3) $aHostPage[1] = StringStripWS($aHostPage[1], 3) Return $aHostPage EndFunc ;==>_GetHostAndPage Func _GetMidleString($sString, $sStart, $sEnd, $iCase = -1, $iRetType = 0) Local $iCaseSence = '' If $iCase = -1 Then $iCaseSence = '(?i)' Local $aArray = StringRegExp($sString, '(?s)' & $iCaseSence & $sStart & '(.*?)' & $sEnd, 3) Local $IsArrayCheck = IsArray($aArray) If $IsArrayCheck And $iRetType = 1 Then Return $aArray If $IsArrayCheck Then Return $aArray[0] Return SetError(1, 0, "") EndFunc ;==>_GetMidleString Func _EncodeURL($sURL) Local $BinaryString = StringReplace(StringToBinary($sURL, 4), '0x', '', 1) Local $UniBinLen = StringLen($BinaryString) Local $EncodedString, $UniBinChar For $i = 1 To $UniBinLen Step 2 $UniBinChar = StringMid($BinaryString, $i, 2) If StringRegExp(BinaryToString('0x' & $UniBinChar, 4), '(?i)[a-z0-9]|-|_|\.|^/') Then $EncodedString &= BinaryToString('0x' & $UniBinChar) Else $EncodedString &= '%' & $UniBinChar EndIf Next Return $EncodedString EndFunc ;==>_EncodeURL Func _HexURLToString($URLHex) Local $StrArray = StringSplit($URLHex, "") Local $RetString = "", $iDec Local $Ubound = UBound($StrArray) For $i = 1 To $Ubound-1 If $StrArray[$i] = "%" And $i+2 <= $Ubound-1 Then $i += 2 $iDec = Dec($StrArray[$i-1] & $StrArray[$i]) If Not @error Then $RetString &= Chr($iDec) Else $RetString &= $StrArray[$i-2] EndIf Else $RetString &= $StrArray[$i] EndIf Next Return $RetString EndFunc ;==>_HexURLToString Func _HTTPConnect($Host) TCPStartup() Local $Name_To_IP = TCPNameToIP($Host) Local $Socket = TCPConnect($Name_To_IP, $HTTP_TCP_Port) If $Socket = -1 Then TCPCloseSocket($Socket) Return SetError(1, 0, "") EndIf $LAST_SOCKET = $Socket Return $Socket EndFunc Func _HTTPGetResponse($Host, $Page, $sRequest="GET", $sReferrer="") Local $Socket = _HTTPConnect($Host) If @error Then Return SetError(1, 0, "") _HTTPGet($Host, $Page, $Socket, $sRequest, $sReferrer) If @error Then _HTTPClose($Socket) Return SetError(2, 0, "") EndIf Local $Recv = "", $CurrentRecv Local $iTimer = TimerInit() While 1 $CurrentRecv = TCPRecv($Socket, 100) If @error <> 0 Then ExitLoop If $CurrentRecv <> "" Then $Recv &= $CurrentRecv If TimerDiff($iTimer) >= $Limit_TimeOut Then $Limit_TimeOutOver = True ExitLoop EndIf WEnd _HTTPClose($Socket) Return $Recv EndFunc Func _HTTPGet($Host, $Page, $Socket, $sRequest="GET", $sReferrer="") Local $Command = $sRequest & " " & $Page & " HTTP/1.1" & @CRLF $Command &= "Host: " & $Host & @CRLF $Command &= "User-Agent: " & $HTTPUserAgent & @CRLF $Command &= "Referer: " & $sReferrer & @CRLF $Command &= "Connection: close" & @CRLF & @CRLF Local $BytesSent = TCPSend($Socket, $Command) If $BytesSent = 0 Then Return SetError(1, @error, 0) Return $BytesSent EndFunc Func _HTTPClose($Socket=-1) TCPCloseSocket($Socket) TCPShutdown() Return 1 EndFunc
  19. Maybe it's a little bit late but I had a few days off and just saw this response, so : Thank you all and the solution from weaponx works nicely. You saved me some headaches.
  20. A full exampe: The url is something like this: http://www.shsforums.net/index.php?automod...load&id=141 If you load it, the default filename will be fairydragon_WeiDU.zip Mostly all browsers can get it, but I don't want to start IE, get a popup an copy the filename. Is it possible? IE Management and INetGet don't seem to fit. _INetGetSource is not suitable, since some of the files are big and I don't need the source but the name of it... I searched the forum for an hour, found a nice HTML.udf but I don't know html or php and so the results by testing and failing are ... uuh, bad? I did find out that the other side uses apache by testing another one, but it didn't tell me the name of the file I was going to get. Well, it seems like I'm close, but I don't get it done. Any thoughts?
  21. Here's an example: $sGui = GUICreate('', 100, 100, 0, 0) $sButton1 = GUICtrlCreateButton('DE', 40, 40, 20, 20) GUICtrlSetTip($sButton1, 'Fault') GUISetState(@SW_SHOW, $sGui) _TestGui() GUIDelete($sGui) $sGui = GUICreate('', 100, 100, 0, 0) $sButton1 = GUICtrlCreateButton('DE', 40, 40, 20, 20) GUISetState(@SW_SHOW, $sGui) _TestGui() GUIDelete($sGui) Func _TestGui() $aGui = GUICreate('', 100, 100, 200, 0) $aCombo1 = GUICtrlCreateCombo('', 10, 10, 50, 300) $aButton1 = GUICtrlCreateButton ( 'exit', 10, 50, 50, 20) GUISetState(@SW_SHOW, $aGui) While 1 $aMsg = GUIGetMsg() Switch $aMsg Case $aButton1 GUIDelete($aGui) ExitLoop EndSwitch Sleep(10) WEnd EndFunc In the first run, I can't open the combobox. In the second run, it's possible. The only diff between the runs is the tip in the first one. Can anyone confirm? Is it a bug? I'm running the latest stable release.
  22. C'mon, you haven't even tested this. You need a lot more Ups than PgUps to get to the top. If I use you're example, I'm one line above the bottom. And that's a few lines from where I'd like to be. Btw: GUICtrlSetState(mEdit1, $GUI_FOCUS) is totally useless here since controlsend sends the keystrokes directly to the control.
×
×
  • Create New...