Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 03/12/2015 in all areas

  1. Hi everyone, I've created a GUI that hides at the top of the screen, peeks out when mouse is held at top of screen for over ~1 second and can be clicked to slide down to display the GUI contents. Then it can be clicked again to slide away and hide after a timeout (~2.5 seconds). UPDATE 14/03/2015: Script has been completely overhauled and updated. Hope to get some feedback and perhaps improvements. Now also works in both Aero and non-Aero environments. Please make sure you download the two attached PNG files (NOT THEIR THUMBNAILS) to experience the GUI in whole glory (if you have Aero enabled). Feedback appreciated . Please do excuse me if something is not scripted in the best way possible, I am learning new things ever day and improving my autoit skills continuously. #include-once #NoTrayIcon #AutoIt3Wrapper_Outfile=Example.exe #AutoIt3Wrapper_Compression=4 #AutoIt3Wrapper_UseUpx=n #AutoIt3Wrapper_UseX64=n #include <GDIPlus.au3> #include <WindowsConstants.au3> #include <GUIConstants.au3> #include <WinAPIEx.au3> Global $bAero, $hidden = False, $tuck = False, $tucked = False, $untucked = False, $tucking = False, $untucking = False, $timer = 0, $tdiff = 0, _ $LAYERED_GUI = $WS_EX_LAYERED, $hGUI_child, $hGUI_height = 683 Global Const $hDwmApiDll = DllOpen("dwmapi.dll"), $sChkAero = DllStructCreate("int;") DllCall($hDwmApiDll, "int", "DwmIsCompositionEnabled", "ptr", DllStructGetPtr($sChkAero)) $bAero = DllStructGetData($sChkAero, 1) If Not $bAero Then $LAYERED_GUI = 0 $hGUI_height = $hGUI_height - 20 EndIf $hGUI = GUICreate("", 715, $hGUI_height, -1, 0, $WS_POPUP, $LAYERED_GUI + $WS_EX_TOPMOST, WinGetHandle(AutoItWinGetTitle())) $hIcon = _WinAPI_GetClassLongEx($hGUI, $GCL_HICON) _WinAPI_DestroyIcon($hIcon) _WinAPI_SetClassLongEx($hGUI, $GCL_HICON, 0) _WinAPI_SetClassLongEx($hGUI, $GCL_HICONSM, 0) If $bAero Then $hGUI_child = GUICreate("", 715-39, 683 - 26, 22, 3, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_TOPMOST, $hGUI) $hGUI_Font = $hGUI_child Else $hGUI_Font = $hGUI $hGUI_child = $hGUI EndIf GUISetBkColor(0xFFFFFF) GUISetFont(18, 100, Default, 'Segoe UI', $hGUI_Font, 5) GUICtrlCreateLabel('Example lbl:', 10, 25) GUICtrlCreateInput('input', 150, 20, 100, 35) $testbutton = GUICtrlCreateButton('Example button', 100, 250) GUISetFont(12, 100, Default, 'Segoe UI', $hGUI_Font, 5) GUICtrlCreateLabel('Right click on GUI to exit', 100, 500) $hGUI_child2 = GUICreate("", 112, 50, 299, 645, $WS_POPUP, $LAYERED_GUI + $WS_EX_MDICHILD + $WS_EX_TOPMOST, $hGUI_child) If Not $bAero Then GUISetBkColor(0xE0F2F7) $hGUI_Font = $hGUI_child2 GUISetFont(33, 100, Default, 'Segoe UI', $hGUI_Font, 5) GUICtrlCreateLabel(" = ", 0, 0, 112, 50, $SS_CENTER + $SS_CENTERIMAGE) EndIf GUISetCursor(0, 1, $hGUI_child2) If $bAero Then _GDIPlus_Startup() $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\panel.png') SetBitmap($hGUI, $hImage) $hImage = _GDIPlus_ImageLoadFromFile(@ScriptDir & '\roundbn.png') SetBitmap($hGUI_child2, $hImage) _GDIPlus_Shutdown() EndIf GUISetState(@SW_SHOW, $hGUI) If $bAero Then GUISetState(@SW_SHOW, $hGUI_child) GUISetState(@SW_SHOW, $hGUI_child2) While 1 $mPos = MouseGetPos() If BitAnd($hidden, $mPos[1] = 0, $timer = 0) Then $timer = TimerInit() Sleep(10) ElseIf $mPos[1] <> 0 Then $timer = 0 $tdiff = 0 EndIf If $timer <> 0 Then $tdiff = TimerDiff($timer) If BitAND($hidden, Not $tucked, $mPos[1] <> 0, Not $tucking) Then $tuck = True $untucking = False $tucking = True AdlibRegister("TuckAway", 2500) ElseIf BitAND($hidden, $tucked, $mPos[1] = 0, Not $untucking, $tdiff > 450) Then $tuck = False $tucking = False $untucking = True AdlibRegister("TuckAway") ElseIf BitAND($hidden, Not $tucked, $mPos[1] = 0, $tucking) Then AdlibUnRegister("TuckAway") $tuck = False $tucking = False EndIf $msg = GUIGetMsg(1) Switch $msg[1] Case $hGUI Switch $msg[0] Case $GUI_EVENT_CLOSE, $GUI_EVENT_SECONDARYUP Exit Case $testbutton MsgBox(0,'Button','You clicked a button!', 0, $hGUI) EndSwitch Case $hGUI_child Switch $msg[0] Case $GUI_EVENT_CLOSE, $GUI_EVENT_SECONDARYUP Exit Case $testbutton MsgBox(0,'Button','You clicked a button!', 0, $hGUI_child) EndSwitch Case $hGUI_child2 Switch $msg[0] Case $GUI_EVENT_PRIMARYDOWN If Not $hidden Then HidePanel() Else HidePanel(False) EndIf EndSwitch EndSwitch WEnd Func HidePanel($hide = True) AdlibUnRegister("TuckAway") If $hide Then $tucked = False $untucked = True $hidden = True For $i = -1 to -663 Step - 1 WinMove($hGUI, "", Default, $i) Next Else $tucked = False $untucked = False $hidden = False For $i = -664 to -4 Step 1 WinMove($hGUI, "", Default, $i) Next EndIf EndFunc Func TuckAway() If $tuck Then $tucking = False $untucked = False $tucked = True For $i = 663 to 695 Step 1 WinMove($hGUI, "", Default, -$i) Sleep(10) Next Else $untucking = False $tucked = False For $i = 695 to 663 Step - 1 WinMove($hGUI, "", Default, -$i) Sleep(10) Next EndIf AdlibUnRegister("TuckAway") EndFunc Func SetBitmap($hGUI, $hImage, $iOpacity = 255) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hGUI, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc
    2 points
  2. jguinch

    _StringShuffle

    Here is a small function to shuffle a string : ConsoleWrite( _StringShuffle("I like AutoIt !") ) Func _StringShuffle($sString) For $i = StringLen($sString) - 1 To 0 Step -1 $sString = StringRegExpReplace($sString, "(?s)(.{" & Random(0, $i, 1) & "})(.)(.*)", "$1$3$2") Next Return $sString EndFunc It could be useful ?
    1 point
  3. Melba23

    Auto file copier

    rapfreak, Because you were asked not to do it. And please do not send PMs asking for help - the Forum rules specifically ask you not do that either. And if you got as many as I still do you would understand why! But I will take a look at the code this evening. M23
    1 point
  4. jchd

    Regular express to array

    Try this: #include <Array.au3> Local $str = " 11:05:40.839855 T2708 DBG Feat stats, sensor 78: BG, p=2000: c=10: 100%." Local $res = StringRegExp($str, "(?i)(\d+:\d+:\d+\.\d+).*?sensor\s+(\d+):\s+([^,]+),\s+p=(\d+):\s+c=(\d+):\s+(\d+)%", 1) _ArrayDisplay($res)
    1 point
  5. Ok, so I'm smashing my head with autoit and tesseract and I have a problem. The code works and does what it needs to do on one environment but not on another. When running it on Windows Server 2012 (2 DELL monitors connected) it works, but when I used on my home environment, Windows 8 (2 TVs connected) it does not. Here is the code: #include <SimpleTesseract.au3> #include <ScreenCapture.au3> #include <Array.au3> #include <String.au3> GLOBAL $var1 GLOBAL $num1 GLOBAL $var2 GLOBAL $num2 GLOBAL $diff GLOBAL $x GLOBAL $z ;Tesseract Path for temp files (where you put the app) _TesseractTempPathSet("D:\AUTOIT") ;Get First Val Screenshot SplashImageOn ( "Test", "D:\AUTOIT\tst1.jpg" , 135 , 30 , 0 , 0, 1) sleep(200) _ScreenCapture_Capture("D:\AUTOIT\TEST1.jpg", 0, 0, 135, 30) sleep(1000) ;Get First Val SplashImageOn ( "Test", "D:\AUTOIT\TEST1.jpg" , 135 , 30 , 0 , 0, 1) sleep(200) $var1 = _TesseractScreenCapture(0, "", 0, 3, 0, 0, 135, 30, 0) sleep(200) ;Get Second Val Screenshot SplashImageOn ( "Test", "D:\AUTOIT\tst2.jpg" , 135 , 30 , 0 , 0, 1) sleep(200) _ScreenCapture_Capture("D:\AUTOIT\TEST2.jpg", 0, 0, 135, 30) sleep(1000) ;Get Second Val SplashImageOn ( "Test", "D:\AUTOIT\tst2.jpg" , 135 , 30 , 0 , 0, 1) sleep(200) $var2 = _TesseractScreenCapture(0, "", 0, 4, 0, 0, 135, 30, 0) sleep(200) ;Parse First Val $var1 = StringReplace($var1, ",", "") $num1 = Number($var1) ;Parse Second Val $var2 = StringReplace($var2, ",", "") $num2 = Number($var2) ;Calculate $diff = $num2 - $num1 ;Parse XP Number =========================== $x = StringLen($diff) $z = Int($x/3) if IsInt($x/$z) then if $z = 1 Then $diff = _StringInsert ($diff, ",", $x-3); under 1,000,000 XP else for $i = 1 to $z-1 $diff = _StringInsert ($diff, ",", $x-3*$i); under 1,000,000,000 XP Next endif else for $i = 1 to $z $diff = _StringInsert ($diff, ",", $x-3*$i); under 1,000,000,000,000 XP Next Endif ;End Of Parse XP Number ==================== ;Display Tooltip("First Image: " & $var1 & " Second Image: " & $var2 & " Difference: " & $diff, 500, 0) sleep(10000) Here are the needed files: http://www.filedropper.com/simpletesseract http://www.filedropper.com/tst1 http://www.filedropper.com/tst2 Please help if you have any idea. You should always set it up with 0 at the end. It always does something. If it "does" nothing when set with 0 at the end it means that the array is null. When you set it up with 1 at the end you will get that error which you stated. Also if you configured a path two files will be created. Random name having the following: 1. file .tiff with image on which tesseract performs OCR 2. file .txt with result after ocr was performed on image Here is an image if it is not clear: http://www.filedropper.com/explanation
    1 point
  6. PlayHD

    GUI design concepts.

    One of my old projects... #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <WinApi.au3> Global $RBOX_EVENT_CLOSE = 1 Global $ROUNDES = 20, $LastHwnd = 0 Global $GUIBKCOLOR = 0xEEC591 Global $ARRAY_COLOR_TOP_MIN[3] = [36 ,65 ,142] , $ARRAY_COLOR_TOP_MAX[3] = [11 ,42 ,122] Local $hGui = RBoxCreate("Gui Design PHD",800,600) While 1 CheckX($hGui,$RBOX_EVENT_CLOSE,"GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0xA3A3A3)","GuiCtrlSetColor("&$RBOX_EVENT_CLOSE&",0x555555)") $gMsg = GUIGetMsg() Switch $gMsg Case $RBOX_EVENT_CLOSE, $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func RBoxCreate($Title,$width, $height ,$left=-1 ,$top=-1 ,$show=1) Local $GUI = GUICreate($Title,$width,$height,$left,$top,$WS_POPUP) GUISetBkColor($GUIBKCOLOR,$GUI) _GuiRoundCorners($GUI,0,0,$ROUNDES,$ROUNDES) $RBOX_EVENT_CLOSE = GUICtrlCreateLabel('X',$width-20,3,25,25) GUICtrlSetCursor($RBOX_EVENT_CLOSE,0) GUICtrlSetBkColor($RBOX_EVENT_CLOSE,-2) GUICtrlSetFont($RBOX_EVENT_CLOSE,15,800) GUICtrlSetColor($RBOX_EVENT_CLOSE,0x555555) $Title &= " " Local $hTitle = GUICtrlCreateLabel($Title,0,0,$width-20,26,$SS_CENTER,$GUI_WS_EX_PARENTDRAG) GUICtrlSetFont($hTitle,17,400,0,"Consolas") GUICtrlSetBkColor($hTitle,-2) Local $Graphic = GUICtrlCreateGraphic (0,0, $width, 25) GUICtrlSetState($Graphic,$Gui_DISABLE) GradientFill($Graphic, 0, 0, $width, 25, $ARRAY_COLOR_TOP_MIN, $ARRAY_COLOR_TOP_MAX) If $show = 1 Then GUISetState(@SW_SHOW,$GUI) Return $GUI EndFunc Func CheckX($hGui, $CtrlID, $sCMD, $eCMD) Local $cGui = GUIGetCursorInfo($hGui) If Not IsArray($cGui) Then Return 0 if $LastHwnd <> $cGui[4] And $cGui[4] = $CtrlID Then Return Execute($sCMD) + Assign("LastHwnd",$cGui[4]) if $LastHwnd <> $cGui[4] Then Return Execute($eCMD) + Assign("LastHwnd",$cGui[4]) EndFunc Func _GuiRoundCorners($h_win, $i_x1, $i_y1, $i_x3, $i_y3) Dim $pos, $ret, $ret2 $pos = WinGetPos($h_win) $ret = DllCall("gdi32.dll", "long", "CreateRoundRectRgn", "long", $i_x1, "long", $i_y1, "long", $pos[2], "long", $pos[3], "long", $i_x3, "long", $i_y3) If $ret[0] Then $ret2 = DllCall("user32.dll", "long", "SetWindowRgn", "hwnd", $h_win, "long", $ret[0], "int", 1) If $ret2[0] Then Return 1 Else Return 0 EndIf Else Return 0 EndIf EndFunc Func GradientFill($im, $x1, $y1, $width, $height, $left_color, $right_color) Local $color0=($left_color[0]-$right_color[0])/$height Local $color1=($left_color[1]-$right_color[1])/$height $color2=($left_color[2]-$right_color[2])/$height For $Y=0 to $height-1 $red=$left_color[0]-floor($Y*$color0) $green=$left_color[1]-floor($Y*$color1) $blue=$left_color[2]-floor($Y*$color2) $col = Dec(Hex($blue,2) & Hex($green,2) & Hex($red,2)) GUICtrlSetGraphic($im,$GUI_GR_COLOR, $col) GUICtrlSetGraphic($im,$GUI_GR_MOVE,0,$Y) GUICtrlSetGraphic($im,$GUI_GR_LINE,$width,$Y) Next GUICtrlSetGraphic($im,$GUI_GR_COLOR, 0x000000) GUICtrlSetGraphic($im,$GUI_GR_MOVE,0,$height) GUICtrlSetGraphic($im,$GUI_GR_LINE,$width,$height) GUICtrlSetGraphic($im,$GUI_GR_REFRESH) EndFunc Here is a screen : http://prntscr.com/ni5sq
    1 point
  7. UEZ

    GUI design concepts.

    Found this in my collection: ;another fast hack by UEZ 2011 #include <GDIPlus.au3> #include <WindowsConstants.au3> Opt("GUIOnEventMode", 1) _GDIPlus_Startup() Global Const $SC_DRAGMOVE = 0xF012 Global Const $W = -1 Global Const $H = 200 Global Const $hGUI = GUICreate("GDI+ Test by UEZ 2011", $W, $H, -1, -1, $WS_POPUP, $WS_EX_LAYERED) Global Const $hGUI_Child = GUICreate("", $W, $H, 0, 0, $WS_POPUP, $WS_EX_MDICHILD + $WS_EX_LAYERED + $WS_EX_TOOLWINDOW, $hGUI) GUISetBkColor(0xABCDEF, $hGUI_Child) GUISwitch($hGUI_Child) Global Const $idButton = GUICtrlCreateButton("Exit", 40, 20, 100, 40) GUICtrlSetOnEvent(-1, "_Exit") Global Const $idLabel = GUICtrlCreateLabel("TEST LABEL HERE!!!", 110, 140, 180, 20) GUICtrlSetFont(-1, 14, 400, 0, "Times New Roman", 3) GUICtrlSetColor(-1, 0xF0F0FF) GUICtrlSetBkColor(-1, -2) _WinAPI_SetLayeredWindowAttributes($hGUI_Child, 0xABCDEF, 0xFF) GUISetState(@SW_SHOW, $hGUI_Child) GUISetState(@SW_SHOW, $hGUI) _SetGuiRoundCorners($hGUI, 40, False, True, True, False) Global Const $hGraphic = _GDIPlus_GraphicsCreateFromHWND($hGUI) Global Const $hBitmap = _CreateCustomBk($hGUI, 0x550555) Global Const $hContext = _GDIPlus_ImageGetGraphicsContext($hBitmap) _CreateCustomGroupPic($hContext, 100, 100, 200, 75, 0xff0000) _GDIPlus_GraphicsDrawImageRect($hGraphic, $hBitmap, 0, 0, $W, $H) SetTransparentBitmap($hGUI, $hBitmap, 0xD0) GUISetOnEvent(-3, "_Exit") GUIRegisterMsg($WM_LBUTTONDOWN, "_WM_LBUTTONDOWN") While Sleep(2 ^ 16) WEnd Func _Exit() _GDIPlus_BitmapDispose($hBitmap) _GDIPlus_GraphicsDispose($hContext) _GDIPlus_GraphicsDispose($hGraphic) _GDIPlus_Shutdown() GUIDelete($hGUI_Child) GUIDelete($hGUI) Exit EndFunc ;==>_Exit Func _CreateCustomBk($hGUI, $hexColor, $alpha = "0xAA") Local $iWidth = _WinAPI_GetClientWidth($hGUI) Local $iHeight = _WinAPI_GetClientHeight($hGUI) Local $oBitmap = _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext($oBitmap) _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, 0, 0, $iWidth, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $iWidth - 6, $iHeight - 6, $hBrush) _GDIPlus_BrushSetSolidColor($hBrush, 0x22FFFFFF) Local $iTimes = Round($iWidth / 50) Local $aPoints[5][2] $aPoints[0][0] = 4 $aPoints[1][1] = $iHeight $aPoints[2][1] = $iHeight $aPoints[4][1] = 0 $aPoints[3][1] = 0 For $i = 0 To $iTimes Local $Random1 = Random(0, $iWidth, 1) Local $Random2 = Random(30, 50, 1) $aPoints[1][0] = $Random1 $aPoints[2][0] = $Random1 + $Random2 $aPoints[4][0] = $aPoints[1][0] + 50 $aPoints[3][0] = $aPoints[2][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) $aPoints[1][0] -= $Random2 / 10 $aPoints[2][0] = $Random1 + $Random2 - ($Random2 / 10 * 2) $aPoints[3][0] = $aPoints[2][0] + 50 $aPoints[4][0] = $aPoints[1][0] + 50 _GDIPlus_GraphicsFillPolygon($hGraphics, $aPoints, $hBrush) Next _GDIPlus_BrushDispose($hBrush) _GDIPlus_GraphicsDispose($hGraphics) Return $oBitmap EndFunc ;==>_CreateCustomBk Func _CreateCustomGroupPic($hGraphics, $ix, $iy, $Width, $iHeight, $hexColor, $alpha = "0x55") _GDIPlus_GraphicsSetSmoothingMode($hGraphics, 2) Local $hBrush = _GDIPlus_BrushCreateSolid($alpha & Hex($hexColor, 6)) _GDIPlus_GraphicsFillRect($hGraphics, $ix, $iy, $Width, $iHeight, $hBrush) _GDIPlus_GraphicsFillRect($hGraphics, 2, 2, $Width - 4, $iHeight - 4, $hBrush) _GDIPlus_BrushDispose($hBrush) EndFunc ;==>_CreateCustomGroupPic Func _SetGuiRoundCorners($hGUI, $iEllipse, $iLeftUp = True, $iLeftDown = True, $iRightUp = True, $iRightDown = True) Local $hCornerRgn Local $aGuiSize = WinGetPos($hGUI) Local $hRgn = _WinAPI_CreateRoundRectRgn(0, 0, $aGuiSize[2], $aGuiSize[3], $iEllipse, $iEllipse) If $iLeftUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, 0, $aGuiSize[2] / 2, $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iLeftDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn(0, $aGuiSize[3] / 2, $aGuiSize[2] / 2, $aGuiSize[3]) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightUp = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, 0, $aGuiSize[2], $aGuiSize[3] / 2) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf If $iRightDown = False Then $hCornerRgn = _WinAPI_CreateRectRgn($aGuiSize[2] / 2, $aGuiSize[3] / 2, $aGuiSize[2] - 1, $aGuiSize[3] - 1) _WinAPI_CombineRgn($hRgn, $hRgn, $hCornerRgn, $RGN_OR) _WinAPI_DeleteObject($hCornerRgn) EndIf _WinAPI_SetWindowRgn($hGUI, $hRgn) EndFunc ;==>_SetGuiRoundCorners Func SetTransparentBitmap($hGUI, $hImage, $iOpacity = 0xFF) Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend $hScrDC = _WinAPI_GetDC(0) $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC) $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage) $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap) $tSize = DllStructCreate($tagSIZE) $pSize = DllStructGetPtr($tSize) DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage)) DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage)) $tSource = DllStructCreate($tagPOINT) $pSource = DllStructGetPtr($tSource) $tBlend = DllStructCreate($tagBLENDFUNCTION) $pBlend = DllStructGetPtr($tBlend) DllStructSetData($tBlend, "Alpha", $iOpacity) DllStructSetData($tBlend, "Format", 1) _WinAPI_UpdateLayeredWindow($hGUI, $hMemDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA) _WinAPI_ReleaseDC(0, $hScrDC) _WinAPI_SelectObject($hMemDC, $hOld) _WinAPI_DeleteObject($hBitmap) _WinAPI_DeleteDC($hMemDC) EndFunc ;==>SetTransparentBitmap Func _GDIPlus_BitmapCreateFromScan0($iWidth, $iHeight, $iStride = 0, $iPixelFormat = 0x0026200A, $pScan0 = 0) Local $aResult = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iWidth, "int", $iHeight, "int", $iStride, "int", $iPixelFormat, "ptr", $pScan0, "int*", 0) If @error Then Return SetError(@error, @extended, 0) Return $aResult[6] EndFunc ;==>_GDIPlus_BitmapCreateFromScan0 Func _WM_LBUTTONDOWN($hWnd, $iMsg, $wParam, $lParam) _SendMessage($hGUI, $WM_SYSCOMMAND, $SC_DRAGMOVE, 0) EndFunc ;==>_WM_LBUTTONDOWN Screenshot: Br, UEZ
    1 point
  8. jvanegmond

    MySQL UDFs

    So much for homework lol... No includes, ready to compile and use wherever you like. Global Const $ES_PASSWORD = 32 Global Const $ES_AUTOVSCROLL = 64 Global Const $ES_AUTOHSCROLL = 128 $sDriver = "{MySQL ODBC 3.51 Driver}" Local $v = StringMid($sDriver, 2, StringLen($sDriver) - 2) Local $key = "HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI\ODBC Drivers", $val = RegRead($key, $v) If @error or $val = "" Then $error = 1 EndIf Dim $error, $sql, $dontshow $objErr = ObjEvent("AutoIt.Error","MyErrFunc") GUICreate("MySQL Analyser", 350, 205) GUICtrlCreateLabel("User:", 10, 15) $username=GUICtrlCreateInput("", 65, 10, 100, 25, 128) GUICtrlCreateLabel("Password:", 10, 50) $password=GUICtrlCreateInput("", 65, 45, 100, 25, 32) GUICtrlCreateLabel("Server*:", 175, 15) $server=GUICtrlCreateInput("", 230, 10, 100, 25, 128) $logbox=GUICtrlCreateEdit("", 10, 75, 330, 95, 64) $vinkje=GUICtrlCreateCheckbox("Msgbox Errors", 10, 175) $connect=GUICtrlCreateButton("Connect", 260, 175, 80, 25) If $error = 1 Then GUICtrlSetState($username,128) GUICtrlSetState($password,128) GUICtrlSetState($server,128) GUICtrlSetState($vinkje,128) GUICtrlSetState($logbox,128) GUICtrlSetState($connect,128) GUICtrlSetData($logbox,@CRLF & "MySQL ODBC Driver 3.51 not installed!" & @CRLF & "Download from http://dev.mysql.com/downloads/connector/odbc/3.51.html", 1) Else GUICtrlSetData($logbox,"Welcome to MySQL Analyser" & @CRLF & "Be careful, this program will test on database 'fiets123'" & @CRLF & "Any data stored there will be lost" & @CRLF, 1) EndIf GUISetState() While 1 $msg = GUIGetMsg() If $msg = -3 Then Exit If $msg = $connect Then If GUICtrlRead($server) = "" Then GUICtrlSetData($logbox, "Server field is required" & @CRLF, 1) Else GUICtrlSetData($logbox, "Connecting.." & @CRLF, 1) $sql = _MySQLConnect(GUICtrlRead($username), GUICtrlRead($password), "", GUICtrlRead($server)) If $error = "" Then GUICtrlSetData($logbox, "Starting queries" & @CRLF, 1) $dontshow = "1" _Query($sql, "CREATE DATABASE `fiets123`;") If $error = "1" Then _Query($sql, "DROP DATABASE `fiets123` ") $dontshow = "" _Query($sql, "CREATE DATABASE `fiets123`;") EndIf $sql = _MySQLConnect(GUICtrlRead($username), GUICtrlRead($password), "fiets123", GUICtrlRead($server)) Queries() Else GUICtrlSetData($logbox, "Unable to connect" & @CRLF, 1) EndIf $error = "" EndIf EndIf Wend Func Queries() _Query($sql, "CREATE TABLE `aapje321` (`id` BIGINT NOT NULL AUTO_INCREMENT ,`546` VARCHAR( 255 ) NOT NULL ,`aaan` VARCHAR( 243 ) NOT NULL ,`gekkie` VARCHAR( 111 ) NOT NULL ,PRIMARY KEY ( `id` ) );") _Query($sql, "INSERT INTO `aapje321` ( `id` , `546` , `aaan` , `gekkie` ) VALUES ('', 'gegeven1', 'gegeven2', 'gegeven3');") _Query($sql, "TRUNCATE TABLE `aapje321` ") _Query($sql, "DROP TABLE `aapje321` ") _Query($sql, "DROP DATABASE `fiets123` ") If $error = "" Then GUICtrlSetData($logbox, "All queries were performed succesfully" & @CRLF, 1) EndIf EndFunc Func _Query($oConnectionObj,$sQuery) if isobj($oConnectionobj) Then Return $oConnectionobj.execute($sQuery) EndIf if @error Then seterror(1) return 0 EndIf EndFunc Func _MySQLConnect($sUsername, $sPassword, $sDatabase, $sServer, $sDriver = "{MySQL ODBC 3.51 Driver}") $ObjConn = ObjCreate("ADODB.Connection") $Objconn.open("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword & ";") if @error Then seterror(1) return 0 Else return $objconn EndIf EndFunc func _MySQLEnd($oConnectionObj) if isobj($oConnectionObj) Then $oConnectionObj.close return 1 Else seterror(1) return 0 EndIf EndFunc Func MyErrFunc() If $dontshow = "" Then If GUICtrlRead($vinkje) = 1 Then $hexnum=hex($objErr.number,8) Msgbox(0,"","COM Error" & @CRLF & @CRLF & _ "err.description is: " & $objErr.description & @CRLF & _ "err.windescription is: " & $objErr.windescription & @CRLF & _ "err.number is: " & $hexnum & @CRLF & _ "err.source is: " & $objErr.source _ ) GUICtrlSetData($logbox, StringReplace($objErr.description, "[MySQL][ODBC 3.51 Driver]", "[Error]") & @CRLF, 1) $error = "1" Else GUICtrlSetData($logbox, StringReplace($objErr.description, "[MySQL][ODBC 3.51 Driver]", "[Error]") & @CRLF, 1) $error = "1" EndIf EndIf EndFunc
    1 point
×
×
  • Create New...