
Zoldex
Active Members-
Posts
39 -
Joined
-
Last visited
Zoldex's Achievements

Seeker (1/7)
3
Reputation
-
I need some more help on this. Running the following example I do have strange behaviour: #include <AutoItConstants.au3> Example("user01") Example("user02") Example("user03") Func Example($uname) Local $sUserName = $uname Local $sPassword = "pw_is_always_the_same" ; Run chrome with the window maximized. chrome is run under the user previously specified. Local $iPID = RunAs($sUserName, @ComputerName, $sPassword, $RUN_LOGON_NOPROFILE, "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe", "", @SW_SHOWMAXIMIZED) ; Wait 10 seconds for the Chrome window to appear. WinWait("[CLASS:Chrome_WidgetWin_1]", "", 10) MouseMove(579,278,40) MouseClick($MOUSE_CLICK_LEFT) Sleep(2000) ; Close the Chrome process using the PID returned by RunAs. ProcessClose($iPID) EndFunc ;==>Example I would like to run Chrome 3 times (or more) as a different user, moving the mouse, closing the app, then do it again with different user. User01 runs fine: the mouse does the job and the process closes. user02 and user03 won't launch chrome anymore but the mouse keeps on moving and clicking, as programmed. It doesn't care if the window is open or not. Also, when I try to run chrome manually as user01, most of the times it says that chrome did not close well, and asks me to restore previous state. Why don't let me run chrome as other users? Why it only seems to work with first user? Thanks in advance for any help
-
OMG you're right, of course. I've completely forgot Runas... Thanks!
-
Zoldex reacted to a post in a topic: run a file as other user
-
Hello, It's loooong time I'm missing from this forum and my Autoit knowledge is heavily rusted. I'm looking for a way to run (launch) an application as other user. I do know that if I right-click an application icon while keeping Shift key pressed, i could select "run as other user", but i was looking for a more "elegant" way so I think it may be a way to do it with Autoit. If I know username and password of the other user there must be a way to do it automatically... Any help would be appreciated
-
Zoldex reacted to a post in a topic: Debenu Quick PDF Library - UDF
-
Zoldex reacted to a post in a topic: Debenu Quick PDF Library - UDF
-
-
Zoldex reacted to a post in a topic: HotKey UDF
-
Thanks mate! You saved my day!
-
Zoldex reacted to a post in a topic: HotKey UDF
-
I'm experiencing the very same problem: CTRL key keeps "hooked" and I need to press it alone to let it unlock. Anyways I'm having the problem also with original HotKeySet function... Hope someone can help...
-
-
Zoldex reacted to a file: Debenu Quick PDF Library - UDF
-
Hi, it does not seem to work anymore on SAP740... _SAPSessAttach("SAP Easy Access") returns this: >Running:(3.3.14.2):C:\Program Files (x86)\AutoIt3\autoit3.exe "C:\Cancellabili\SAP Test\_SAPSessAttach.au3" --> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop Unable to find the window with title "SAP Easy Access" to attach to. "C:\Cancellabili\SAP Test\SAP.au3" (446) : ==> Variable must be of type "Object".: $sap_session.findById("wnd[" & $sap_window_num & "]/" & $object_id).text = $object_value $sap_session^ ERROR ->14:58:30 AutoIt3.exe ended.rc:1 Of course, the SaAP Easy Access window is open.. Any hint?
-
Zoldex reacted to a post in a topic: SAPWizard.UDF
-
Zoldex reacted to a post in a topic: Chilkatsoft Component Example
-
Just discovered your project, and I'm simply... amused! Great job, and PLEASE keep on working on it!
- 995 replies
-
- isn autoit studio
- isn
-
(and 3 more)
Tagged with:
-
Yes, it does. But the crop function does not...
-
This is my attempt on loading and let the user select only a portion of an image. I found some samples by Melba23 and UEZ and tried to glue things together. I think I've almost done it but still have some problems: Resizing and displaying image is not always proportional (just try the script with different resolution images, expecially big ones) The rectangle selection to crop is wrong: it actually selects a different region of the screen Function _GUICtrlStatic_SetImage does not work. Temporarily fixed using _WinAPI_DeleteObject instead...Any hint would be greatly appreciated! #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> #include <StaticConstants.au3> Global $iX1, $iY1, $iX2, $iY2, $aPos, $sMsg, $sBMP_Path Global Const $IMAGE_BITMAP = 0 ; Needed for GUICtrlSendMsg. Global Const $STM_SETIMAGE = 0x0172 ; Needed for GUICtrlSendMsg. Local $GUIimg_title,$GUIwidth,$GUIheight,$GUILeft,$GUITop Local $filename = FileOpenDialog("Select image", @ScriptDir, "Image (*.jpg;*.bmp)", 3) $GUIimg_title = $filename _GDIPlus_Startup() Local $imagefromfile = _GDIPlus_ImageLoadFromFile($filename) ;Create an image object based on a file [OK] **NOTA PER LA ROTAZIONE VEDI HELP FILE!** Local $GUIwidth = _GDIPlus_ImageGetWidth ($imagefromfile) Local $GUIheight = _GDIPlus_ImageGetHeight ($imagefromfile) ;try to create a smaller window if the pictures is bigger than Desktop If $GUIwidth > @DesktopWidth Then $GUIwidth = @DesktopWidth - 6 EndIf If $GUIheight > @DesktopHeight Then $GUIheight = @DesktopHeight - 73 ; rought attempt to show the window bar... EndIf $GUILeft = (@DesktopWidth - $GUIwidth) / 2 $GUITop = (@DesktopHeight - $GUIheight) / 2 $hBitmap_resized = _GDIPlus_ScaleImage($imagefromfile, $GUIwidth, $GUIheight); attempts to scale the image but it not always proportional.. _GDIPlus_ImageDispose($imagefromfile) ; Display image $hBitmap_GUI = GUICreate($GUIimg_title & " [" & $GUIwidth & "x" & $GUIheight & "]", $GUIwidth, $GUIheight,$GUILeft,$GUITop) $hPic = GUICtrlCreatePic("", 0, 0, $GUIwidth, $GUIheight) GUISetState() Local $hHBitmap_resized = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hBitmap_resized); creates an handle _WinAPI_DeleteObject(GUICtrlSendMsg($hPic, $STM_SETIMAGE, $IMAGE_BITMAP, $hHBitmap_resized)) ; Updates the GUI - It works instead of _GDIPlus_ImageDispose($hHBitmap_resized) [OK] _WinAPI_DeleteObject($hHBitmap_resized) ;~ _GUICtrlStatic_SetImage($hPic, $hBitmap_resized); does not seems to work... using _WinAPI_DeleteObject above _GDIPlus_Shutdown() ; Create GUI ;~ Local $GUITop = $hMain_GUI = GUICreate("Select a function", 480, 50) $hRect_Button = GUICtrlCreateButton("Crop", 10, 10, 80, 30) $hRot_90_plus_Button = GUICtrlCreateButton("+90°", 95, 10, 50, 30) $hRot_90_minus_Button = GUICtrlCreateButton("-90°", 150, 10, 50, 30) $hOK_Button = GUICtrlCreateButton("OK", 305, 10, 50, 30) $hCancel_Button = GUICtrlCreateButton("Cancel", 360, 10, 80, 30) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE, $hCancel_Button FileDelete(@ScriptDir & "Rect.bmp") Exit Case $hRect_Button GUISetState(@SW_HIDE, $hMain_GUI) Mark_Rect($GUIwidth,$GUIheight,$GUILeft,$GUITop);selects wrong area!! ; Capture selected area $sBMP_Path = @ScriptDir & "Rect.bmp" ;~ _ScreenCapture_Capture($sBMP_Path, $iX1, $iY1, $iX2, $iY2, False) _ScreenCapture_CaptureWnd($sBMP_Path, $hBitmap_GUI,$iX1, $iY1, $iX2, $iY2, False) GUISetState(@SW_SHOW, $hMain_GUI) GUIDelete($hBitmap_GUI) ; Display image $hBitmap_GUI = GUICreate("Selected Rectangle", $iX2 - $iX1 + 1, $iY2 - $iY1 + 1, 100, 100) $hPic = GUICtrlCreatePic(@ScriptDir & "Rect.bmp", 0, 0, $iX2 - $iX1 + 1, $iY2 - $iY1 + 1) GUISetState() case $hRot_90_plus_Button ; Rotate +90 case $hRot_90_minus_Button ;Rotate -90 case $hOK_Button ;should return the resulting picture object EndSwitch WEnd ; ------------- Func Mark_Rect($width = @DesktopWidth, $height = @DesktopHeight, $Left = 0, $Top = 0);Made by Melba23 - Arguments added by me Local $aMouse_Pos, $hMask, $hMaster_Mask, $iTemp Local $UserDLL = DllOpen("user32.dll") Global $hRectangle_GUI = GUICreate("", $width, $height, $Left, $Top, $WS_POPUP, $WS_EX_TOOLWINDOW + $WS_EX_TOPMOST);create fading _GUICreateInvRect($hRectangle_GUI, 0, 0, 1, 1) GUISetBkColor(0) WinSetTrans($hRectangle_GUI, "", 95) GUISetState(@SW_SHOW, $hRectangle_GUI) GUISetCursor(3, 1, $hRectangle_GUI) ; Wait until mouse button pressed While Not _IsPressed("01", $UserDLL) Sleep(10) WEnd ; Get first mouse position $aMouse_Pos = MouseGetPos() $iX1 = $aMouse_Pos[0] $iY1 = $aMouse_Pos[1] ; Draw rectangle while mouse button pressed While _IsPressed("01", $UserDLL) $aMouse_Pos = MouseGetPos() ; Set in correct order if required If $aMouse_Pos[0] < $iX1 Then $iX_Pos = $aMouse_Pos[0] $iWidth = $iX1 - $aMouse_Pos[0] Else $iX_Pos = $iX1 $iWidth = $aMouse_Pos[0] - $iX1 EndIf If $aMouse_Pos[1] < $iY1 Then $iY_Pos = $aMouse_Pos[1] $iHeight = $iY1 - $aMouse_Pos[1] Else $iY_Pos = $iY1 $iHeight = $aMouse_Pos[1] - $iY1 EndIf _GUICreateInvRect($hRectangle_GUI, $iX_Pos, $iY_Pos, $iWidth, $iHeight) Sleep(10) WEnd ; Get second mouse position $iX2 = $aMouse_Pos[0] $iY2 = $aMouse_Pos[1] ; Set in correct order if required If $iX2 < $iX1 Then $iTemp = $iX1 $iX1 = $iX2 $iX2 = $iTemp EndIf If $iY2 < $iY1 Then $iTemp = $iY1 $iY1 = $iY2 $iY2 = $iTemp EndIf GUIDelete($hRectangle_GUI) DllClose($UserDLL) EndFunc ;==>Mark_Rect Func _GUICreateInvRect($hWnd, $iX, $iY, $iW, $iH) $hMask_1 = _WinAPI_CreateRectRgn(0, 0, @DesktopWidth, $iY) $hMask_2 = _WinAPI_CreateRectRgn(0, 0, $iX, @DesktopHeight) $hMask_3 = _WinAPI_CreateRectRgn($iX + $iW, 0, @DesktopWidth, @DesktopHeight) $hMask_4 = _WinAPI_CreateRectRgn(0, $iY + $iH, @DesktopWidth, @DesktopHeight) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_2, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_3, 2) _WinAPI_CombineRgn($hMask_1, $hMask_1, $hMask_4, 2) _WinAPI_DeleteObject($hMask_2) _WinAPI_DeleteObject($hMask_3) _WinAPI_DeleteObject($hMask_4) _WinAPI_SetWindowRgn($hWnd, $hMask_1, 1) EndFunc Func _GDIPlus_ScaleImage($hImage, $iW, $iH, $iInterpolationMode = 7) ;coded by UEZ 2012 Local $hBitmap = DllCall($ghGDIPDll, "uint", "GdipCreateBitmapFromScan0", "int", $iW, "int", $iH, "int", 0, "int", 0x0026200A, "ptr", 0, "int*", 0) If @error Then Return SetError(3, 0, 0) $hBitmap = $hBitmap[6] Local $hBmpCtxt = _GDIPlus_ImageGetGraphicsContext($hBitmap) DllCall($ghGDIPDll, "uint", "GdipSetInterpolationMode", "handle", $hBmpCtxt, "int", $iInterpolationMode) _GDIPlus_GraphicsDrawImageRect($hBmpCtxt, $hImage, 0, 0, $iW, $iH) _GDIPlus_ImageDispose($hImage) _GDIPlus_GraphicsDispose($hBmpCtxt) Return $hBitmap EndFunc Func _GUICtrlStatic_SetImage($iCtrlId, $hBitmap) Local Const $STM_SETIMAGE = 0x0172 Local Const $IMAGE_BITMAP = 0 Local Const $SS_BITMAP = 0xE Local Const $GWL_STYLE = -16 If IsHWnd($iCtrlId) Then If WinGetProcess($iCtrlId) <> @AutoItPID Then Return SetError(1,0,0) Else $iCtrlId = GUICtrlGetHandle($iCtrlId) If Not $iCtrlId Then Return SetError(2,0,0) EndIf ; set SS_BITMAP style to control Local $oldStyle = DllCall("user32.dll", "long", "GetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE) If @error Then Return SetError(3, 0, 0) DllCall("user32.dll", "long", "SetWindowLong", "hwnd", $iCtrlId, "int", $GWL_STYLE, "long", BitOR($oldStyle[0], $SS_BITMAP)) If @error Then Return SetError(4, 0, 0) Local $oldBmp = DllCall("user32.dll", "handle", "SendMessageW", "hwnd", $iCtrlId, "int", $STM_SETIMAGE, "wparam", $IMAGE_BITMAP, "handle", $hBitmap) If @error Then Return SetError(5, 0, 0) If $oldBmp[0] Then _WinAPI_DeleteObject($oldBmp[0]) Return 1 EndFunc
-
I'm trying to displaya picture on a gui but it doesn't work if I make some GDI+ operations just before creating the gui: #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> #include <StaticConstants.au3> Local $GUIimg_title,$GUIwidth,$GUIheight,$GUILeft,$GUITop Local $filename = FileOpenDialog("Select image", @ScriptDir, "Image (*.jpg;*.bmp)", 3) _GDIPlus_Startup() Local $imagefromfile = _GDIPlus_ImageLoadFromFile($filename) ;Create an image object based on a file Local $GUIwidth = _GDIPlus_ImageGetWidth($imagefromfile) Local $GUIheight = _GDIPlus_ImageGetHeight($imagefromfile) ; Display image $hBitmap_GUI = GUICreate("", $GUIwidth, $GUIheight) $hPic = GUICtrlCreatePic($filename, 0, 0) GUISetState() _GDIPlus_Shutdown() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE;, $hCancel_Button Exit ;~ EndSwitch WEnd Instead it works if I remove GDI+ ... Can't understand why! #include <GuiConstantsEx.au3> #include <WindowsConstants.au3> #Include <ScreenCapture.au3> #Include <Misc.au3> #include <StaticConstants.au3> Local $GUIimg_title,$GUIwidth,$GUIheight,$GUILeft,$GUITop Local $filename = FileOpenDialog("Select image", @ScriptDir, "Image (*.jpg;*.bmp)", 3) ;~ _GDIPlus_Startup() ;~ Local $imagefromfile = _GDIPlus_ImageLoadFromFile($filename) ;Create an image object based on a file ;~ Local $GUIwidth = _GDIPlus_ImageGetWidth($imagefromfile) ;~ Local $GUIheight = _GDIPlus_ImageGetHeight($imagefromfile) ;~ _GDIPlus_Shutdown() ; Display image ;$hBitmap_GUI = GUICreate("", $GUIwidth, $GUIheight) $hBitmap_GUI = GUICreate("", 800, 800); <---- had to use fixed size... $hPic = GUICtrlCreatePic($filename, 1, 1) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE;, $hCancel_Button Exit ;~ EndSwitch WEnd Any hints?
- 2 replies
-
- guictrlcreatepic
- gdi+
-
(and 1 more)
Tagged with:
-
FireFox reacted to a post in a topic: Excel XML UDF v1.-1 [UPDATE 19/10/2012]
-
Sorry I can't get it working on win7 x64...
-
Thanks! It looks useful.