Closed Bug 845973 Opened 12 years ago Closed 12 years ago

Remove win32api dependency from mouse_and_screen_resolution.py

Categories

(Release Engineering :: General, defect)

x86
All
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: armenzg, Assigned: armenzg)

Details

Attachments

(1 file, 2 obsolete files)

I have been able to query but not call the actual function to change the resolution. > function 'ChangeDisplaySettings' not found Any ideas? Thanks!
Attachment #719145 - Flags: feedback?(wlachance)
Comment on attachment 719145 [details] [diff] [review] Remove win32api dependency from mouse_and_screen_resolution.py To answer your question, it looks like ChangeDisplaySettings is not defined as part of the user32 namespace, you have to call it ChangeDisplaySettingsA. Here's an example of using it: https://github.com/ravenscroftj/SPE/blob/master/sm/__init__.py#L50 And here's API documentation for the function: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183411%28v=vs.85%29.aspx One quick comment on your patch as it stands: >diff --git a/scripts/support/mouse_and_screen_resolution.py b/scripts/support/mouse_and_screen_resolution.py >+from ctypes import * I think it would be clearer if you just wrote "from ctypes import windll" here. As it is it's ambiguous where windll (which we're using later in the function) is coming from.
Attachment #719145 - Flags: feedback?(wlachance)
I saw the screen resolution change but then it returns back to the original after the python script ends. C:\Users\cltbld\Desktop>C:\mozilla-build\python27\python.exe mouse_and_screen_re solution.py --configuration-url http://hg.mozilla.org/mozilla-central/raw-file/d efault/testing/machine-configuration.json Screen resolution (current): (1600, 1200) Changing the screen resolution... Screen resolution (new): (1024, 768) C:\Users\cltbld\Desktop>C:\mozilla-build\python27\python.exe mouse_and_screen_re solution.py --configuration-url http://hg.mozilla.org/mozilla-central/raw-file/d efault/testing/machine-configuration.json Screen resolution (current): (1600, 1200) Changing the screen resolution... 0 Screen resolution (new): (1024, 768)
Attachment #719145 - Attachment is obsolete: true
Comment on attachment 719666 [details] [diff] [review] Remove win32api dependency from mouse_and_screen_resolution.py - attempt 2 >+ result = windll.user32.ChangeDisplaySettingsA(DevModeData, CDS_FULLSCREEN) I think you want to pass "0" here instead of CDS_FULLSCREEN. Using CDS_FULLSCREEN makes things temporary, or at least the documentation suggests it does: http://msdn.microsoft.com/en-us/library/windows/desktop/dd183411%28v=vs.85%29.aspx
And there was joy!
Attachment #719666 - Attachment is obsolete: true
Attachment #719974 - Flags: review?(wlachance)
Comment on attachment 719974 [details] [diff] [review] Remove win32api dependency from mouse_and_screen_resolution.py - attempt 2 Looks pretty reasonable except an unnecessary global. r+ without it. >+class POINT(Structure): >+ _fields_ = [("x", c_ulong), ("y", c_ulong)] > > def queryMousePosition(): >- pos = win32api.GetCursorPos() >- return {"x": pos[0], "y": pos[1]} >+ global pt Why is this a global? Don't really see any reason why it needs to be. Can't you just remove this line? >+ pt = POINT() >+ windll.user32.GetCursorPos(byref(pt)) >+ return pt.x, pt.y
Attachment #719974 - Flags: review?(wlachance) → review+
(In reply to William Lachance (:wlach) from comment #5) > Comment on attachment 719974 [details] [diff] [review] > Remove win32api dependency from mouse_and_screen_resolution.py - attempt 2 > > Looks pretty reasonable except an unnecessary global. r+ without it. > > >+class POINT(Structure): > >+ _fields_ = [("x", c_ulong), ("y", c_ulong)] > > > > def queryMousePosition(): > >- pos = win32api.GetCursorPos() > >- return {"x": pos[0], "y": pos[1]} > >+ global pt > > Why is this a global? Don't really see any reason why it needs to be. Can't > you just remove this line? > > >+ pt = POINT() > >+ windll.user32.GetCursorPos(byref(pt)) > >+ return pt.x, pt.y I'm testing it again without global. Maybe it was leftover from my development.
Assignee: nobody → armenzg
OS: Mac OS X → All
Comment on attachment 719974 [details] [diff] [review] Remove win32api dependency from mouse_and_screen_resolution.py - attempt 2 I removed the global line: http://hg.mozilla.org/build/tools/rev/0766c91b8536
Attachment #719974 - Flags: checked-in+
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Product: mozilla.org → Release Engineering
Component: General Automation → General
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: