All Activity

This stream auto-updates   

  1. Today
  2. Thanks for the reply but I solved the problem, putting "0" on "_IECreate(0)" alone doesn't work, but I tried to do it this way "_IECreate("",0,0)". it works, Now if it still is good, to anyone I would like to ask another question on this thread, I tried another code: ; Script Start - Add your code below here $var = "jhetro" $var2 = "jhetro" $var3 = "jhetro" if $var == $var2 Or $var3 Then MsgBox($MB_SYSTEMMODAL, "Warning", "INVADING, opening my files are prohibited") endif and it doesn't show any messageBox, why? I tried some other codes andi thisnk it's because of the "Or" statement,:)
  3. Hello guys, i'm the new one. I'm learning to using autoit. I have a question: Is there a way to copy text from a website follow example "ABC001, ABC002... ABCxxx" Like this, i want to copy thueacc2471 and input it to another tab.Is it possible ? Thank in advance.
  4. Read the help file entry for _IECreate. There's a parameter that allows you to control the visibility of the browser window.
  5. Hi I am able to get rid of the Regex complexity and to be easier, how can I use _StringBetween succession or another? thanks. #include <Array.au3> #include <String.au3> $string = _oHTTPGet("") $string = StringRegExpReplace($string, '(?s)[\n\r\t\v]', '') $string = StringStripWS($string, 7) $aData = _StringBetween($string, '<loc>','</loc>') For $j = 0 To UBound($aData) - 1 If IsArray($aData) Then ConsoleWrite("Line : " & @ScriptLineNumber & " : " & $aData[$j] & @CRLF) $string2 = _oHTTPGet($aData[$j]) $string2 = StringRegExpReplace($string2, '(?s)[\n\r\t\v]', '') $string2 = StringStripWS($string2, 7) $aPostData = _StringBetween($string2, '</head>','<footer') For $s = 0 To UBound($aPostData) - 1 If IsArray($aPostData) Then $StringBetw2 = _StringBetween($aPostData[$s], '<div class="entry-content">','<span class="synved-social-container');My question is exactly for this line $StringBetw2 = StringRegExpReplace($StringBetw2, "(?is)(<script[^>]+javascript.*?/script>)", "") $StringBetw2 = StringRegExpReplace($StringBetw2, '(?s)<.*?>', "" & @CRLF) $StringBetw2 = StringRegExpReplace($StringBetw2, '(&nbsp;)+', "") ConsoleWrite("Line : " & @ScriptLineNumber & " : " & $StringBetw2 & @CRLF) Else ConsoleWrite("Line : " & @ScriptLineNumber & " : " & " Problem " & @CRLF) EndIf Next EndIf Next Func _oHTTPGet($aUrL) Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("GET", $aUrL, False) $oHTTP.SetRequestHeader("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0") $oHTTP.Send() If @error Then ConsoleWrite("Line : " & @ScriptLineNumber & " Not Connect " & @CRLF) $oHTTP = 0 Return SetError(1) EndIf If $oHTTP.Status = 200 Then Local $sReceived = $oHTTP.ResponseText $oHTTP = Null Return $sReceived EndIf $oHTTP = Null Return -1 EndFunc
  6. HEY man I hope you wouldn't mind me asking another question, is there any way I can use @SW_HIDE as a parameter in an the script: #include <IE.au3> $oIE = _IECreate(@SW_HIDE) _IENavigate($oIE, "") I tried but it still shows the window, is it possible with autoIT?
  7. It is about 50 years since I last did linear algebra.
  8. @Deye Yes it does have an independent "Include" directory alongside the program. Since it already houses the compiler with the application itself the include directory is automatically chosen by the compiler that is bundled with the application this is why I added a Synchronize option. so if you have a script that uses a custom udf you can just hit synchronize and it will copy that UDF to the local include library. But it if your thinking that it detects the script first then copies only the used includes. Actually it doesn't. It copies the Whole installed include library.
  9. You're welcome...
  10. HEY man I can't edit my reply(can't find the edit button) and I found the IE management thanks
  11. WTH, how come I did not see that one, well is there really a documentation in the help file? can't seem to ind it
  12. @jhave21 if you were in that thread already, you should have noticed two things: The post is 11 years old! The last post very clearly states - the latest and greatest when it comes to documentation is included in the current release of AutoIt. Look in the AutoIt help file under IE Management
  13. Hello all, I'm new here and I just started learning AutoIT a few days ago, And I would like to use IE.au3 and the thing is I downloaded documentation zip file from this thread and Nothing showing up take a look: thanks
  14. @mrPuh welcome to the forum. How about posting your code, rather than expecting us to guess? I have some plink scripts, and have not seen this.
  15. The truly useless key nowadays, is the "Scroll Lock". So I use as a "play a macro ON" key. In this case for speaker volume control. #include <WinAPIvkeysConstants.au3> Global $hDLL = DllOpen("user32.dll") OnAutoItExitRegister("OnAutoItExit") Func OnAutoItExit() DllClose($hDLL) EndFunc main() Func main() Local $iScrollState = BitAND(_WinAPI_Key_GetState($VK_SCROLL, $hDLL), 1) If Not $iScrollState Then Send("{SCROLLLOCK}") $iScrollState = BitAND(_WinAPI_Key_GetState($VK_SCROLL, $hDLL), 1) If Not $iScrollState Then Exit MsgBox(262144+16, StringTrimRight(@ScriptName,4), 'failed to turn on "Scroll Lock"',5) If $iScrollState Then Send("{SCROLLLOCK}") $iScrollState = BitAND(_WinAPI_Key_GetState($VK_SCROLL, $hDLL), 1) If $iScrollState Then Exit MsgBox(262144+16, StringTrimRight(@ScriptName,4), 'failed to turn off "Scroll Lock"',5) ; the above code is to make sure we are affecting the keyboard $iScrollState = BitAND(_WinAPI_Key_GetState($VK_SCROLL, $hDLL), 1) Local $iScrollStateWas = $iScrollState While 1 $iScrollState = BitAND(_WinAPI_Key_GetState($VK_SCROLL, $hDLL), 1) If $iScrollStateWas <> $iScrollState Then $iScrollStateWas = $iScrollState If $iScrollState Then ToolTip("SCROLLLOCK is ON") HotKeySet("{PAUSE}","f_PAUSE") HotKeySet("{UP}","f_UP") HotKeySet("{DOWN}","f_DOWN") HotKeySet("{ESC}","f_ESC") Else HotKeySet("{PAUSE}") HotKeySet("{UP}") HotKeySet("{DOWN}") HotKeySet("{ESC}") ToolTip("") EndIf EndIf Sleep(50) WEnd EndFunc Func f_PAUSE() Send("{VOLUME_MUTE}") ToolTip("VOLUME_MUTE") Send("{SCROLLLOCK OFF}") ; return keyboard use EndFunc ; by {SCROLLLOCK OFF} Func f_UP() Send("{VOLUME_UP}") ToolTip("VOLUME_UP") EndFunc Func f_DOWN() Send("{VOLUME_DOWN}") ToolTip("VOLUME_DOWN") EndFunc Func f_ESC() Exit ; just in case you hide the Tray icon EndFunc Func _WinAPI_Key_GetState($vKey, $vDLL = 'user32.dll') ; read help on _WinAPI_GetAsyncKeyState() and DllOpen() Local $aRet = DllCall($vDLL, 'short', 'GetKeyState', 'int', $vKey) If @error Then Return SetError(@error, @extended, 0) Return $aRet[0] EndFunc ;==>_WinAPI_GetKeyState Func _WinAPI_Key_Pressed($vKey, $vDLL = 'user32.dll') ; read help on _IsPressed(), but use Virtual-Key Codes (WinAPIvkeysConstants.au3) Local $a_R = DllCall($vDLL, "short", "GetAsyncKeyState", "int", $vKey) If @error Then Return SetError(@error, @extended, False) Return BitAND($a_R[0], 0x8000) <> 0 EndFunc ;==>_IsPressed Also here is the version of _IsPressed() I use.
  16. Yesterday
  17. Yes, it was just a proof of concept version. What I would do is to create a bitmap with a rectangle (different color of course) which will be also rotated and check for the color. This will work also for images with transparent parts. Of course your math solution is much cooler! Well done!
  18. Ok.. So the FINAL WORKING code is DONE! You guys ROCK! I've attached the program if anyone wants to try it/see what I was trying to do.. It opens an excel file, reads all the sample ID's and corresponding test codes, and assigns it to a machine if the test code is new, or generates the sampleid/testcode for each device if it's not new or after you select the device that hte test code corresponds to! You guys genuinely rock...! Note: Some functions that are network dependent and how the excel is generated were deleted ExcelLoaderFinished.au3 MC_SampleDueRpt.xls
  19. Sorry I didn't have much time for lengthy explanation. Nice to know you've got it.
  20. Your approach is surprisingly performant, given that it has a for loop that is executed many times. It appears to me that it will fail if, in traversing the image, it simultaneously encounters two black pixels before reaching a corner triangle. I realize that this is unlikely. In order to run your code, I ran it on a 1024x768 version of pergola.jpg; otherwise on my 1920x1024 monitor, the Rotate button was off screen. I have revisited my code, improving the time it takes to do the cropping. While it was recreating the control, it now adds borders to the displayed version, the borders being the colour of the client-area background. What was taking about 130 msec snow takes about 36. Also, there is now no flicker. The script, with the new code, is below: #include <ButtonConstants.au3> #include <GDIPlus.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars',1) GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL") GUIRegisterMsg($WM_PAINT,'WM_PAINT') Global $gX0=10,$gX1=580,$gY0,$gY1,$gForm1,$glblPic,$gCtlWid,$gCtlHt,$imgWid,$imgHt Global $ghCanvas,$ghImage,$ghPen,$gGraphicPic,$ghBitmap main() Func main() $gCtlWid = 893 $gCtlHt = 480 $gForm1 = GUICreate("Form1", $gCtlWid+50, 601, 192, 114) $glblPic = GUICtrlCreateLabel("", 8, 8, $gCtlWid, $gCtlHt) Local $btnRotate = GUICtrlCreateButton("Rotate", 472, 560, 65, 25) Local $btnExit = GUICtrlCreateButton(" Exit ",600,560) GUISetState(@SW_SHOW) Local $oldY0,$oldY1 _GDIPlus_Startup() $ghPen = _GDIPlus_PenCreate(0xFF999999,2) $ghImage = _GDIPlus_ImageLoadFromFile('H:\b\pergola.jpg') Local $hnd = GUICtrlGetHandle($glblPic) $gGraphicPic = _GDIPlus_GraphicsCreateFromHWND($hnd) $gY0 = 400 $gY1 = 400 $imgWid = _GDIPlus_ImageGetWidth($ghImage) $imgHt = _GDIPlus_ImageGetHeight($ghImage) $ghBitmap = _GDIPlus_BitmapCreateFromScan0($imgWid, $imgHt) $ghCanvas = _GDIPlus_ImageGetGraphicsContext($ghBitmap) ; Loop until the user exits. While True If $gY0<>$oldY0 Or $gY1<>$oldY1 Then Paint() $oldY0 = $gY0 $oldY1 = $gY1 Else Switch GUIGetMsg() Case $GUI_EVENT_CLOSE,$btnExit ExitLoop Case $btnRotate Local $hImageClone=_GDIPlus_BitmapCreateFromScan0($imgWid, $imgHt) Local $hGfxClone=_GDIPlus_ImageGetGraphicsContext($hImageClone) ; rotate about centre Local $gMatrix = _GDIPlus_MatrixCreate() _GDIPlus_MatrixTranslate($gMatrix, $imgWid/2, $imgHt/2) Local $deg = Angle($gY1-$gY0, $gX1-$gX0) _GDIPlus_MatrixRotate($gMatrix, -$deg) _GDIPlus_MatrixTranslate($gMatrix, -$imgWid/2, -$imgHt/2) _GDIPlus_GraphicsSetTransform($hGfxClone, $gMatrix) _GDIPlus_GraphicsDrawImageRect($hGfxClone,$ghImage,0,0,$imgWid,$imgHt) _GDIPlus_GraphicsDispose($hGfxClone) $hGfxClone=_GDIPlus_ImageGetGraphicsContext($ghImage) ; See deskew notes document Local $ang = Abs($deg*3.14159/180) Local $cos = cos($ang), $sin = sin($ang), $tan = tan($ang) Local $w2cos = $imgWid/2*$cos, $w2sin = $imgWid/2*$sin Local $h2cos = $imgHt/2*$cos, $h2sin = $imgHt/2*$sin Local $nsrcX = ($imgHt/2 - $w2sin - $h2cos)*$tan - $w2cos + $h2sin + $imgWid/2 Local $nsrcY = ($imgWid/2 + $w2cos - $h2sin)*$tan - $w2sin - $h2cos + $imgHt/2 Local $nSrcWidth = $imgWid - 2*$nSrcX Local $nSrcHeight = $imgHt - 2*$nSrcY ; crop to screen, centering within control _GDIPlus_GraphicsClear($hGfxClone,0xFFD4D0C8) ; client area background colour Local $nDstX = ($imgWid-$nSrcWidth)/2 Local $nDstY = ($imgHt-$nSrcHeight)/2 ; draw a portion of image object $hImageClone on the image that $hGfxClone points to _GDIPlus_GraphicsDrawImageRectRect($hGfxClone,$hImageClone, _ $nSrcX,$nSrcY,$nSrcWidth,$nSrcHeight,$nDstX,$nDstY,$nSrcWidth,$nSrcHeight) _GDIPlus_ImageDispose($hImageClone) $gy0 = 400 $gy1 = 400 Paint() Local $hImageClone2 = _GDIPlus_BitmapCloneArea($ghImage,$nsrcX,$nsrcY,$nSrcWidth,$nSrcHeight) _GDIPlus_ImageSaveToFile($hImageClone2,'H:\b\1.jpg') _GDIPlus_ImageDispose($hImageClone2) ShellExecute('H:\b\1.jpg') EndSwitch EndIf WEnd ; Clean up resources _GDIPlus_MatrixDispose($gMatrix) _GDIPlus_ImageDispose($ghCanvas) _GDIPlus_ImageDispose($ghImage) _GDIPlus_ImageDispose($ghBitmap) _GDIPlus_PenDispose($ghPen) _GDIPlus_GraphicsDispose($gGraphicPic) _GDIPlus_Shutdown() EndFunc Func WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam) #forceref $hWnd, $iMsg, $wParam, $lParam Local Const $MK_SHIFT=0x4,$MK_CONTROL= 0x8 Local Const $kYmax=$gCtlHt-1,$kDelta=2 Local $vec = GUIGetCursorInfo($gForm1) If $vec[4] = $vec[4]=$glblPic Then Local $iDelta = BitShift($wParam, 16) ; positive = up Local $iKeys = _WinAPI_LoWord($wParam) If BitAND($iKeys,$MK_CONTROL)=$MK_CONTROL Then If BitAND($iKeys,$MK_SHIFT)=$MK_SHIFT Then ; do nothing Else If $iDelta > 0 And $gY0>3 Then $gY0 -= $kDelta If $iDelta < 0 And $gY0<$kYmax Then $gY0 += $kDelta EndIf Else If BitAND($iKeys,$MK_SHIFT)=$MK_SHIFT Then If $iDelta > 0 And $gY1>3 Then $gY1 -= $kDelta If $iDelta < 0 And $gY1<$kYmax Then $gY1 += $kDelta Else If $iDelta > 0 And $gY0>3 Then $gY0 -= $kDelta If $iDelta < 0 And $gY0<$kYmax Then $gY0 += $kDelta If $iDelta > 0 And $gY1>3 Then $gY1 -= $kDelta If $iDelta < 0 And $gY1<$kYmax Then $gY1 += $kDelta EndIf EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_MOUSEWHEEL Func Paint() _GDIPlus_GraphicsClear($ghCanvas,0) _GDIPlus_GraphicsDrawImageRect($ghCanvas, $ghImage, 0,0, $gCtlWid, $gCtlHt) _GDIPlus_GraphicsDrawLine($ghCanvas, $gX0, $gY0, $gX1, $gY1, $ghPen) _GDIPlus_GraphicsDrawImageRect($gGraphicPic, $ghBitmap, 0, 0, $imgWid, $imgHt) EndFunc Func WM_PAINT() _WinAPI_RedrawWindow($gForm1, 0, 0, $RDW_UPDATENOW) Paint() _WinAPI_RedrawWindow($gForm1, 0, 0, $RDW_VALIDATE) EndFunc Func Angle($y, $x) ;return value is in degree Local Const $fPi = ACos(-1), $fPi2 = ACos(-1) / 2, $fRad = 180 / $fPi Switch True Case ($x > 0) Return ATan($y / $x) * $fRad Case ($x < 0 And $y >= 0) Return ATan($y / $x + $fPi) * $fRad Case ($x < 0 And $y < 0) Return ATan($y / $x - $fPi) * $fRad Case ($x = 0 And $y > 0) Return $fPi2 * $fRad Case ($x = 0 And $y < 0) Return -$fPi2 * $fRad Case ($x = 0 And $y = 0) Return 0 EndSwitch EndFunc
  21. Thank you, I could find this very useful thread (with all the explanations) thanks to your hint : As far as I'm concerned, this topic can now be closed.
  22. Hi, This code will give you the last row of column 1, and the last column on row 1 of your Excel file : $MaxRow = $oWorkbook.Sheets($SheetName).Range("A99999").End(-4162).Row $MaxCol = $oWorkbook.Sheets($SheetName).Range("ZZ1").End(-4159).Column -4162 is the internal Excel code for "XlUp" and -4159 the one for "XlToLeft". Make sure to adapt the 99999 and ZZ if necessary (i.e. if not high enough).
  23. Hello, A strange behaviour occured in my code, so I've stripped and stripped again its content, until I could confine and identify the very cause of the malfunction. Put under its simplest form, here it is : this kind of comparison is working, although at first sight it's no so evident why it is : If "338a" = 338 Then MsgBox(0, "", "Why oh why ?") EndIf I understand that comparing a string with an integer is a bit odd, however in the original code, I'm comparing variables from an array, and this array if filled from an Excel file through the _Excel_RangeRead function. The column of the Excel file can contain random values : some of them are 338 (interpreted as integer) and some others are 338a (interpreted as string). Now I can solve the problem by forcing the comparison like this : String(variable1) = String(variable2) where variable1 and variable2 can be of any type (coming from the Excel file). However I'd like to know the very reason why this comparison is working in the first place ? Please enlighten me ! Faalamva
  24. Msgbox(0,"", StringRegExpReplace(9578, '(?=\d{3}$)', "."))
  25. Ok so the REAL code is posted below.. But to answer your questions.. 1) Yes, for each testcode that I will pull from a .txt file, I want to check to see if it's assigned to a $testcodeIC1, or IC2 or IC3 or blah blah.. If it is, then write that to a file called blah.. if it's not then prompt the user for a $testcodeIC1 and save each to a file 2) I don't disagree, but a normal messagebox doesn't have enough options for the user to choose, I need 4 options (at least). And I'm a shitty programmer so.. #include <Array.au3> #include <MsgBoxConstants.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <File.au3> Global $TCArray[0] ; Dummy data for now Global $SampIDArray[0] _FileReadToArray(@ScriptDir & "\testcodesforclientIDs.txt", $TCArray, @CRLF) ;~ _ArrayDisplay($TCArray) _FileReadToArray(@ScriptDir & "\clientIDs.txt", $SampIDArray, @CRLF) ;~ _ArrayDisplay($SampIDArray) ;---------- Function Calls here AddAllTestCodes() Knownornot() Addtolistifknownfunction() ;--------- Functions Below here Func AddAllTestCodes() Global $testcodeIC1[0] Global $testcodeIC2[0] Global $testcodeIC3[0] Global $testcodeIC5[0] _FileReadToArray(@ScriptDir & "\IC1testcodes.txt", $testcodeIC1, @CRLF) _FileReadToArray(@ScriptDir & "\IC2testcodes.txt", $testcodeIC2, @CRLF) _FileReadToArray(@ScriptDir & "\IC3testcodes.txt", $testcodeIC3, @CRLF) _FileReadToArray(@ScriptDir & "\IC5testcodes.txt", $testcodeIC5, @CRLF) Global $totaltestcodes = UBound($testcodeIC1) + UBound($testcodeIC2) + UBound($testcodeIC3) + UBound($testcodeIC5) Global $knowntestcode[0] _ArrayAdd($knowntestcode, $testcodeIC1) _ArrayAdd($knowntestcode, $testcodeIC2) _ArrayAdd($knowntestcode, $testcodeIC3) _ArrayAdd($knowntestcode, $testcodeIC5) _ArrayDisplay($knowntestcode) EndFunc ;==>AddAllTestCodes Func Knownornot() For $i = 0 To UBound($TCArray) - 1 ;should write zomgnewtestcode to the unknown file, eventually this will prompt me to assign it to IC1, 2, or 3. But for now I just want to debug why the IF statement isn't working. Local $found = _ArraySearch($knowntestcode, $TCArray[$i]) If $found = -1 Then #Region ### START Koda GUI section ### Form=D:\GodModeAccount\Desktop\ArraydataClientIDHidden\ICSelectGUI.kxf $Form1 = GUICreate("Form1", 434, 146, 192, 200) $IC1 = GUICtrlCreateButton("IC 1", 24, 112, 89, 25) $IC2 = GUICtrlCreateButton("IC 2", 120, 112, 105, 25) $IC3 = GUICtrlCreateButton("IC3/4", 232, 112, 81, 25) $IC5 = GUICtrlCreateButton("IC5 or Unknown", 320, 112, 105, 25) $Label1 = GUICtrlCreateLabel("This test code was not found: Please select a IC to assign it to! " & $TCArray[$i], 8, 8, 412, 89) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $IC1 FileWrite(@ScriptDir & "\IC1testcodes.txt", $TCArray[$i] & @CRLF) Exit Case $IC2 FileWrite(@ScriptDir & "\IC2testcodes.txt", $TCArray[$i] & @CRLF) Exit Case $IC3 FileWrite(@ScriptDir & "\IC3testcodes.txt", $TCArray[$i] & @CRLF) Exit Case $IC5 FileWrite(@ScriptDir & "\IC5testcodes.txt", $TCArray[$i] & @CRLF) Exit EndSwitch WEnd EndIf Next EndFunc ;==>Knownornot Func Addtolistifknownfunction() For $i = 0 To UBound($TCArray) - 1 If $TCArray[$i] = $testcodeIC1 Then FileWrite(@ScriptDir & "\IC1.txt", $SampIDArray[$i] & " " & $TCArray[$i] & @CRLF) EndIf Next For $i = 0 To UBound($TCArray) - 1 If $TCArray[$i] = $testcodeIC2 Then FileWrite(@ScriptDir & "\IC2.txt", $SampIDArray[$i] & " " & $TCArray[$i] & @CRLF) EndIf Next For $i = 0 To UBound($TCArray) - 1 If $TCArray[$i] = $testcodeIC3 Then FileWrite(@ScriptDir & "\IC3.txt", $SampIDArray[$i] & " " & $TCArray[$i] & @CRLF) EndIf Next For $i = 0 To UBound($TCArray) - 1 If $TCArray[$i] = $testcodeIC5 Then FileWrite(@ScriptDir & "\IC5.txt", $SampIDArray[$i] & " " & $TCArray[$i] & @CRLF) EndIf Next EndFunc ;==>Addtolistifknownfunction
  26. A few more methods. $Number = 9578 $Output = Round($Number / 1000, 5) ; Round ( expression [, decimalplaces] ) ; Or $Output1 = Int($Number / 1000) & "." & Mod($Number, 1000) ;Or $Output2 = $Number / 1000 MsgBox(0, "Result:", $Output & @CRLF & $Output1 & @CRLF & $Output2)
  1. Load more activity